Skip to main content

decimate

Function decimate 

Source
pub fn decimate(
    vertices: &[[f64; 3]],
    triangles: &[[usize; 3]],
    target_triangles: usize,
) -> (Vec<[f64; 3]>, Vec<[usize; 3]>)
Expand description

Simplifies a triangle mesh to about target_triangles triangles by quadric error metric edge collapse (Garland and Heckbert): each vertex accumulates the area-weighted squared distances to the planes of its original triangles, and the edge whose collapse to the quadric-optimal point adds the least error is collapsed first. Collapses that would flip a triangle, break the manifold link condition are skipped; boundary vertices never move (interior vertices may collapse onto them, but boundary edges are never collapsed), so open boundaries are preserved exactly. Returns the compacted vertices and triangles.