Drake
Mesh Class Reference

#include <multibody/shapes/geometry.h>

Inheritance diagram for Mesh:
[legend]
Collaboration diagram for Mesh:
[legend]

Public Types

enum  TriangulatePolicy { kFailOnNonTri, kTry }
 Specification of how the Mesh should process faces during parsing. More...
 

Public Member Functions

 Mesh (const std::string &uri, const std::string &resolved_filename)
 Constructs a representation of a mesh to be loaded from resolved_filename. More...
 
virtual ~Mesh ()
 
Meshclone () const override
 
void getPoints (Eigen::Matrix3Xd &points) const override
 
bool hasFaces () const override
 
void getFaces (TrianglesVector *faces) const override
 Returns the faces making up this geometry as a vector of triangles. More...
 
void getBoundingBoxPoints (Eigen::Matrix3Xd &points) const override
 
bool extractMeshVertices (Eigen::Matrix3Xd &vertex_coordinates) const
 
void LoadObjFile (PointsVector *vertices, TrianglesVector *triangles, TriangulatePolicy triangulate=TriangulatePolicy::kFailOnNonTri) const
 Loads triangle mesh from an obj file into the provided vectors of vertices and triangles. More...
 
- Public Member Functions inherited from Geometry
 Geometry ()
 
virtual ~Geometry ()
 
Shape getShape () const
 
virtual void getTerrainContactPoints (Eigen::Matrix3Xd &points) const
 

Public Attributes

Eigen::Vector3d scale_
 
std::string uri_
 
std::string resolved_filename_
 

Friends

std::ostream & operator<< (std::ostream &, const Mesh &)
 A toString method for this class. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Geometry
 Geometry (Shape shape)
 
 Geometry (const Geometry &)=default
 
void operator= (const Geometry &)=delete
 
void getBoundingBoxPoints (double x_half_width, double y_half_width, double z_half_width, Eigen::Matrix3Xd &points) const
 
- Protected Attributes inherited from Geometry
Shape shape
 
- Static Protected Attributes inherited from Geometry
static const int NUM_BBOX_POINTS = 8
 

Member Enumeration Documentation

enum TriangulatePolicy
strong

Specification of how the Mesh should process faces during parsing.

Enumerator
kFailOnNonTri 

Non-triangular faces cause an exception to be thrown.

kTry 

The parser will attempt to triangulate non-triangular faces, throwing an exception if the attempt fails.

Constructor & Destructor Documentation

Mesh ( const std::string &  uri,
const std::string &  resolved_filename 
)

Constructs a representation of a mesh to be loaded from resolved_filename.

uri provides a unique identifier used to interact with BotVisualizer.

Here is the caller graph for this function:

virtual ~Mesh ( )
inlinevirtual

Here is the call graph for this function:

Member Function Documentation

Mesh * clone ( ) const
overridevirtual

Reimplemented from Geometry.

Here is the call graph for this function:

bool extractMeshVertices ( Eigen::Matrix3Xd &  vertex_coordinates) const

Here is the call graph for this function:

Here is the caller graph for this function:

void getBoundingBoxPoints ( Eigen::Matrix3Xd &  points) const
overridevirtual

Reimplemented from Geometry.

Here is the call graph for this function:

void getFaces ( TrianglesVector faces) const
overridevirtual

Returns the faces making up this geometry as a vector of triangles.

Each triangle contains three indices into the vertex list returned by the Geometry getPoints() method.

Parameters
[out]facesReturns a vector of triangles describing this geometry.

Reimplemented from Geometry.

Here is the call graph for this function:

void getPoints ( Eigen::Matrix3Xd &  points) const
overridevirtual

Reimplemented from Geometry.

Here is the call graph for this function:

bool hasFaces ( ) const
inlineoverridevirtual
Returns
true if this geometry can return faces.

Reimplemented from Geometry.

Here is the call graph for this function:

void LoadObjFile ( PointsVector vertices,
TrianglesVector triangles,
TriangulatePolicy  triangulate = TriangulatePolicy::kFailOnNonTri 
) const

Loads triangle mesh from an obj file into the provided vectors of vertices and triangles.

This method can optionally attempt to triangulate the mesh as it is read. This triangulation is conservative. Non-triangular faces are decomposed into a set of equivalent triangles. It places certain requirements on the mesh for the triangulation to be valid. If these requirements are not met, an exception is thrown. These requirements are:

  1. Non-triangular faces cannot contain a sequence of co-linear vertices.
  2. Non-triangular faces must be close to planar; the decomposed triangles normals can deviate by no more than 30 degrees from their edge-adjacent neighbors.
  3. Decomposed triangles must have an area larger than 10⁻¹⁰ m².

NOTE: The triangulation method is simple. Even if these requirements are met, triangulation might fail.

Parameters
[out]verticesVector of 3D vertices in the mesh.
[out]trianglesVector of indices for each triangle in the mesh. The i-th entry of triangles holds a 3D vector of integer indices into vertices corresponding to the vertices forming the i-th triangle.
[in]triangulateSpecifies the triangulation policy.

On output, vertices.size() corresponds to the number of vertices in the mesh while triangles.size() corresponds to the number of triangles in the mesh.

Here is the call graph for this function:

Here is the caller graph for this function:

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  out,
const Mesh mm 
)
friend

A toString method for this class.

Member Data Documentation

std::string resolved_filename_
Eigen::Vector3d scale_
std::string uri_

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