Drake
Drake C++ Documentation
VolumeMesh< T > Class Template Reference

## Detailed Description

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

VolumeMesh represents a tetrahedral volume mesh.

Template Parameters
 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 VolumeElementelement (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...

CalcTetrahedronVolume (int 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, 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

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

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...

## ◆ Barycentric

 using Barycentric = Vector

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.

## ◆ ScalarType

 using ScalarType = T

## ◆ 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< 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.

## ◆ CalcBarycentric()

 Barycentric > 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.

Parameters
 p_MQ A position expressed in the frame M of the mesh. e The 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.

 Vector3 > 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.

## ◆ CalcTetrahedronVolume()

 T CalcTetrahedronVolume ( int e ) const

Calculates volume of a tetrahedral element.

Precondition
f ∈ [0, num_elements()).

## ◆ 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 ( int 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
 mesh The mesh for comparison. vertex_tolerance The 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& tetrahedra ( ) const

## ◆ TransformVertices()

 void TransformVertices ( const math::RigidTransform< T > & transform )

Transforms the vertices of this mesh from its initial frame M to the new frame N.

Parameters
 [in] transform The transform X_NM relating the mesh in frame M to the new frame N.

## ◆ vertex()

 const Vector3& vertex ( int v ) const

Returns the vertex identified by a given index.

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

## ◆ vertices()

 const std::vector >& vertices ( ) const

## ◆ internal::MeshDeformer< VolumeMesh< T > >

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

## ◆ VolumeMeshTester< T >

 friend class VolumeMeshTester< T >
friend

## ◆ 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: