slice_mesh

compas_cgal.slicer.slice_mesh(mesh, planes)[source]

Slice a mesh by a list of planes.

Parameters
  • mesh (tuple[Sequence[[float, float, float] | Point], Sequence[[int, int, int]]]) – The mesh to slice.

  • planes (list[[point, normal] | Plane]) – The slicing planes.

Returns

list[NDArray[(Any, 3), np.float64]] – A list of slice polylines, with each polyline an array of points.

Examples

>>> from compas.geometry import Sphere, Plane, Polylines
>>> from compas.utilities import linspace
>>> from compas_cgal.slicer import slice_mesh
>>> sphere = Sphere([0, 0, 1.0], 1.0)
>>> mesh = sphere.to_vertices_and_faces(u=32, v=32, triangulated=True)
>>> planes = [Plane([0, 0, z], [0, 0, 1.0]) for z in linspace(0.1, 1.9, 19)]
>>> result = slice_mesh(mesh, planes)
>>> polylines = [Polyline(points) for points in result]