Search code examples
python3dgeometrymesh

Boolean geometry subtraction of 3D meshes


I am parsing a 3D mesh from .obj using pywavefront which gives me vertices, faces and normals. I want to calculate the remaining area from subtracting another mesh.

Following up on calculating volume I wonder how can I perform operations on the meshes such as intersect and subtract.


Solution

  • If I understand correctly, in order to get the volume of your remaining area you should first compute the resulting mesh. This is known as boolean operations which are often implemented on envelopes (surface mesh like in the .obj files)

    There is several python modules proposing implementations for boolean operation on meshes.

    • pymesh exposes the algorithms of CGAL (c++ library)
    • pymadcad with a different algorithm in pure python
    • blender which is a complete software but which provide boolean operations in their API
    • trimesh relying on CGAL and Blender

    there is few other modules but - as far as I know - all of them are relying on pymesh or blender under the coat.