|
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 = axom::NumericArray< T, NDIMS > |
| using | PlaneType = Plane< T, NDIMS > |
| using | PlaneArrayType = StackArray< PlaneType, MAX_PLANES > |
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 | vertexMean () const |
| Computes the vertex mean as the average of the polyhedron's vertex positions. More... | |
| template<typename ConnectivityType = int> | |
| AXOM_HOST_DEVICE void | getFaces (ConnectivityType *faces, ConnectivityType *face_size, ConnectivityType *face_offset, axom::IndexType &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 PlaneArrayType | getFaces (axom::IndexType &numFaces, bool divideNonPlanarFaces=true, double eps=1.e-8) const |
| Get the polyhedron's faces as planes. More... | |
| AXOM_HOST_DEVICE void | moments (double &volume, PointType ¢roid, bool should_compute_centroid=true) const |
| Computes the moments of the polyhedron. The 0th moment is the volume of the polyhedron, the 1st moment is the centroid. 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... | |
| AXOM_HOST_DEVICE PointType | centroid () const |
| Computes the centroid as the center of mass 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 |
| constexpr static int | MAX_PLANES = 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 = axom::NumericArray<T, NDIMS> |
| using axom::primal::Polyhedron< T, NDIMS >::PlaneType = Plane<T, NDIMS> |
| using axom::primal::Polyhedron< T, NDIMS >::PlaneArrayType = StackArray<PlaneType, MAX_PLANES> |
|
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 vertex mean 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.
| ConnectivityType | The type to generate for the polyhedral face data. |
| [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 |
Get the polyhedron's faces as planes.
| [out] | The | number of faces. |
| divideNonPlanarFaces | Whether to divide non-planar faces into separate planes. | |
| eps | The tolerance used to decide whether points are close enough to a plane. |
References axom::utilities::abs(), axom::primal::make_plane(), axom::primal::Polyhedron< T, NDIMS >::MAX_PLANES, and axom::primal::Polyhedron< T, NDIMS >::MAX_VERTS.
|
inline |
Computes the moments of the polyhedron. The 0th moment is the volume of the polyhedron, the 1st moment is the centroid.
| [out] | volume | The volume of the polyhedron (0th moment) |
| [out] | centroid | The centroid of the polyhedron (1st moment) |
| [in] | should_compute_centroid | If true, computes the centroid of the polyhedron. Default is true. |
References axom::primal::Polyhedron< T, NDIMS >::centroid(), 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(), SLIC_CHECK_MSG, and axom::primal::Polyhedron< T, NDIMS >::volume().
|
inline |
Computes the signed volume of the polyhedron.
References axom::primal::Polyhedron< T, NDIMS >::centroid(), axom::primal::Polyhedron< T, NDIMS >::moments(), and axom::primal::Polyhedron< T, NDIMS >::volume().
|
inline |
Returns the absolute (unsigned) volume of the polyhedron.
References axom::utilities::abs(), and axom::primal::Polyhedron< T, NDIMS >::signedVolume().
|
inline |
Computes the centroid as the center of mass of the polyhedron.
References axom::primal::Polyhedron< T, NDIMS >::moments(), and axom::primal::Polyhedron< T, NDIMS >::volume().
|
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 |
|
staticconstexpr |