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...
|
| | 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...
|
| |
| 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 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...
|
| |
template<typename T, int NDIMS = 3>
class axom::primal::Polyhedron< T, NDIMS >
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)
- Template Parameters
-
| T | the coordinate type, e.g., double, float, etc. |
| NDIMS | the 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 representing a convex polyhedron.
-
The polyhedron neighbors should be ordered counter clockwise as when viewing the polyhedron externally.
3--------2 +y
/| /|
/ | / | ^
7--------6 | |
| 0-----|--1 |
| / | / -----> +x
|/ |/ /
4--------5 /
<
+z
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.
template<typename T , int NDIMS = 3>
Helper function to find the faces of the Polyhedron, assuming the vertex neighbors are in counter-clockwise ordering.
- Parameters
-
| [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 |
- Warning
- Function is experimental, input parameters and/or output may change in the future.
- Note
- This function does not check that the provided buffers are large enough to hold all values. It is the responsibility of the caller to know ahead of time and pass buffers with appropriate size.
-
Function is based off extractFaces() in Mike Owen's PolyClipper.
- Precondition
- polyhedron vertex neighbors are defined
References axom::primal::NeighborCollection::getNumNeighbors(), axom::primal::Polyhedron< T, NDIMS >::MAX_VERTS, and axom::primal::Polyhedron< T, NDIMS >::numVertices().
template<typename T , int NDIMS = 3>
Computes the moments of the polyhedron. The 0th moment is the volume of the polyhedron, the 1st moment is the centroid.
- Parameters
-
| [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. |
- Note
- Function is based off moments() in Mike Owen's PolyClipper.
- Precondition
- polyhedron vertex neighbors are defined, and polyhedron is 3D
- See also
- volume()
-
centroid()
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().
template<typename T , int NDIMS = 3>