Skip to main content

cut_by_mesh_region

Function cut_by_mesh_region 

Source
pub fn cut_by_mesh_region(
    model: &mut Model,
    shape: &Shape,
    mesh: &Triangulation,
    region: &[bool],
    offset: f64,
    keep: Side,
    tol: Tolerances,
) -> OgeomResult<Built>
Expand description

Cut shape by the break surface region marks on mesh, thickened by offset to each side, and keep the pieces on the keep side.

region holds one flag per triangle of mesh; the flagged triangles are the break. They must be wound alike (each edge two of them share run opposite ways in them) and face, as their corners wind counter-clockwise, one way: seen along their average normal none may face away or overlap another. Side::Above keeps the side the break’s faces face, Side::Below the other.

The break is extended past its rims along its average plane until it is clear of the shape’s box, its holes are closed, and the sheet is thickened by offset to each side into a slab 2 * offset thick, which is cut from the shape: the face the kept pieces take along the break stands offset off it, on the kept side. The slab’s faces are the thickened mesh’s, merged where coplanar and recognized where they lie on a cylinder, cone, sphere or torus. The shape’s faces keep their surfaces, those the break does not reach whole. The result is the kept solid, or a compound of the kept solids where the break leaves several on that side. Its history is the cut’s, with the pieces on the other side deleted.

§Errors

OgeomError::Dimension if region does not hold one flag per triangle. OgeomError::Construction if offset is not a positive distance, shape holds no solid, the region is empty, a triangle of it names a vertex twice or one that is not there, two of its triangles run along an edge the same way, its triangles’ areas cancel so it has no average normal, a triangle faces away from that normal, its rims cross or touch seen along it, or the region does not separate the shape (no piece lies on one side of it, the side kept included); and as thicken, solid_from_mesh and cut fail. OgeomError::NotDone if the thickened sheet does not build into one closed solid.