Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ library for mesh to mesh intersection: what is available?

I need to calculate volume intersection and penetration depth between 3D triangular meshes (e.g. in .obj format), but I am quite new to computational geometry.

In a previous post (Mesh to mesh intersections) and from my google search, I found a few C++ libraries which might be appropriate to do the job:

  • CGAL
  • PQP
  • libigl
  • SWIFT

Though, I am not sure which one could be the most appropriate for a beginner. Any suggestion?

like image 630
Nic Avatar asked Jul 11 '14 09:07

Nic


1 Answers

libigl as of version 1.1 has robust mesh boolean operations in igl/boolean/mesh_boolean.h. This uses either an implementation using CGAL's exact arithmetic kernel or a wrapper of cork (another option for you).

For now, libigl also contains a patched version of cork in libigl/external/cork, which greatly improves robustness.

While implementing libigl's boolean ops, I found that cork is faster but does not always produce the correct result (specifically, it fails to resolve all intersections).

Libigl, using CGAL as a backend, is the most robust and still fast compared to converting a mesh to CGAL's Nef_polyhedron, conducting CSG operations and converting back to a mesh. This final conversion would be possible only if the result is manifold. Instead, libigl only uses CGAL for exact triangle-triangle intersection and 2D meshing. Correct, non-manifold output is no problem.

Libigl's interface is very simple and familiar to users of Eigen. For example, to find the intersection between a solid mesh with vertices in the rows of VA and triangles indices in the rows of FA and another mesh (VB,FB) and store the output in a new mesh (VC,FC):

#include <igl/boolean/mesh_boolean.h>
...
igl::mesh_boolean(VA,FA,VB,FB,MESH_BOOLEAN_TYPE_UNION,VC,FC);
like image 106
Alec Jacobson Avatar answered Sep 20 '22 14:09

Alec Jacobson