AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
|
Represents a polygon defined by an array of points. More...
#include </home/docs/checkouts/readthedocs.org/user_builds/axom/checkouts/main/src/axom/primal/geometry/Polygon.hpp>
Public Types | |
using | PointType = Point< T, NDIMS > |
using | VectorType = Vector< T, NDIMS > |
Public Member Functions | |
Polygon () | |
Default constructor for an empty polygon. More... | |
Polygon (int numExpectedVerts) | |
Constructor for an empty polygon that reserves space for the given number of vertices. More... | |
Polygon (const axom::Array< PointType > &vertices) | |
Constructor for a polygon with the given vertices. More... | |
int | numVertices () const |
Return the number of vertices in the polygon. More... | |
void | addVertex (const PointType &pt) |
Appends a vertex to the list of vertices. More... | |
void | clear () |
Clears the list of vertices. More... | |
PointType & | operator[] (int idx) |
Retrieves the vertex at index idx. More... | |
const PointType & | operator[] (int idx) const |
Retrieves the vertex at index idx. More... | |
template<int TDIM = NDIMS> | |
std::enable_if< TDIM==3, VectorType >::type | normal () const |
Robustly returns the normal of the polygon (not normalized) More... | |
PointType | vertexMean () const |
Computes the average of the polygon's vertex positions. More... | |
template<int TDIM = NDIMS> | |
std::enable_if< TDIM==3, double >::type | area () const |
Returns the area of the polygon (3D specialization) More... | |
template<int TDIM = NDIMS> | |
std::enable_if< TDIM==2, double >::type | area () const |
Returns the area of a planar polygon (2D specialization) More... | |
template<int TDIM = NDIMS> | |
std::enable_if< TDIM==2, double >::type | signedArea () const |
Returns the signed area of a 2D polygon. 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... | |
Represents a polygon defined by an array of points.
T | the coordinate type, e.g., double, float, etc. |
NDIMS | the number of dimensions |
using axom::primal::Polygon< T, NDIMS >::PointType = Point<T, NDIMS> |
using axom::primal::Polygon< T, NDIMS >::VectorType = Vector<T, NDIMS> |
|
inline |
Default constructor for an empty polygon.
|
inlineexplicit |
Constructor for an empty polygon that reserves space for the given number of vertices.
[in] | numExpectedVerts | number of vertices for which to reserve space |
References axom::Array< T, DIM, SPACE >::reserve(), and SLIC_ASSERT.
|
inline |
Constructor for a polygon with the given vertices.
|
inline |
Return the number of vertices in the polygon.
References axom::Array< T, DIM, SPACE >::size().
|
inline |
Appends a vertex to the list of vertices.
References axom::Array< T, DIM, SPACE >::push_back().
|
inline |
Clears the list of vertices.
References axom::Array< T, DIM, SPACE >::clear().
|
inline |
Retrieves the vertex at index idx.
|
inline |
Retrieves the vertex at index idx.
|
inline |
Robustly returns the normal of the polygon (not normalized)
References axom::primal::Vector< T, NDIMS >::cross_product(), axom::primal::Polygon< T, NDIMS >::isValid(), axom::primal::Polygon< T, NDIMS >::numVertices(), and SLIC_ASSERT.
|
inline |
Computes the average of the polygon's vertex positions.
References axom::primal::Point< T, NDIMS >::array(), axom::primal::Polygon< T, NDIMS >::isValid(), axom::primal::Polygon< T, NDIMS >::numVertices(), and SLIC_ASSERT.
|
inline |
Returns the area of the polygon (3D specialization)
The algorithm sums up contributions from triangles defined by each edge of the polygon and a local origin (at the Polygon's vertexMean()). The algorithm assumes a planar polygon embedded in 3D, however it will return a value for non-planar polygons.
The area is always non-negative since 3D polygons do not have a unique orientation.
References axom::utilities::abs(), axom::primal::Vector< T, NDIMS >::cross_product(), axom::primal::Vector< T, NDIMS >::norm(), axom::primal::Polygon< T, NDIMS >::numVertices(), and axom::primal::Polygon< T, NDIMS >::vertexMean().
|
inline |
Returns the area of a planar polygon (2D specialization)
The area is always non-negative.
References axom::utilities::abs(), and axom::primal::Polygon< T, NDIMS >::signedArea().
|
inline |
Returns the signed area of a 2D polygon.
The signed area accounts for the orientation of the polygon. It is positive when the vertices are oriented counter-clockwise and negative when the vertices are oriented clockwise.
References axom::primal::Polygon< T, NDIMS >::numVertices().
|
inline |
Simple formatted print of a polygon instance.
os | The output stream to write to |
References axom::primal::Polygon< T, NDIMS >::numVertices().
|
inline |
Simple check for validity of a polygon.
Initial check is that the polygon has three or more vertices
References axom::Array< T, DIM, SPACE >::size().