PTEMS  0.1.0-dev+git.81fd0e4
PolyTopic Element Method Solver
ptems::Polytope< 2 > Class Reference

Specialization of the class for specifying indices of vertices for defining a DIM-dimensional polytope for DIM=2 (i.e., a polygon) More...

#include <ptems/polytope.hpp>

Public Types

typedef std::vector< std::size_t >::const_iterator iterator
 Type of iterator over the vertices. More...
 
typedef std::vector< std::size_t >::const_iterator const_iterator
 Type of iterator over the vertices. More...
 

Public Member Functions

template<typename It >
 Polytope (It begin, It end)
 Constructs a polygon from a list of vertex indices. More...
 
 Polytope (std::vector< std::size_t > &&vertices)
 Constructs a polygon from a list of vertex indices. More...
 
template<typename... INDICES, typename = std::enable_if<(std::is_integral_v<INDICES> && ...)>>
 Polytope (std::size_t index1, INDICES... indices)
 Constructs a polygon from a list of vertex indices. More...
 
 Polytope (const std::initializer_list< std::size_t > &indices)
 Constructs a polygon from a list of vertex indices. More...
 
template<typename V >
bool Validate ([[maybe_unused]] const V &vertexList) const
 Checks if the polytope defines a valid polygon: More...
 
int Compare (const Polytope &rhs) const
 Compares this polygon to the specified polygon with strict ordering. More...
 
std::set< Polytope< 1 > > Faces () const
 Gets list of faces of the polygon (edges) More...
 
std::size_t size () const
 Gets the number of vertices in the polytope. More...
 
std::size_t operator[] (std::size_t idx) const
 Gets the specified vertex of the polytope. More...
 
const_iterator begin () const
 Gets begin iterator over the list of vertices of the polytope. More...
 
const_iterator cbegin () const
 Gets begin iterator over the list of vertices of the polytope. More...
 
const_iterator end () const
 Gets end iterator over the list of vertices of the polytope. More...
 
const_iterator cend () const
 Gets begin iterator over the list of vertices of the polytope. More...
 

Detailed Description

Specialization of the class for specifying indices of vertices for defining a DIM-dimensional polytope for DIM=2 (i.e., a polygon)

Warning
For consistency all vertices should be specified in counter-clockwise order (but no validation)

Member Typedef Documentation

◆ const_iterator

Type of iterator over the vertices.

◆ iterator

Type of iterator over the vertices.

Constructor & Destructor Documentation

◆ Polytope() [1/4]

template<typename It >
ptems::Polytope< 2 >::Polytope ( It  begin,
It  end 
)
inline

Constructs a polygon from a list of vertex indices.

Template Parameters
Typeof iterator over list of vertices
Parameters
beginThe iterator to the start of the list of vertex indices
endThe iterator to the end of the list of vertex indices

◆ Polytope() [2/4]

ptems::Polytope< 2 >::Polytope ( std::vector< std::size_t > &&  vertices)
inline

Constructs a polygon from a list of vertex indices.

Parameters
verticesList of vertex indices defining the polygon

◆ Polytope() [3/4]

template<typename... INDICES, typename = std::enable_if<(std::is_integral_v<INDICES> && ...)>>
ptems::Polytope< 2 >::Polytope ( std::size_t  index1,
INDICES...  indices 
)
inline

Constructs a polygon from a list of vertex indices.

Parameters
index1First vertex index defining the polygon
indicesRest of vertex indices defining the polygon

◆ Polytope() [4/4]

ptems::Polytope< 2 >::Polytope ( const std::initializer_list< std::size_t > &  indices)
inline

Constructs a polygon from a list of vertex indices.

Parameters
indicesList of vertex indices defining the polygon

Member Function Documentation

◆ begin()

const_iterator ptems::Polytope< 2 >::begin ( ) const
inline

Gets begin iterator over the list of vertices of the polytope.

◆ cbegin()

const_iterator ptems::Polytope< 2 >::cbegin ( ) const
inline

Gets begin iterator over the list of vertices of the polytope.

◆ cend()

const_iterator ptems::Polytope< 2 >::cend ( ) const
inline

Gets begin iterator over the list of vertices of the polytope.

◆ Compare()

int ptems::Polytope< 2 >::Compare ( const Polytope< 2 > &  rhs) const
inline

Compares this polygon to the specified polygon with strict ordering.

Parameters
rhsThe right hand polygon to compare to
Returns
0 if this polygon is equal to rhs; -1 if in the ordered list of vertex indices (list of both ordered such that lowest index is first) the first "different" index is less than the rhs (or this has less vertices than rhs but all vertices are equal upto that point); 1 if this polygon is greater than rhs (opposite to -1).

◆ end()

const_iterator ptems::Polytope< 2 >::end ( ) const
inline

Gets end iterator over the list of vertices of the polytope.

◆ Faces()

std::set<Polytope<1> > ptems::Polytope< 2 >::Faces ( ) const
inline

Gets list of faces of the polygon (edges)

◆ operator[]()

std::size_t ptems::Polytope< 2 >::operator[] ( std::size_t  idx) const
inline

Gets the specified vertex of the polytope.

Exceptions
std::out_of_rangeIf idx is greater than 1
Parameters
idxIndex of vertex to get
Returns
std::size_t The index of the vertex

◆ size()

std::size_t ptems::Polytope< 2 >::size ( ) const
inline

Gets the number of vertices in the polytope.

Returns
Number of vertices

◆ Validate()

template<typename V >
bool ptems::Polytope< 2 >::Validate ( [[maybe_unused] ] const V &  vertexList) const
inline

Checks if the polytope defines a valid polygon:

  • The face is planar
  • At least two "linearly independent" edge vectors (guarantees three vertices)

This makes no guarantee about simplicity (could self-intersect)

Template Parameters
VType of vertex list - must be indexable
Parameters
vertexListList of vertices to look up the polygon vertices in
Returns
true if valid; false otherwise

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