Skip to main content

cut_by_plane

Function cut_by_plane 

Source
pub fn cut_by_plane(
    tx: &mut Transaction<'_>,
    plane: &Plane,
    options: &CutOptions,
) -> Result<CutOutput>
Expand description

Splits the mesh of tx with plane: the + side stays, the - side is returned as a mesh with the same origin. Triangles crossing the plane are split along it; with options.cap both openings are closed with flat, unfaired fill_holes patches over the cut rim.

A rim is capped when it closes: by vertex index, or, on a mesh with UVs, by exact position across seams (see the module docs for the cap’s UVs). One that runs into a real boundary of an open mesh stays open. On a mesh without UVs split vertices are such a boundary: weld them first.

§Errors

  • OpsError::InvalidInput when the plane does not cut the mesh (every triangle on one side), when a cut point leaves f32 range, or, with cap, when a rim cannot be capped: see the module docs.
  • OpsError::StaleLoops when a rim loop vanished between listing and filling (defensive: both come from the same mesh state).
  • OpsError::Store when memory runs out. Nothing is written then: the plan is read from the untouched mesh before the first write.