Skip to main content

slice_mesh

Function slice_mesh 

Source
pub fn slice_mesh(
    vertices: &[[f64; 3]],
    triangles: &[[usize; 3]],
    plane_point: [f64; 3],
    normal: [f64; 3],
    tol: f64,
) -> Vec<Contour>
Expand description

Slices the triangle mesh with the plane through plane_point with normal, returning the cut as contours. tol is the distance within which vertices count as on the plane and cut endpoints count as coincident; choose it relative to the mesh size (e.g. 1e-9 * extent).

Triangles lying exactly in the plane contribute nothing (their boundary appears from the neighbouring triangles), and an edge lying in the plane is reported once even though both of its triangles cut there, so a plane through a ring of vertices gives one loop. Triangles with out-of-range indices are skipped.