Skip to main content

triangulate

Function triangulate 

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

Triangulate rings into a flat index buffer over a single vertex list.

The returned vertices are the concatenation outer ++ holes, unchanged, and every one of them is a corner of some triangle. Rings may be given either way round; the triangles are counter-clockwise. The result is certified before it is returned (#253): every ring edge is a triangle edge, every other edge is shared by exactly two triangles, so no triangle edge runs past a vertex and an extrusion of the caps closes.

ยงErrors

InvalidInput, naming the ring, for rings that do not bound a polygon with holes: fewer than three or non-finite vertices, a repeated vertex, a ring that folds back on or crosses itself or runs along a seam both ways (a keyhole, #270), holes that overlap or touch each other or the outer ring, a hole outside the outer ring or inside another hole. Degenerate if the triangulation cannot be certified.

Touching rings are refused because this is the cap of a solid (PinchPolicy::Refuse); a 2D region or a planar surface patch uses triangulate_with and PinchPolicy::Accept.