GEOS 3.11.1
|
#include <PolygonEarClipper.h>
Public Member Functions | |
PolygonEarClipper (std::vector< Coordinate > &polyShell) | |
void | setSkipFlatCorners (bool p_isFlatCornersSkipped) |
void | compute (TriList< Tri > &triList) |
std::unique_ptr< Polygon > | toGeometry () const |
Static Public Member Functions | |
static void | triangulate (std::vector< Coordinate > &polyShell, TriList< Tri > &triListResult) |
Triangulates a polygon using the Ear-Clipping technique. The polygon is provided as a closed list of contiguous vertices defining its boundary. The vertices must have clockwise orientation.
The polygon boundary must not self-cross, but may self-touch at points or along an edge. It may contain repeated points, which are treated as a single vertex. By default every vertex is triangulated, including ones which are "flat" (the adjacent segments are collinear). These can be removed by setting setSkipFlatCorners(boolean)
The polygon representation does not allow holes. Polygons with holes can be triangulated by preparing them with PolygonHoleJoiner
.
geos::triangulate::polygon::PolygonEarClipper::PolygonEarClipper | ( | std::vector< Coordinate > & | polyShell | ) |
Creates a new ear-clipper instance.
polyShell | the polygon vertices to process |
void geos::triangulate::polygon::PolygonEarClipper::setSkipFlatCorners | ( | bool | p_isFlatCornersSkipped | ) |
Sets whether flat corners formed by collinear adjacent line segments are included in the triangulation. Skipping flat corners reduces the number of triangles in the output. However, it produces a triangulation which does not include all input vertices. This may be undesirable for downstream processes (such as computing a Constrained Delaunay Triangulation for purposes of computing the medial axis).
The default is to include all vertices in the result triangulation. This still produces a valid triangulation, with no zero-area triangles.
Note that repeated vertices are always skipped.
p_isFlatCornersSkipped | whether to skip collinear vertices |
|
static |
Triangulates a polygon via ear-clipping.
polyShell | the vertices of the polygon |
triListResult | vector to fill in with the resultant Tri s |