VolumeMesh represents a tetrahedral volume mesh.
T | The underlying scalar type for coordinates, e.g., double or AutoDiffXd. Must be a valid Eigen scalar. |
#include <drake/geometry/proximity/volume_mesh.h>
Public Member Functions | |
VolumeMesh (std::vector< VolumeElement > &&elements, std::vector< Vector3< T >> &&vertices) | |
Constructor from a vector of vertices and from a vector of elements. More... | |
const VolumeElement & | element (int e) const |
const Vector3< T > & | vertex (int v) const |
Returns the vertex identified by a given index. More... | |
const std::vector< Vector3< T > > & | vertices () const |
const std::vector< VolumeElement > & | tetrahedra () const |
int | num_elements () const |
Returns the number of tetrahedral elements in the mesh. More... | |
int | num_vertices () const |
Returns the number of vertices in the mesh. More... | |
T | CalcTetrahedronVolume (int e) const |
Calculates volume of a tetrahedral element. More... | |
T | CalcVolume () const |
Calculates the volume of this mesh by taking the sum of the volume of each tetrahedral element. More... | |
template<typename C > | |
Barycentric< promoted_numerical_t< T, C > > | CalcBarycentric (const Vector3< C > &p_MQ, int e) const |
Calculate barycentric coordinates with respect to the tetrahedron e of the point Q. More... | |
bool | Equal (const VolumeMesh< T > &mesh, double vertex_tolerance=0) const |
Checks to see whether the given VolumeMesh object is equal via deep comparison (up to a tolerance). More... | |
template<typename FieldValue > | |
Vector3< promoted_numerical_t< T, FieldValue > > | CalcGradientVectorOfLinearField (const std::array< FieldValue, 4 > &field_value, int e) const |
Calculates the gradient ∇u of a linear field u on the tetrahedron e . More... | |
void | TransformVertices (const math::RigidTransform< T > &transform) |
Transforms the vertices of this mesh from its initial frame M to the new frame N. More... | |
Implements CopyConstructible, CopyAssignable, MoveConstructible, MoveAssignable | |
VolumeMesh (const VolumeMesh &)=default | |
VolumeMesh & | operator= (const VolumeMesh &)=default |
VolumeMesh (VolumeMesh &&)=default | |
VolumeMesh & | operator= (VolumeMesh &&)=default |
Friends | |
class | internal::MeshDeformer< VolumeMesh< T > > |
class | VolumeMeshTester< T > |
Mesh type traits | |
A collection of type traits to enable mesh consumers to be templated on mesh type. Each mesh type provides specific definitions of vertex, element, and barycentric coordinates. For VolumeMesh, an element is a tetrahedron. | |
using | ScalarType = T |
template<typename U = T> | |
using | Barycentric = Vector< U, kVertexPerElement > |
Type of barycentric coordinates on a tetrahedral element. More... | |
static constexpr int | kVertexPerElement = 4 |
Number of vertices per element. More... | |
using Barycentric = Vector<U, kVertexPerElement> |
Type of barycentric coordinates on a tetrahedral element.
Barycentric coordinates (b₀, b₁, b₂, b₃) satisfy b₀ + b₁ + b₂ + b₃ = 1. It corresponds to a position in the space. If all bᵢ >= 0, it corresponds to a position inside the tetrahedron or on the faces of the tetrahedron. If some bᵢ < 0, it corresponds to a position outside the tetrahedron. Technically we could calculate one of the bᵢ from the others; however, there is no standard way to omit one of the coordinates.
using ScalarType = T |
|
default |
|
default |
VolumeMesh | ( | std::vector< VolumeElement > && | elements, |
std::vector< Vector3< T >> && | vertices | ||
) |
Constructor from a vector of vertices and from a vector of elements.
Each element must be a valid VolumeElement following the vertex ordering convention documented in the VolumeElement class. This class however does not enforce this convention and it is thus the responsibility of the user.
Barycentric<promoted_numerical_t<T, C> > CalcBarycentric | ( | const Vector3< C > & | p_MQ, |
int | e | ||
) | const |
Calculate barycentric coordinates with respect to the tetrahedron e
of the point Q.
This operation is expensive compared with going from barycentric to Cartesian.
The return type depends on both the mesh's vertex position scalar type T
and the Cartesian coordinate type C
of the query point. See promoted_numerical_t for details.
p_MQ | A position expressed in the frame M of the mesh. |
e | The index of a tetrahedral element. |
Vector3<promoted_numerical_t<T, FieldValue> > CalcGradientVectorOfLinearField | ( | const std::array< FieldValue, 4 > & | field_value, |
int | e | ||
) | const |
Calculates the gradient ∇u of a linear field u on the tetrahedron e
.
Field u is defined by the four field values field_value[i]
at the i-th vertex of the tetrahedron. The gradient ∇u is expressed in the coordinates frame of this mesh M.
The return type depends on both the mesh's vertex position scalar type T
and the given field's scalar type FieldValue
. See promoted_numerical_t for details.
T CalcTetrahedronVolume | ( | int | e | ) | const |
Calculates volume of a tetrahedral element.
f ∈ [0, num_elements())
. T CalcVolume | ( | ) | const |
Calculates the volume of this
mesh by taking the sum of the volume of each tetrahedral element.
const VolumeElement& element | ( | int | e | ) | const |
bool Equal | ( | const VolumeMesh< T > & | mesh, |
double | vertex_tolerance = 0 |
||
) | const |
Checks to see whether the given VolumeMesh object is equal via deep comparison (up to a tolerance).
NaNs are treated as not equal as per the IEEE standard. The tolerance is applied to corresponding vertex positions; the ith vertex in each mesh can have a distance of no more than vertex_tolerance
.
mesh | The mesh for comparison. |
vertex_tolerance | The maximum distance allowed between two vertices to be considered equal. |
true
if the given mesh is equal. int num_elements | ( | ) | const |
Returns the number of tetrahedral elements in the mesh.
int num_vertices | ( | ) | const |
Returns the number of vertices in the mesh.
|
default |
|
default |
const std::vector<VolumeElement>& tetrahedra | ( | ) | const |
void TransformVertices | ( | const math::RigidTransform< T > & | transform | ) |
Transforms the vertices of this mesh from its initial frame M to the new frame N.
[in] | transform | The transform X_NM relating the mesh in frame M to the new frame N. |
Returns the vertex identified by a given index.
v | The index of the vertex. |
const std::vector<Vector3<T> >& vertices | ( | ) | const |
|
friend |
|
friend |
|
static |
Number of vertices per element.
A tetrahedron has 4 vertices.