AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
|
Represents a convex 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/main/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 | |
Polyhedron ()=default | |
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< std::int8_t > 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< std::int8_t > 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 () |
Coords & | getVertices () |
AXOM_HOST_DEVICE PointType & | operator[] (int idx) |
AXOM_HOST_DEVICE const PointType & | operator[] (int idx) const |
AXOM_HOST_DEVICE Neighbors & | getNeighbors () |
AXOM_HOST_DEVICE int | getNumNeighbors (int i) const |
AXOM_HOST_DEVICE Neighbors::VertexNbrs & | getNeighbors (int i) |
AXOM_HOST_DEVICE const Neighbors::VertexNbrs & | getNeighbors (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 void | getFaces (int *faces, int *face_size, int *face_offset, int &face_count) const |
Helper function to find the faces of the Polyhedron, assuming the vertex neighbors are in counter-clockwise ordering. More... | |
AXOM_HOST_DEVICE double | signedVolume () const |
Computes the signed volume of the polyhedron. More... | |
AXOM_HOST_DEVICE double | volume () const |
Returns the absolute (unsigned) 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 | hasDuplicateVertices (double eps=1.e-10) const |
Check if any vertices are duplicate, within a tolerance. More... | |
AXOM_HOST_DEVICE bool | hasNeighbors () const |
Check if vertex neighbors information is available. More... | |
Static Public Member Functions | |
static AXOM_HOST_DEVICE Polyhedron | from_primitive (const Hexahedron< T, NDIMS > &hex, bool tryFixOrientation=false) |
Creates a Polyhedron from a given Hexahedron's vertices. More... | |
static AXOM_HOST_DEVICE Polyhedron | from_primitive (const Octahedron< T, NDIMS > &oct, bool tryFixOrientation=false) |
Creates a Polyhedron from a given Octahedron's vertices. More... | |
static AXOM_HOST_DEVICE Polyhedron | from_primitive (const Tetrahedron< T, NDIMS > &tet, bool tryFixOrientation=false) |
Creates a Polyhedron from a given Tetrahedron's vertices. More... | |
Static Public Attributes | |
constexpr static int | MAX_VERTS = NeighborCollection::MAX_VERTS |
Represents a convex 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)
T | the coordinate type, e.g., double, float, etc. |
NDIMS | the number of dimensions |
3--------2 +y /| /| / | / | ^ 7--------6 | | | 0-----|--1 | | / | / -----> +x |/ |/ / 4--------5 / < +z
For example, vertex 5 above should have neighbors (4,1,6).
using axom::primal::Polyhedron< T, NDIMS >::PointType = Point<T, NDIMS> |
using axom::primal::Polyhedron< T, NDIMS >::VectorType = Vector<T, NDIMS> |
using axom::primal::Polyhedron< T, NDIMS >::NumArrayType = NumericArray<T, NDIMS> |
|
default |
Default constructor for an empty polyhedron
|
inline |
Return the number of vertices in the polyhedron
|
inline |
Appends a vertex to the list of vertices.
References axom::primal::Polyhedron< T, NDIMS >::MAX_VERTS, and SLIC_ASSERT.
|
inline |
Stores nbrs as the neighbors of vertex pt. If vertex pt is not in the polyhedron, neighbors are not added.
[in] | pt | The vertex to add neighbors |
[in] | nbrs | The neighbors to add to the list of neighbors |
References axom::primal::NeighborCollection::addNeighbors().
|
inline |
Stores nbrs as the neighbors of vertex at a given index.
[in] | vtxId | The vertex id to add neighbors |
[in] | nbrs | The neighbors to add to the list of neighbors |
References axom::primal::NeighborCollection::addNeighbors().
|
inline |
Adds a single nbr as the neighbor of vertex at a given index.
[in] | vtxId | The vertex id to add the neighbor |
[in] | nbr | The neighbor to add to the list of neighbors |
References axom::primal::NeighborCollection::addNeighbors().
|
inline |
Clears the list of vertices and neighbors
References axom::primal::NeighborCollection::clear().
|
inline |
Retrieves the vertices
|
inline |
Retrieves the vertex at index idx
|
inline |
Retrieves the vertex at index idx
|
inline |
Retrieves the neighbors
|
inline |
|
inline |
Retrieves the neighbors for vertex i
|
inline |
Retrieves the neighbors for vertex i
|
inline |
Computes the centroid as the average of the polyhedron's vertex positions.
References axom::primal::Polyhedron< T, NDIMS >::isValid(), axom::primal::Polyhedron< T, NDIMS >::numVertices(), and SLIC_ASSERT.
|
inline |
Helper function to find the faces of the Polyhedron, assuming the vertex neighbors are in counter-clockwise ordering.
[out] | faces | is the vertex indices for faces |
[out] | face_offset | is the offset for each face |
[out] | face_size | is the number of vertices for each face |
[out] | face_count | is the number of faces |
References axom::primal::NeighborCollection::getNumNeighbors(), axom::primal::Polyhedron< T, NDIMS >::MAX_VERTS, and axom::primal::Polyhedron< T, NDIMS >::numVertices().
|
inline |
Computes the signed volume of the polyhedron.
References axom::primal::Polyhedron< T, NDIMS >::getFaces(), axom::primal::Polyhedron< T, NDIMS >::hasDuplicateVertices(), axom::primal::Polyhedron< T, NDIMS >::hasNeighbors(), axom::primal::Polyhedron< T, NDIMS >::isValid(), axom::primal::Polyhedron< T, NDIMS >::MAX_VERTS, axom::primal::Vector< T, NDIMS >::scalar_triple_product(), and SLIC_CHECK_MSG.
|
inline |
Returns the absolute (unsigned) volume of the polyhedron.
References axom::utilities::abs(), and axom::primal::Polyhedron< T, NDIMS >::signedVolume().
|
inline |
Simple formatted print of a polyhedron instance.
os | The output stream to write to |
References axom::primal::Polyhedron< T, NDIMS >::getNeighbors(), axom::primal::NeighborCollection::getNumNeighbors(), axom::primal::Polyhedron< T, NDIMS >::hasNeighbors(), and axom::primal::Polyhedron< T, NDIMS >::numVertices().
|
inline |
Simple check for validity of a polyhedron.
Initial check is that the polyhedron has four or more vertices
|
inline |
Check if any vertices are duplicate, within a tolerance.
[in] | eps | The tolerance |
References axom::utilities::isNearlyEqual().
|
inline |
Check if vertex neighbors information is available.
Checks if neighbors is not empty
References axom::primal::NeighborCollection::getNumNeighbors().
|
inlinestatic |
Creates a Polyhedron from a given Hexahedron's vertices.
[in] | hex | The hexahedron |
[in] | tryFixOrientation | If true, checks if the signed volume of the Polyhedron is negative and swaps the order of some vertices in that shape to try to obtain a nonnegative signed volume. Defaults to false. |
* * 4--------7 +z * /| /| +y * / | / | ^ > * 5--------6 | | / * | 0-----|--3 |/ * | / | / -----> +x * |/ |/ * 1--------2 * *
The Polyhedron's vertex neighbors are created assuming this vertex ordering.
References axom::primal::Polyhedron< T, NDIMS >::addNeighbors(), axom::primal::Polyhedron< T, NDIMS >::addVertex(), and axom::primal::Polyhedron< T, NDIMS >::signedVolume().
|
inlinestatic |
Creates a Polyhedron from a given Octahedron's vertices.
[in] | oct | The octahedron |
[in] | tryFixOrientation | If true, checks if the signed volume of the Polyhedron is negative and swaps the order of some vertices in that shape to try to obtain a nonnegative signed volume. Defaults to false. |
* * 4 +z * /\ +y * 0 --/ \-- 2 ^ > * \/ \ / | / * / \ |/ * 5 -------- 3 -----> +x * \/ * 1 * *
The Polyhedron's vertex neighbors are created assuming this vertex ordering.
References axom::primal::Polyhedron< T, NDIMS >::addNeighbors(), axom::primal::Polyhedron< T, NDIMS >::addVertex(), and axom::primal::Polyhedron< T, NDIMS >::signedVolume().
|
inlinestatic |
Creates a Polyhedron from a given Tetrahedron's vertices.
[in] | tet | The tetrahedron |
[in] | tryFixOrientation | If true, checks if the signed volume of the Polyhedron is negative and swaps the order of some vertices in that shape to try to obtain a nonnegative signed volume. Defaults to false. |
* * 3 +z * / \\ +y * / \ \ ^ > * / \ \ | / * / \ \ |/ * / \ 2 -----> +x * / \ / * /_____________\/ * 0 1 * *
The Polyhedron's vertex neighbors are created assuming this vertex ordering.
References axom::primal::Polyhedron< T, NDIMS >::addNeighbors(), axom::primal::Polyhedron< T, NDIMS >::addVertex(), and axom::primal::Tetrahedron< T, NDIMS >::signedVolume().
|
staticconstexpr |