template<class T>
class drake::geometry::TriangleSurfaceMesh< T >
TriangleSurfaceMesh represents a union of triangles.
The surface is not necessarily continuous.
- Template Parameters
-
|
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 TriangleSurfaceMesh, an element is a triangle.
|
| using | ScalarType = T |
| template<typename U = T> |
| using | Barycentric = Vector<U, kVertexPerElement> |
| | Type of barycentric coordinates on a triangular element.
|
| static constexpr int | kVertexPerElement = 3 |
| | Number of vertices per element.
|
| class | TriangleSurfaceMeshTester< T > |
| const SurfaceTriangle & | element (int e) const |
| | Returns the triangular element identified by a given index.
|
| Vector3< T > | element_centroid (int t) const |
| | Returns the centroid of a triangle measured and expressed in the mesh's frame.
|
| const std::vector< SurfaceTriangle > & | triangles () const |
| | Returns the triangles.
|
| const std::vector< Vector3< T > > & | vertices () const |
| | Returns the vertices.
|
| const Vector3< T > & | vertex (int v) const |
| | Returns the vertex identified by a given index.
|
| int | num_vertices () const |
| | Returns the number of vertices in the mesh.
|
| int | num_elements () const |
| | Returns the number of triangles in the mesh.
|
| | TriangleSurfaceMesh (std::vector< SurfaceTriangle > &&triangles, std::vector< Vector3< T > > &&vertices) |
| | Constructs a TriangleSurfaceMesh from triangles and vertices.
|
| void | TransformVertices (const math::RigidTransform< T > &X_NM) |
| | (Internal use only) Transforms the vertices of this mesh from its initial frame M to the new frame N.
|
| void | ReverseFaceWinding () |
| | (Internal use only) Reverses the ordering of all the triangles' indices – see SurfaceTriangle::ReverseWinding().
|
| int | num_triangles () const |
| | Returns the number of triangles in the mesh.
|
| const T & | area (int t) const |
| | Returns area of triangle t.
|
| const T & | total_area () const |
| | Returns the total area of all the triangles of this surface mesh.
|
| const Vector3< T > & | face_normal (int t) const |
| | Returns the unit face normal vector of a triangle.
|
| const Vector3< T > & | centroid () const |
| | Returns the area-weighted geometric centroid of this surface mesh.
|
| template<typename B> |
| Vector3< promoted_numerical_t< T, B > > | CalcCartesianFromBarycentric (int element_index, const Barycentric< B > &b_Q) const |
| | Maps the barycentric coordinates Q_barycentric of a point Q in element_index to its position vector p_MQ.
|
| template<typename C> |
| Barycentric< promoted_numerical_t< T, C > > | CalcBarycentric (const Vector3< C > &p_MQ, int t) const |
| | Calculate barycentric coordinates with respect to the triangle t of the point Q'.
|
| std::pair< Vector3< T >, Vector3< T > > | CalcBoundingBox () const |
| | Calculates the axis-aligned bounding box of this surface mesh M.
|
| bool | Equal (const TriangleSurfaceMesh< T > &mesh) const |
| | Checks to see whether the given TriangleSurfaceMesh object is equal via deep exact comparison.
|
| template<typename FieldValue> |
| Vector3< FieldValue > | CalcGradientVectorOfLinearField (const std::array< FieldValue, 3 > &field_value, int t) const |
| | Calculates the gradient ∇u of a linear field u on the triangle t.
|
| template<typename FieldValue> |
| std::optional< Vector3< FieldValue > > | MaybeCalcGradientVectorOfLinearField (const std::array< FieldValue, 3 > &field_value, int t) const |
| | Calculates the gradient ∇u of a linear field u on the triangle t.
|
| void | SetAllPositions (const Eigen::Ref< const VectorX< T > > &p_MVs) |
| | Updates the position of all vertices in the mesh.
|
template<class T>
template<typename U = T>
Type of barycentric coordinates on a triangular element.
Barycentric coordinates (b₀, b₁, b₂) satisfy b₀ + b₁ + b₂ = 1. It corresponds to a position on the plane of the triangle. If all bᵢ >= 0, it corresponds to a position inside the triangle or on the edges of the triangle. If some bᵢ < 0, it corresponds to a position on the plane of the triangle that is outside the triangle. Technically we could calculate one of the bᵢ from the others; however, there is no standard way to omit one of the coordinates.
The barycentric coordinates for a point Q are notated a b_Q.
template<class T>
| const Vector3< T > & centroid |
( |
| ) |
const |
Returns the area-weighted geometric centroid of this surface mesh.
The returned value is the position vector p_MSc from M's origin to the centroid Sc, expressed in frame M. (M is the frame in which this mesh's vertices are measured and expressed.) Note that the centroid is not necessarily a point on the surface. If the total mesh area is exactly zero, we define the centroid to be (0,0,0).
The centroid location is calculated per face not per vertex so is insensitive to whether vertices are shared by triangles.
template<class T>
| void SetAllPositions |
( |
const Eigen::Ref< const VectorX< T > > & | p_MVs | ) |
|
Updates the position of all vertices in the mesh.
Each sequential triple in p_MVs (e.g., 3i, 3i + 1, 3i + 2), i ∈ ℤ, is interpreted as a position vector associated with the iᵗʰ vertex. The position values are interpreted to be measured and expressed in the same frame as the mesh to be deformed.
- Parameters
-
| p_MVs | Vertex positions for the mesh's N vertices flattened into a vector (where each position vector is measured and expressed in the mesh's original frame). |
- Exceptions
-