Parasol Planning Library (PPL)
Public Member Functions
GMSPolygon Class Reference

#include <GMSPolygon.h>

Public Types

Local Types
typedef std::vector< Point3d > PointList
 
typedef std::vector< int > IndexList
 
typedef IndexList::const_iterator const_iterator
 

Public Member Functions

const int & operator[] (const size_t _i) const noexcept
 
size_t GetNumVertices () const noexcept
 Get the number of vertices in the polygon. More...
 
const Point3d & GetPoint (const size_t _i) const noexcept
 
Vector3d & GetNormal () noexcept
 Get the polygon's normal. More...
 
const Vector3d & GetNormal () const noexcept
 
double GetArea () const noexcept
 Get the polygon's area. More...
 
Construction
 GMSPolygon ()
 
 GMSPolygon (const int _v1, const int _v2, const int _v3, const PointList &_pts)
 
 GMSPolygon (const_iterator _begin, const_iterator _end, const PointList &_pts)
 
Iterators

Iterate over the vertex indices in this polygon.

const_iterator begin () const noexcept
 
const_iterator end () const noexcept
 
Modifiers
void Reverse ()
 Reverse the facing of this polygon. More...
 
void ComputeNormal ()
 Compute the normal and area for this polygon. More...
 
Equality
bool operator== (const GMSPolygon &_p) const noexcept
 
bool operator!= (const GMSPolygon &_p) const noexcept
 
Ordering

Define an ordering of polygons based on surface area.

bool operator< (const GMSPolygon &_other) const noexcept
 
bool operator> (const GMSPolygon &_other) const noexcept
 
Queries
const bool IsTriangle () const noexcept
 Test for three unique vertex indexes. More...
 
const Point3d FindCenter () const noexcept
 Find the centroid of this polygon. More...
 
const bool PointIsAbove (const Point3d &_p) const noexcept
 
const int CommonVertex (const GMSPolygon &_p) const noexcept
 
const std::pair< int, int > CommonEdge (const GMSPolygon &_p) const noexcept
 

Detailed Description

Geometric structure for polygons, including vertex indexes, normal, and area. The vertex indexes refer to an external vertex list, which is required for accessing the points through this object.

Since we require triangulated models, this usually represents a triangle.

Member Typedef Documentation

◆ const_iterator

typedef IndexList::const_iterator GMSPolygon::const_iterator

◆ IndexList

typedef std::vector<int> GMSPolygon::IndexList

◆ PointList

typedef std::vector<Point3d> GMSPolygon::PointList

Constructor & Destructor Documentation

◆ GMSPolygon() [1/3]

GMSPolygon::GMSPolygon ( )
default

Default construction is provided for compatibility with STL containers only. It should not be called otherwise.

◆ GMSPolygon() [2/3]

GMSPolygon::GMSPolygon ( const int  _v1,
const int  _v2,
const int  _v3,
const PointList _pts 
)

Construct a polygon (triangle) from three vertex indexes.

Parameters
_v1The first vertex index.
_v2The second vertex index.
_v3The third vertex index.
_ptsThe vector holding the vertex data.

◆ GMSPolygon() [3/3]

GMSPolygon::GMSPolygon ( const_iterator  _begin,
const_iterator  _end,
const PointList _pts 
)

Construct a polygon from a range of vertex indexes.

Parameters
_beginAn iterator to the front of the range (first index).
_endAn iterator to one-past-the-last of the range.
_ptsThe vector holding the vertex data.

Member Function Documentation

◆ begin()

GMSPolygon::const_iterator GMSPolygon::begin ( ) const
noexcept

◆ CommonEdge()

const std::pair< int, int > GMSPolygon::CommonEdge ( const GMSPolygon _p) const
noexcept

Find the common edge between two polygons.

Parameters
_pThe other polygon under consideration.
Returns
A pair of vertex indexes if a common edge exists. If not, at least one of the indexes will be -1.

◆ CommonVertex()

const int GMSPolygon::CommonVertex ( const GMSPolygon _p) const
noexcept

Find a common vertex between two polygons.

Parameters
_pThe other polygon under consideration.
Returns
A common vertex index, or -1 if none exists.

◆ ComputeNormal()

void GMSPolygon::ComputeNormal ( )

Compute the normal and area for this polygon.

◆ end()

GMSPolygon::const_iterator GMSPolygon::end ( ) const
noexcept

◆ FindCenter()

const Point3d GMSPolygon::FindCenter ( ) const
noexcept

Find the centroid of this polygon.

◆ GetArea()

double GMSPolygon::GetArea ( ) const
noexcept

Get the polygon's area.

◆ GetNormal() [1/2]

const Vector3d & GMSPolygon::GetNormal ( ) const
noexcept

◆ GetNormal() [2/2]

Vector3d & GMSPolygon::GetNormal ( )
noexcept

Get the polygon's normal.

◆ GetNumVertices()

size_t GMSPolygon::GetNumVertices ( ) const
noexcept

Get the number of vertices in the polygon.

◆ GetPoint()

const Point3d & GMSPolygon::GetPoint ( const size_t  _i) const
noexcept

Get the vertex referenced by the _i'th index in the vertex list.

Parameters
_iThe vertex index in range [0 : n - 1].
Returns
The vertex which is the _i'th point in this polygon.

◆ IsTriangle()

const bool GMSPolygon::IsTriangle ( ) const
noexcept

Test for three unique vertex indexes.

◆ operator!=()

bool GMSPolygon::operator!= ( const GMSPolygon _p) const
noexcept

◆ operator<()

bool GMSPolygon::operator< ( const GMSPolygon _other) const
noexcept

◆ operator==()

bool GMSPolygon::operator== ( const GMSPolygon _p) const
noexcept

◆ operator>()

bool GMSPolygon::operator> ( const GMSPolygon _other) const
noexcept

◆ operator[]()

const int & GMSPolygon::operator[] ( const size_t  _i) const
noexcept

Access a vertex index in the polygon.

Parameters
_iThe vertex index in range [0 : n - 1].
Returns
The _i'th vertex index in this polygon.

◆ PointIsAbove()

const bool GMSPolygon::PointIsAbove ( const Point3d &  _p) const
noexcept

Test whether a point lies above or below the polygon plane. A point is considered above the plane when it is on the side where the normal faces outward.

Parameters
_pThe point to check.

◆ Reverse()

void GMSPolygon::Reverse ( )

Reverse the facing of this polygon.


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