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);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…