Skip to main content

triangulate_with

Function triangulate_with 

Source
pub fn triangulate_with(
    rings: &Rings,
    pinches: PinchPolicy,
) -> GeomResult<(Vec<Point2>, Vec<[u32; 3]>)>
Expand description

triangulate under an explicit PinchPolicy.

Under PinchPolicy::Refuse this is triangulate. Under PinchPolicy::Accept rings may also touch at single points: where two edges meet at a point that is a vertex of at least one of them. The region is then the points inside the outer ring and outside every hole (for a ring pinched into loops, inside an odd number of its loops), split into its connected parts at the pinches; each part is triangulated and the whole is certified as triangulate is, with each visit of a pinch point counted as its own vertex. A point several vertices share is referenced by its first index in outer ++ holes, and a vertex on another ring’s edge splits that edge, so the ring edges of the result are the rings’ edges cut at every touching vertex. Rings touching nowhere triangulate exactly as under PinchPolicy::Refuse.

Under PinchPolicy::Accept a ring may also join a hole by a seam (#270): an edge and a later edge of the same ring between the same two points in opposite directions, which no other edge has, and which no other edge meets except at its ends – a keyhole, the outer boundary, the seam, the hole and the seam back. The two copies cancel: the ring bounds what its other edges bound, and is split at its seams into the loops they join, triangulated as above (a hole loop drawn either way round is a hole; a seam between two loops side by side leaves two parts). A seam may be a triangle edge, once each way, or none at all; a planar face of a closed shell uses triangulate_shell_face, which never makes it one (#283).

§Errors

As triangulate, except that touching at single points and seams are accepted under PinchPolicy::Accept. Rings that cross, at a shared vertex included, or overlap along an edge are refused by name under both, and so are, under PinchPolicy::Accept, an edge running back along only part of another, the same edge in one direction twice or more than twice in all, seams interleaving along their ring instead of nesting, seams in a row, an edge crossing, touching or running along a seam away from its ends, and a loop folding back where a seam left it. PinchPolicy::Refuse refuses any seam by name.