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

2

11

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?

Cowskin answered 11/7, 2014 at 9:45 Comment(0)
A
13

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);
Airburst answered 3/11, 2014 at 6:56 Comment(0)
J
1

One additional possibility is to use open-source C++ library MeshLib. It can read and write meshes in Wavefront format (.obj) and robustly perform Boolean operations (intersection, union, difference) on meshes: documentation of the appropriate functions.

As far as I know, Boolean operations in MeshLib are faster than in CGAL and libigl, see video of MeshInspector application based on MeshLib.

Jellicoe answered 3/10, 2022 at 5:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.