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

Represents a polyhedron defined by an array of points and optionally their neighbors (a point is a neighbor of another point if there is an edge between them) More...

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

Public Types

using PointType = Point< T, NDIMS >
 
using VectorType = Vector< T, NDIMS >
 
using NumArrayType = NumericArray< T, NDIMS >
 

Public Member Functions

AXOM_HOST_DEVICE Polyhedron ()
 
AXOM_HOST_DEVICE int numVertices () const
 
AXOM_HOST_DEVICE int addVertex (const PointType &pt)
 Appends a vertex to the list of vertices. More...
 
AXOM_HOST_DEVICE void addNeighbors (const PointType &pt, std::initializer_list< axom::int8 > nbrs)
 Stores nbrs as the neighbors of vertex pt. If vertex pt is not in the polyhedron, neighbors are not added. More...
 
AXOM_HOST_DEVICE void addNeighbors (int vtxId, std::initializer_list< axom::int8 > nbrs)
 Stores nbrs as the neighbors of vertex at a given index. More...
 
AXOM_HOST_DEVICE void addNeighbors (int vtxId, int nbr)
 Adds a single nbr as the neighbor of vertex at a given index. More...
 
AXOM_HOST_DEVICE void clear ()
 
CoordsgetVertices ()
 
AXOM_HOST_DEVICE PointTypeoperator[] (int idx)
 
AXOM_HOST_DEVICE const PointTypeoperator[] (int idx) const
 
AXOM_HOST_DEVICE NeighborsgetNeighbors ()
 
AXOM_HOST_DEVICE int getNumNeighbors (int i) const
 
AXOM_HOST_DEVICE Neighbors::VertexNbrsgetNeighbors (int i)
 
AXOM_HOST_DEVICE const Neighbors::VertexNbrsgetNeighbors (int i) const
 
AXOM_HOST_DEVICE PointType centroid () const
 Computes the centroid as the average of the polyhedron's vertex positions. More...
 
AXOM_HOST_DEVICE double volume () const
 Finds the volume of the polyhedron. More...
 
std::ostream & print (std::ostream &os) const
 Simple formatted print of a polyhedron instance. More...
 
AXOM_HOST_DEVICE bool isValid () const
 Simple check for validity of a polyhedron. More...
 
AXOM_HOST_DEVICE bool hasNeighbors () const
 Check if vertex neighbors information is available. More...
 

Static Public Attributes

static constexpr int MAX_VERTS = NeighborCollection::MAX_VERTS
 

Detailed Description

template<typename T, int NDIMS = 3>
class axom::primal::Polyhedron< T, NDIMS >

Represents a polyhedron defined by an array of points and optionally their neighbors (a point is a neighbor of another point if there is an edge between them)

Template Parameters
Tthe coordinate type, e.g., double, float, etc.
NDIMSthe number of dimensions
Note
The Polyhedron functions do not check that points defining a face are coplanar. It is the responsibility of the caller to pass a valid set of points and neighbors.
The polyhedron neighbors should be ordered counter clockwise as when viewing the polyhedron externally.

4-----—7 /| /| / | / | 5-----—6 | | 0--—|–3 | / | / |/ |/ 1-----—2

For example, vertex 5 above should have neighbors (4,1,6).

Note
The Polyhedron functions do not check that neighbors are ordered counter clockwise. It is the responsibility of the caller to pass a valid neighbors ordering.

Member Typedef Documentation

◆ PointType

template<typename T, int NDIMS = 3>
using axom::primal::Polyhedron< T, NDIMS >::PointType = Point<T, NDIMS>

◆ VectorType

template<typename T, int NDIMS = 3>
using axom::primal::Polyhedron< T, NDIMS >::VectorType = Vector<T, NDIMS>

◆ NumArrayType

template<typename T, int NDIMS = 3>
using axom::primal::Polyhedron< T, NDIMS >::NumArrayType = NumericArray<T, NDIMS>

Constructor & Destructor Documentation

◆ Polyhedron()

template<typename T, int NDIMS = 3>
AXOM_HOST_DEVICE axom::primal::Polyhedron< T, NDIMS >::Polyhedron ( )
inline

Default constructor for an empty polyhedron

Member Function Documentation

◆ numVertices()

template<typename T, int NDIMS = 3>
AXOM_HOST_DEVICE int axom::primal::Polyhedron< T, NDIMS >::numVertices ( ) const
inline

Return the number of vertices in the polyhedron

Referenced by axom::primal::compute_bounding_box(), and axom::quest::IntersectionShaper::setExecPolicy().

◆ addVertex()

template<typename T, int NDIMS = 3>
AXOM_HOST_DEVICE int axom::primal::Polyhedron< T, NDIMS >::addVertex ( const PointType pt)
inline

Appends a vertex to the list of vertices.

Returns
The index where the vertex was inserted into.

References AXOM_HOST_DEVICE, and SLIC_ASSERT.

Referenced by axom::quest::IntersectionShaper::setExecPolicy().

◆ addNeighbors() [1/3]

template<typename T, int NDIMS = 3>
AXOM_HOST_DEVICE void axom::primal::Polyhedron< T, NDIMS >::addNeighbors ( const PointType pt,
std::initializer_list< axom::int8 nbrs 
)
inline

Stores nbrs as the neighbors of vertex pt. If vertex pt is not in the polyhedron, neighbors are not added.

Note
pt should be a vertex of this polyhedron. Otherwise, pt may not be found due to floating point precision differences.
Parameters
[in]ptThe vertex to add neighbors
[in]nbrsThe neighbors to add to the list of neighbors

References AXOM_HOST_DEVICE.

Referenced by axom::quest::IntersectionShaper::setExecPolicy().

◆ addNeighbors() [2/3]

template<typename T, int NDIMS = 3>
AXOM_HOST_DEVICE void axom::primal::Polyhedron< T, NDIMS >::addNeighbors ( int  vtxId,
std::initializer_list< axom::int8 nbrs 
)
inline

Stores nbrs as the neighbors of vertex at a given index.

Note
Caller is responsible for ensuring a given vertex has enough space remaining to fit the new neighbors.
Parameters
[in]vtxIdThe vertex id to add neighbors
[in]nbrsThe neighbors to add to the list of neighbors
Precondition
vtxId < getVertices()

References AXOM_HOST_DEVICE.

◆ addNeighbors() [3/3]

template<typename T, int NDIMS = 3>
AXOM_HOST_DEVICE void axom::primal::Polyhedron< T, NDIMS >::addNeighbors ( int  vtxId,
int  nbr 
)
inline

Adds a single nbr as the neighbor of vertex at a given index.

Note
Caller is responsible for ensuring a given vertex has enough space remaining to fit the new neighbor.
Parameters
[in]vtxIdThe vertex id to add the neighbor
[in]nbrThe neighbor to add to the list of neighbors
Precondition
vtxId < getVertices()

◆ clear()

template<typename T, int NDIMS = 3>
AXOM_HOST_DEVICE void axom::primal::Polyhedron< T, NDIMS >::clear ( )
inline

Clears the list of vertices and neighbors

◆ getVertices()

template<typename T, int NDIMS = 3>
Coords& axom::primal::Polyhedron< T, NDIMS >::getVertices ( )
inline

Retrieves the vertices

◆ operator[]() [1/2]

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

Retrieves the vertex at index idx

◆ operator[]() [2/2]

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

Retrieves the vertex at index idx

◆ getNeighbors() [1/3]

template<typename T, int NDIMS = 3>
AXOM_HOST_DEVICE Neighbors& axom::primal::Polyhedron< T, NDIMS >::getNeighbors ( )
inline

Retrieves the neighbors

◆ getNumNeighbors()

template<typename T, int NDIMS = 3>
AXOM_HOST_DEVICE int axom::primal::Polyhedron< T, NDIMS >::getNumNeighbors ( int  i) const
inline

References AXOM_HOST_DEVICE.

◆ getNeighbors() [2/3]

template<typename T, int NDIMS = 3>
AXOM_HOST_DEVICE Neighbors::VertexNbrs& axom::primal::Polyhedron< T, NDIMS >::getNeighbors ( int  i)
inline

Retrieves the neighbors for vertex i

References AXOM_HOST_DEVICE.

◆ getNeighbors() [3/3]

template<typename T, int NDIMS = 3>
AXOM_HOST_DEVICE const Neighbors::VertexNbrs& axom::primal::Polyhedron< T, NDIMS >::getNeighbors ( int  i) const
inline

Retrieves the neighbors for vertex i

References AXOM_HOST_DEVICE.

◆ centroid()

template<typename T, int NDIMS = 3>
AXOM_HOST_DEVICE PointType axom::primal::Polyhedron< T, NDIMS >::centroid ( ) const
inline

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

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

References AXOM_HOST_DEVICE, and SLIC_ASSERT.

Referenced by axom::quest::IntersectionShaper::setExecPolicy().

◆ volume()

template<typename T, int NDIMS = 3>
AXOM_HOST_DEVICE double axom::primal::Polyhedron< T, NDIMS >::volume ( ) const
inline

Finds the volume of the polyhedron.

Returns
The volume of the polyhedron
Note
Function is based off moments() in Mike Owen's PolyClipper.
Precondition
polyhedron vertex neighbors are defined, and polyhedron is 3D

References axom::numerics::cross_product(), axom::primal::Vector< T, NDIMS >::dot(), axom::primal::NeighborCollection::MAX_VERTS, and SLIC_CHECK_MSG.

Referenced by axom::quest::IntersectionShaper::setExecPolicy().

◆ print()

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

Simple formatted print of a polyhedron instance.

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

References AXOM_HOST_DEVICE, and axom::primal::NeighborCollection::getNeighbors().

◆ isValid()

template<typename T, int NDIMS = 3>
AXOM_HOST_DEVICE bool axom::primal::Polyhedron< T, NDIMS >::isValid ( ) const
inline

Simple check for validity of a polyhedron.

Initial check is that the polyhedron has four or more vertices

Returns
True, if the polyhedron is valid, False otherwise

References AXOM_HOST_DEVICE.

◆ hasNeighbors()

template<typename T, int NDIMS = 3>
AXOM_HOST_DEVICE bool axom::primal::Polyhedron< T, NDIMS >::hasNeighbors ( ) const
inline

Check if vertex neighbors information is available.

Checks if neighbors is not empty

Returns
True, if the polyhedron has neighbors info for each vertex, False otherwise

Member Data Documentation

◆ MAX_VERTS

template<typename T, int NDIMS = 3>
constexpr int axom::primal::Polyhedron< T, NDIMS >::MAX_VERTS = NeighborCollection::MAX_VERTS
static

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