Skip to main content

repair_triangle_soup

Function repair_triangle_soup 

Source
pub fn repair_triangle_soup(
    positions: &[f64],
    indices: Option<&[u32]>,
    weld_tolerance: f64,
) -> Result<(Vec<f64>, Vec<u32>, MeshRepairReport), String>
Expand description

The mesh half of mesh_to_faceted_brep: weld, drop degenerate and duplicate triangles, prune surplus sheets at non-manifold edges, and cap the remaining boundary cycles with a fan — returning the repaired triangle soup instead of a BREP.

This is what lets a defective mesh still reach the ANALYTIC import lanes. They all require a closed two-manifold, and the defect that costs a part every recognized cylinder is usually a handful of triangles far away from any of them; running them on this output instead of on the raw file keeps the surfaces a repairable mesh can still support. Pass weld_tolerance <= 0 to derive it from the bounding-box diagonal. The result is not guaranteed closed — an input too broken to close comes back as whatever the repair could reach, and the caller must re-test it.