Skip to main content

mesh_to_faceted_brep

Function mesh_to_faceted_brep 

Source
pub fn mesh_to_faceted_brep(
    positions: &[f64],
    indices: Option<&[u32]>,
    tolerance: f64,
) -> Result<BrepSolid, String>
Expand description

Build a faceted (planar-triangle) BREP solid from a triangle soup or an indexed triangle mesh — the STL/mesh import entry (§8.6 inverse: mesh → body). Vertices weld within tolerance (pass <= 0 to derive it from the bounding-box diagonal), duplicate and degenerate triangles are dropped, surplus sheets at non-manifold edges are pruned, and remaining boundary cycles are capped with a fan so the result closes watertight whenever the input is close to a manifold. Validation is authoritative: an input too broken to close returns an error, never a silently-invalid solid.