GEOS  3.13.0dev
Public Member Functions | Static Public Member Functions | List of all members
geos::triangulate::polygon::PolygonEarClipper Class Reference

#include <PolygonEarClipper.h>

Public Member Functions

 PolygonEarClipper (const geom::CoordinateSequence &polyShell)
 
void setSkipFlatCorners (bool p_isFlatCornersSkipped)
 
void compute (TriList< Tri > &triList)
 
std::unique_ptr< PolygontoGeometry () const
 

Static Public Member Functions

static void triangulate (const geom::CoordinateSequence &polyShell, TriList< Tri > &triListResult)
 

Detailed Description

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.

Author
Martin Davis

Constructor & Destructor Documentation

◆ PolygonEarClipper()

geos::triangulate::polygon::PolygonEarClipper::PolygonEarClipper ( const geom::CoordinateSequence polyShell)

Creates a new ear-clipper instance.

Parameters
polyShellthe polygon vertices to process

Member Function Documentation

◆ setSkipFlatCorners()

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.

Parameters
p_isFlatCornersSkippedwhether to skip collinear vertices

◆ triangulate()

static void geos::triangulate::polygon::PolygonEarClipper::triangulate ( const geom::CoordinateSequence polyShell,
TriList< Tri > &  triListResult 
)
static

Triangulates a polygon via ear-clipping.

Parameters
polyShellthe vertices of the polygon
triListResultvector to fill in with the resultant Tri s

The documentation for this class was generated from the following file: