MCPcopy Create free account
hub / github.com/PyMesh/PyMesh / boolean

Function boolean

python/pymesh/boolean.py:17–111  ·  view source on GitHub ↗

Perform boolean operations on input meshes. Args: mesh_1 (:class:`Mesh`): The first input mesh, :math:`M_1`. mesh_2 (:class:`Mesh`): The second input mesh, :math:`M_2`. operation (``string``): The name of the operation. Valid choices are: * ``intersection`

(mesh_1, mesh_2, operation, engine="auto", with_timing=False,
        exact_mesh_file=None)

Source from the content-addressed store, hash-verified

15 return engine
16
17def boolean(mesh_1, mesh_2, operation, engine="auto", with_timing=False,
18 exact_mesh_file=None):
19 """ Perform boolean operations on input meshes.
20
21 Args:
22 mesh_1 (:class:`Mesh`): The first input mesh, :math:`M_1`.
23 mesh_2 (:class:`Mesh`): The second input mesh, :math:`M_2`.
24 operation (``string``): The name of the operation. Valid choices are:
25
26 * ``intersection``: :math:`M_1 \cap M_2`
27 * ``union``: :math:`M_1 \cup M_2`
28 * ``difference``: :math:`M_1 \setminus M_2`
29 * ``symmetric_difference``: :math:`(M_1 \setminus M_2) \cup
30 (M_2 \setminus M_1)`
31
32 engine (``string``): (optional) Boolean engine name. Valid engines include:
33
34 * ``auto``: Using the default boolean engine
35 (``igl`` for 3D and ``clipper`` for 2D). This is the default.
36 * ``cork``: `Cork 3D boolean libary
37 <https://github.com/gilbo/cork>`_
38 * ``cgal``: `CGAL 3D boolean operations on Nef Polyhedra
39 <http://doc.cgal.org/latest/Nef_3/index.html>`_
40 * ``corefinement``: The undocumented CGAL boolean function that does
41 not use Nef Polyhedra.
42 * ``igl``: `libigl&#x27;s 3D boolean support
43 <https://github.com/libigl/libigl>`_
44 * ``clipper``: `Clipper 2D boolean library
45 <http://www.angusj.com/delphi/clipper.php>`_
46 * ``carve``: `Carve solid geometry library
47 <https://code.google.com/p/carve/>`_
48
49 with_timing (``boolean``): (optional) Whether to time the code.
50 exact_mesh_file (``str``): (optional) Filename to store the XML
51 serialized exact output.
52
53 Returns: The output mesh.
54
55 The following attributes are defined in the output mesh:
56
57 * "source": An array of 0s and 1s indicating which input mesh an output
58 face comes from.
59 * "source_face": An array of indices, one per output face, into the
60 concatenated faces of the input meshes.
61 """
62 assert(mesh_1.dim == mesh_2.dim)
63 assert(mesh_1.vertex_per_face == 3)
64 assert(mesh_2.vertex_per_face == 3)
65 dim = mesh_1.dim
66
67 if engine == "auto":
68 engine = _auto_select_engine(dim)
69 elif engine == "quick_csg":
70 return boolean_unsupported.quick_csg(mesh_1, mesh_2, operation,
71 with_timing)
72
73 engine = PyMesh.BooleanEngine.create(engine)
74 engine.set_mesh_1(mesh_1.vertices, mesh_1.faces)

Calls 15

_auto_select_engineFunction · 0.85
NotImplementedErrorClass · 0.85
form_meshFunction · 0.85
set_mesh_1Method · 0.80
set_mesh_2Method · 0.80
createMethod · 0.45
compute_intersectionMethod · 0.45
compute_unionMethod · 0.45
compute_differenceMethod · 0.45
get_verticesMethod · 0.45
get_facesMethod · 0.45