sanitize_contours

Function sanitize_contours 

Source
pub fn sanitize_contours(rings: &[Ring2D]) -> Vec<Vec<[f64; 2]>>
Expand description

Drop rings that cannot contribute, so no input can panic or hang the overlay: fewer than 3 vertices, ANY non-finite coordinate (a NaN makes i_overlay’s segment ordering meaningless, so the whole ring goes rather than the offending point — dropping single points would silently deform the boundary instead), or all vertices collinear (a ring with no interior). A trailing vertex equal to the first is stripped, so a caller that closes its rings explicitly does not feed in a zero-length edge. Note this drops only provably-collinear rings, NOT by area: a zero-signed-area bow-tie still carries coverage under NonZero and is left for i_overlay.

Re-exported (as sanitize_contours) so the WASM Contours2D constructor can hold the same invariant its accessors document, rather than exposing a raw ring soup that a later boolean would silently disagree with: after this, a set’s rings are exactly the ones a boolean would keep, so is_empty/ bounds cannot report a collinear or degenerate ring that covers nothing.