Skip to main content

fill

Function fill 

Source
pub fn fill(contours: &[(&[[f64; 2]], bool)], out: &mut Fill) -> Result<bool>
Expand description

Fills the closed contours contours (each with whether it is oriented) and writes the triangles to out, replacing what it held.

Contours are nested into outers and holes:

  • When every contour is oriented, counter-clockwise contours are outers, and each clockwise contour is a hole of the smallest outer containing it. A clockwise contour inside no outer is not filled. When the summed signed area is negative (a closed mesh wound inward), the orientation is taken as reversed throughout: clockwise contours are the outers.
  • When any contour is unoriented, winding is ignored: a contour inside an even number of others is an outer, and one inside an odd number is a hole of the smallest such outer containing it.

Containment tests one point of the inner contour with the even-odd ray rule. Contours with zero area are not filled. Each outer and its holes are triangulated by triangulate; out.points holds their points, each outer followed by its holes.

Returns whether the fill is good (fill_ok): false when triangulation could not finish, or when the fill’s signed area differs from the contours’ summed area (signed when oriented, with the sign flipped when reversed; by nesting depth otherwise) by more than 1e-6 · max(1, Σ |area|). This is best effort: there is no separate self-intersection test, so a bad fill can go unreported.

§Errors