Drake
VolumeMesh< T > Class Template Reference

Detailed Description

template<class T>
class drake::geometry::VolumeMesh< T >

VolumeMesh represents a tetrahedral volume mesh.

Template Parameters
TThe 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< VolumeVertex< T >> &&vertices)
 Constructor from a vector of vertices and from a vector of elements. More...
 
const VolumeElementelement (ElementIndex e) const
 
const VolumeVertex< T > & vertex (VertexIndex v) const
 Returns the vertex identified by a given index. More...
 
const std::vector< VolumeVertex< 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...
 
CalcTetrahedronVolume (VolumeElementIndex e) const
 Calculates volume of a tetrahedral element. More...
 
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, ElementIndex 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, VolumeElementIndex e) const
 Calculates the gradient ∇u of a linear field u on the tetrahedron e. More...
 
Implements CopyConstructible, CopyAssignable, MoveConstructible, MoveAssignable
 VolumeMesh (const VolumeMesh &)=default
 
VolumeMeshoperator= (const VolumeMesh &)=default
 
 VolumeMesh (VolumeMesh &&)=default
 
VolumeMeshoperator= (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
 
using VertexIndex = VolumeVertexIndex
 Index for identifying a vertex. More...
 
template<typename U = T>
using VertexType = VolumeVertex< U >
 
using ElementIndex = VolumeElementIndex
 Index for identifying a tetrahedral element. More...
 
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...
 

Member Typedef Documentation

◆ Barycentric

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.

◆ ElementIndex

Index for identifying a tetrahedral element.

◆ ScalarType

using ScalarType = T

◆ VertexIndex

Index for identifying a vertex.

◆ VertexType

Constructor & Destructor Documentation

◆ VolumeMesh() [1/3]

VolumeMesh ( const VolumeMesh< T > &  )
default

◆ VolumeMesh() [2/3]

VolumeMesh ( VolumeMesh< T > &&  )
default

◆ VolumeMesh() [3/3]

VolumeMesh ( std::vector< VolumeElement > &&  elements,
std::vector< VolumeVertex< 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.

Member Function Documentation

◆ CalcBarycentric()

Barycentric<promoted_numerical_t<T, C> > CalcBarycentric ( const Vector3< C > &  p_MQ,
ElementIndex  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.

Parameters
p_MQA position expressed in the frame M of the mesh.
eThe index of a tetrahedral element.
Note
If p_MQ is outside the tetrahedral element, the barycentric coordinates (b₀, b₁, b₂, b₃) still satisfy b₀ + b₁ + b₂ + b₃ = 1; however, some bᵢ will be negative.

◆ CalcGradientVectorOfLinearField()

Vector3<promoted_numerical_t<T, FieldValue> > CalcGradientVectorOfLinearField ( const std::array< FieldValue, 4 > &  field_value,
VolumeElementIndex  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.

◆ CalcTetrahedronVolume()

T CalcTetrahedronVolume ( VolumeElementIndex  e) const

Calculates volume of a tetrahedral element.

◆ CalcVolume()

T CalcVolume ( ) const

Calculates the volume of this mesh by taking the sum of the volume of each tetrahedral element.

◆ element()

const VolumeElement& element ( ElementIndex  e) const

◆ Equal()

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.

Parameters
meshThe mesh for comparison.
vertex_toleranceThe maximum distance allowed between two vertices to be considered equal.
Returns
true if the given mesh is equal.

◆ num_elements()

int num_elements ( ) const

Returns the number of tetrahedral elements in the mesh.

◆ num_vertices()

int num_vertices ( ) const

Returns the number of vertices in the mesh.

◆ operator=() [1/2]

VolumeMesh& operator= ( VolumeMesh< T > &&  )
default

◆ operator=() [2/2]

VolumeMesh& operator= ( const VolumeMesh< T > &  )
default

◆ tetrahedra()

const std::vector<VolumeElement>& tetrahedra ( ) const

◆ vertex()

const VolumeVertex<T>& vertex ( VertexIndex  v) const

Returns the vertex identified by a given index.

Parameters
vThe index of the vertex.
Precondition
v ∈ {0, 1, 2,...,num_vertices()-1}.

◆ vertices()

const std::vector<VolumeVertex<T> >& vertices ( ) const

Friends And Related Function Documentation

◆ internal::MeshDeformer< VolumeMesh< T > >

friend class internal::MeshDeformer< VolumeMesh< T > >
friend

◆ VolumeMeshTester< T >

friend class VolumeMeshTester< T >
friend

Member Data Documentation

◆ kVertexPerElement

constexpr int kVertexPerElement = 4
static

Number of vertices per element.

A tetrahedron has 4 vertices.


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