Definition of a general (possibly non-convex) mesh.
The mesh may be a triangular surface mesh or a tetrahedral volume mesh, depending on how it used.
Meshes can be used with all three roles but, currently, the support for the proximity role is limited. Where a general mesh is not supported, the mesh is replaced by its convex hull. See the documentation of QueryObject's proximity queries for more details. The notable cases where the actual mesh topology is used includes:
- Computing signed distances from the Mesh to query points (when it references a .obj file or a tetrahedral .vtk file).
- Specifying the Mesh as rigid hydroelastic (when it references a triangle .obj file or a tetrahedral .vtk file).
- Specifying the Mesh as compliant hydroelastic (when it references a tetrahedral .vtk file).
- Specifying the Mesh as deformable (when it references a tetrahedral .vtk file).
This convex-hull substitution is a regrettable stop-gap solution until we fully support general, non-convex meshes throughout proximity queries.
For visual roles (illustration and perception), the specified mesh file is used as directly as possible.
The mesh is defined in a canonical frame C, implicit in the file parsed. Upon loading it in SceneGraph it can be scaled around the origin of C by a given scale amount.
Note: a negative scale can be applied. This can be useful in mirroring the geometry (e.g., using a right hand mesh for a left hand). Mirroring the geometry will typically change the "winding" of the mesh elements. By convention, Drake looks at the ordering of the vertices that form mesh elements (triangles and tetrahedra) and derives the notion of "inside" and "outside" relative to that element. In order to preserve the input mesh's definition of "inside" and "outside", when the mesh gets mirrored Drake may perturb the ordering of the vertex indices. For example, a triangle originally referencing vertices [0 1 2], when mirrored may change to [2 1 0], so don't be surprised if you introspect the details of the loaded mesh and you see such a change. An analogous change can affect the vertex ordering of tetrahedra in a volume mesh (i.e., a perturbation of the original vertex index list [0 1 2 3] to [2 1 0 3]).
|
| | Mesh (const std::filesystem::path &filename, double scale=1.0) |
| | Constructs a mesh shape specification from the mesh file located at the given file path.
|
| | Mesh (const std::filesystem::path &filename, const Vector3< double > &scale3) |
| | Mesh-file variant that allows for specification of non-uniform scale.
|
| | Mesh (InMemoryMesh mesh_data, double scale=1.0) |
| | Constructs a mesh shape specification from the contents of a Drake-supported mesh file type.
|
| | Mesh (InMemoryMesh mesh_data, const Vector3< double > &scale3) |
| | Mesh-contents variant that allows for specification of non-uniform scale.
|
| | Mesh (MeshSource source, double scale=1.0) |
| | Constructs a mesh shape specification from the given source.
|
| | Mesh (MeshSource source, const Vector3< double > &scale3) |
| | Mesh-source variant that allows for specification of non-uniform scale.
|
| | ~Mesh () final |
| const MeshSource & | source () const |
| | Returns the source for this specification's mesh data.
|
| const std::string & | extension () const |
| | Returns the extension of the mesh type – all lower case and including the dot.
|
| double | scale () const |
| | Returns a single scale representing the uniform scale factor.
|
| const Vector3< double > & | scale3 () const |
| | Returns general scale factors for this mesh.
|
| const PolygonSurfaceMesh< double > & | GetConvexHull () const |
| | Reports the convex hull of the named mesh.
|
| | Mesh (const Mesh &)=default |
| Mesh & | operator= (const Mesh &)=default |
| | Mesh (Mesh &&)=default |
| Mesh & | operator= (Mesh &&)=default |
| virtual | ~Shape () |
| void | Reify (ShapeReifier *reifier, void *user_data=nullptr) const |
| | Causes this description to be reified in the given reifier.
|
| std::unique_ptr< Shape > | Clone () const |
| | Creates a unique copy of this shape.
|
| std::string_view | type_name () const |
| | Returns the (unqualified) type name of this Shape, e.g., "Box".
|
| std::string | to_string () const |
| | Returns a string representation of this shape.
|
| template<typename ReturnType = void, typename Visitor> |
| decltype(auto) | Visit (Visitor &&visitor) const |
| | Calls the given visitor function with *this as the sole argument, but with *this downcast to be the shape's concrete subclass.
|