Skip to content

compas_cgal.slicer ¤

Functions¤

slice_mesh_planes ¤

slice_mesh_planes(mesh: VerticesFaces, planes: list[Plane]) -> PolylinesNumpy

Slice a mesh by a list of planes.

Parameters:

Name Type Description Default
mesh VerticesFaces

The mesh to slice.

required
planes list[Plane]

The slicing planes.

required

Returns:

Type Description
PolylinesNumpy

A list of slice polylines, with each polyline an array of points.

Examples:

>>> from compas.geometry import Sphere, Plane, Polyline
>>> from compas.itertools import linspace
>>> from compas_cgal.slicer import slice_mesh
>>> sphere = Sphere(1.0, point=[0, 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]