@@ -41,6 +41,8 @@ def _boolean(A, B, operation):
4141 result = booleans .boolean_difference (VA , FA , VB , FB )
4242 elif operation == 'intersection' :
4343 result = booleans .boolean_intersection (VA , FA , VB , FB )
44+ elif operation == 'split' :
45+ result = booleans .split (VA , FA , VB , FB )
4446 else :
4547 raise NotImplementedError
4648
@@ -159,3 +161,41 @@ def boolean_intersection(A, B):
159161
160162 """
161163 return _boolean (A , B , 'intersection' )
164+
165+
166+ @plugin (category = 'booleans' , pluggable_name = 'split_mesh_mesh' )
167+ def split (A , B ):
168+ """Split one mesh with another.
169+
170+ Parameters
171+ ----------
172+ A : tuple[Sequence[[float, float, float] | :class:`~compas.geometry.Point`], Sequence[[int, int, int]]]
173+ Mesh A.
174+ B : tuple[Sequence[[float, float, float] | :class:`~compas.geometry.Point`], Sequence[[int, int, int]]]
175+ Mesh B.
176+ operation : Literal['union', 'difference', 'intersection']
177+ The type of boolean operation.
178+
179+ Returns
180+ -------
181+ NDArray[(Any, 3), np.float64]
182+ The vertices of the boolean mesh.
183+ NDArray[(Any, 3), np.int32]
184+ The faces of the boolean mesh.
185+
186+ Examples
187+ --------
188+ >>> from compas.geometry import Box, Sphere, Polyhedron
189+ >>> from compas_cgal.booleans import split
190+
191+ >>> box = Box.from_width_height_depth(1, 1, 1)
192+ >>> sphere = Sphere([1, 1, 1], 0.5)
193+
194+ >>> A = box.to_vertices_and_faces(triangulated=True)
195+ >>> B = sphere.to_vertices_and_faces(u=32, v=32, triangulated=True)
196+
197+ >>> V, F = split(A, B)
198+ >>> mesh = Mesh.from_vertices_and_faces(V, F)
199+
200+ """
201+ return _boolean (A , B , 'split' )
0 commit comments