Thea
Classes | Public Member Functions | List of all members
Polygon2 Class Reference

A polygon in 2-space. More...

#include <Polygon2.hpp>

Classes

struct  IndexedVertex
 A vertex plus an index. More...
 
struct  TriangulationOptions
 Options controlling interior triangulation. More...
 

Public Member Functions

void addVertex (Vector2 const &p)
 Add a vertex to the polygon. More...
 
void addVertex (Vector2 const &p, intx index)
 Add an indexed vertex to the polygon. More...
 
void clear ()
 Delete all vertices from the polygon. More...
 
Real computeArea () const
 Compute the area of the polygon. More...
 
IndexedVertex getVertex (intx poly_index) const
 Get the vertex at position poly_index in the sequence of vertices around the polygon boundary. More...
 
intx numVertices () const
 Get the number of vertices in the polygon. More...
 
 Polygon2 ()
 Construct an empty polygon. More...
 
intx triangulate (Array< intx > &tri_indices) const
 Triangulate the polygon and return the set of triangle indices (in successive groups of 3). More...
 
intx triangulateInterior (Array< Vector2 > &tri_verts, Array< intx > &tri_indices, Array< bool > *tri_vert_is_boundary=nullptr, TriangulationOptions const &options=TriangulationOptions::defaults()) const
 Triangulate the polygon, inserting Steiner vertices as necessary in the interior of the polygon for a well-conditioned result. More...
 
 ~Polygon2 ()
 Destructor. More...
 

Detailed Description

A polygon in 2-space.

Definition at line 26 of file Polygon2.hpp.

Constructor & Destructor Documentation

Polygon2 ( )

Construct an empty polygon.

Definition at line 35 of file Polygon2.cpp.

~Polygon2 ( )

Destructor.

Definition at line 39 of file Polygon2.cpp.

Member Function Documentation

void addVertex ( Vector2 const &  p)

Add a vertex to the polygon.

The vertex is inserted at the end of the current sequence of vertices, and by default is assigned an index that is one more than the maximum index in the polygon so far (or zero if this is the first vertex).

Definition at line 45 of file Polygon2.cpp.

void addVertex ( Vector2 const &  p,
intx  index 
)

Add an indexed vertex to the polygon.

The vertex is inserted at the end of the current sequence of vertices.

Definition at line 51 of file Polygon2.cpp.

void clear ( )

Delete all vertices from the polygon.

Definition at line 70 of file Polygon2.cpp.

Real computeArea ( ) const

Compute the area of the polygon.

Definition at line 194 of file Polygon2.cpp.

Polygon2::IndexedVertex getVertex ( intx  poly_index) const

Get the vertex at position poly_index in the sequence of vertices around the polygon boundary.

Note
poly_index is determined by the sequence of addVertex() calls, NOT by the index supplied in addVertex(Vector2 const &, intx)!

Definition at line 63 of file Polygon2.cpp.

intx numVertices ( ) const

Get the number of vertices in the polygon.

Definition at line 57 of file Polygon2.cpp.

intx triangulate ( Array< intx > &  tri_indices) const

Triangulate the polygon and return the set of triangle indices (in successive groups of 3).

All prior data in the supplied array are cleared.

Returns
The number of triangles created.

Definition at line 76 of file Polygon2.cpp.

intx triangulateInterior ( Array< Vector2 > &  tri_verts,
Array< intx > &  tri_indices,
Array< bool > *  tri_vert_is_boundary = nullptr,
TriangulationOptions const &  options = TriangulationOptions::defaults() 
) const

Triangulate the polygon, inserting Steiner vertices as necessary in the interior of the polygon for a well-conditioned result.

All prior data in the supplied arrays are cleared.

Parameters
tri_vertsUsed to return the vertices of the output triangulation.
tri_indicesUsed to return the vertex indices of output triangles (w.r.t. tri_verts), in successive groups of 3.
tri_vert_is_boundaryIf not-null, used to return a flag for each output vertex indicating whether it's on the boundary of the triangulated domain or not.
optionsOptions controlling the quality of the triangulation.
Returns
The number of triangles created.

Definition at line 82 of file Polygon2.cpp.


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