Function refine

Source
pub fn refine(
    mesh: &TriMesh,
    target: RefineTarget,
    surface: Option<&Surface>,
    tolerance: Tolerance,
) -> Result<(TriMesh, RefineReport), RefineError>
Expand description

Refine a mesh, optionally snapping new vertices onto a known surface.

Passing Some(surface) is what turns subdivision into approximation improvement. Passing None subdivides linearly and says so in the report rather than implying an accuracy gain it did not deliver.

Deterministic: new vertices are numbered in the order edges are first split during the triangle walk, which is fixed by the index buffer. The midpoint cache is keyed by the ordered vertex pair and is only ever queried by key, never iterated, so its internal ordering cannot reach the output. The same input produces the same output vertex ordering on every run and across processes.

ยงErrors

Refuses a ragged index buffer, out-of-range indices, a non-positive edge-length target, and a request that would exceed the triangle budget.