AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
axom::primal::Polygon< T, NDIMS > Class Template Reference

Represents a polygon defined by an array of points. More...

#include </home/docs/checkouts/readthedocs.org/user_builds/axom/checkouts/v0.5.0/src/axom/primal/geometry/Polygon.hpp>

Public Types

typedef Point< T, NDIMS > PointType
 
typedef Vector< T, NDIMS > VectorType
 
typedef NumericArray< T, NDIMS > NumArrayType
 

Public Member Functions

 Polygon ()
 
 Polygon (int numExpectedVerts)
 Constructor for an empty polygon that reserves space for the given number of vertices. More...
 
int numVertices () const
 
void addVertex (const PointType &pt)
 
void clear ()
 
PointTypeoperator[] (int idx)
 
const PointTypeoperator[] (int idx) const
 
PointType centroid () const
 Computes the centroid as the average of the polygon's vertex positions. More...
 
std::ostream & print (std::ostream &os) const
 Simple formatted print of a polygon instance. More...
 
bool isValid () const
 Simple check for validity of a polygon. More...
 

Detailed Description

template<typename T, int NDIMS>
class axom::primal::Polygon< T, NDIMS >

Represents a polygon defined by an array of points.

Template Parameters
Tthe coordinate type, e.g., double, float, etc.
NDIMSthe number of dimensions
Note
The polygon vertices should be ordered in a counter clockwise orientation with respect to the polygon's desired normal vector

Member Typedef Documentation

◆ PointType

template<typename T, int NDIMS>
typedef Point<T, NDIMS> axom::primal::Polygon< T, NDIMS >::PointType

◆ VectorType

template<typename T, int NDIMS>
typedef Vector<T, NDIMS> axom::primal::Polygon< T, NDIMS >::VectorType

◆ NumArrayType

template<typename T, int NDIMS>
typedef NumericArray<T, NDIMS> axom::primal::Polygon< T, NDIMS >::NumArrayType

Constructor & Destructor Documentation

◆ Polygon() [1/2]

template<typename T, int NDIMS>
axom::primal::Polygon< T, NDIMS >::Polygon ( )
inline

Default constructor for an empty polygon

◆ Polygon() [2/2]

template<typename T, int NDIMS>
axom::primal::Polygon< T, NDIMS >::Polygon ( int  numExpectedVerts)
inline

Constructor for an empty polygon that reserves space for the given number of vertices.

Parameters
[in]numExpectedVertsnumber of vertices for which to reserve space
Precondition
numExpectedVerts is not negative

References SLIC_ASSERT.

Member Function Documentation

◆ numVertices()

template<typename T, int NDIMS>
int axom::primal::Polygon< T, NDIMS >::numVertices ( ) const
inline

◆ addVertex()

template<typename T, int NDIMS>
void axom::primal::Polygon< T, NDIMS >::addVertex ( const PointType pt)
inline

Appends a vertex to the list of vertices

Referenced by axom::primal::clip().

◆ clear()

template<typename T, int NDIMS>
void axom::primal::Polygon< T, NDIMS >::clear ( )
inline

Clears the list of vertices

◆ operator[]() [1/2]

template<typename T, int NDIMS>
PointType& axom::primal::Polygon< T, NDIMS >::operator[] ( int  idx)
inline

Retrieves the vertex at index idx

◆ operator[]() [2/2]

template<typename T, int NDIMS>
const PointType& axom::primal::Polygon< T, NDIMS >::operator[] ( int  idx) const
inline

Retrieves the vertex at index idx

◆ centroid()

template<typename T, int NDIMS>
PointType axom::primal::Polygon< T, NDIMS >::centroid ( ) const
inline

Computes the centroid as the average of the polygon's vertex positions.

Returns
The centroid of the polygon's vertices
Precondition
polygon.isValid() is true

References axom::primal::Polygon< T, NDIMS >::isValid(), axom::primal::Polygon< T, NDIMS >::numVertices(), and SLIC_ASSERT.

Referenced by axom::quest::InOutOctree< DIM >::generateIndex().

◆ print()

template<typename T, int NDIMS>
std::ostream& axom::primal::Polygon< T, NDIMS >::print ( std::ostream &  os) const
inline

Simple formatted print of a polygon instance.

Parameters
osThe output stream to write to
Returns
A reference to the modified ostream

References axom::primal::Polygon< T, NDIMS >::numVertices().

◆ isValid()

template<typename T, int NDIMS>
bool axom::primal::Polygon< T, NDIMS >::isValid ( ) const
inline

Simple check for validity of a polygon.

Initial check is that the polygon has three or more vertices

Returns
True, if the polygon is valid, False otherwise

Referenced by axom::primal::Polygon< T, NDIMS >::centroid().


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