boolean_union

compas_cgal.booleans.boolean_union(A, B)[source]

Boolean union of two meshes.

Parameters
  • A (tuple[Sequence[[float, float, float] | Point], Sequence[[int, int, int]]]) – Mesh A.

  • B (tuple[Sequence[[float, float, float] | Point], Sequence[[int, int, int]]]) – Mesh B.

  • operation (Literal[‘union’, ‘difference’, ‘intersection’]) – The type of boolean operation.

Returns

  • NDArray[(Any, 3), np.float64] – The vertices of the boolean mesh.

  • NDArray[(Any, 3), np.int32] – The faces of the boolean mesh.

Examples

>>> from compas.geometry import Box, Sphere, Polyhedron
>>> from compas_cgal.booleans import boolean_union
>>> box = Box.from_width_height_depth(1, 1, 1)
>>> sphere = Sphere([1, 1, 1], 0.5)
>>> A = box.to_vertices_and_faces(triangulated=True)
>>> B = sphere.to_vertices_and_faces(u=32, v=32, triangulated=True)
>>> C = boolean_union(A, B)
>>> shape = Polyhedron(*C)