All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
SurgSim::Math::MeshShape Class Reference

Mesh shape: shape made of a triangle mesh The triangle mesh needs to be watertight to produce valid volume, center and second moment of volume. More...

#include <SurgSim/Math/MeshShape.h>

Inheritance diagram for SurgSim::Math::MeshShape:
Inheritance graph
[legend]
Collaboration diagram for SurgSim::Math::MeshShape:
Collaboration graph
[legend]

Public Member Functions

 MeshShape ()
 Constructor. More...
 
template<class VertexData , class EdgeData , class TriangleData >
 MeshShape (const SurgSim::DataStructures::TriangleMeshBase< VertexData, EdgeData, TriangleData > &mesh)
 Constructor. More...
 
 SURGSIM_CLASSNAME (SurgSim::Math::MeshShape)
 
virtual int getType () override
 
std::shared_ptr
< SurgSim::DataStructures::TriangleMesh
getInitialMesh ()
 Gets the initial mesh. More...
 
std::shared_ptr
< SurgSim::DataStructures::TriangleMesh
getMesh ()
 Get mesh. More...
 
virtual double getVolume () const override
 Get the volume of the shape. More...
 
virtual Vector3d getCenter () const override
 Get the volumetric center of the shape. More...
 
virtual Matrix33d getSecondMomentOfVolume () const override
 Get the second central moment of the volume, commonly used to calculate the moment of inertia matrix. More...
 
void setPose (const SurgSim::Math::RigidTransform3d &pose)
 Set the object's global pose. More...
 
void updateAabbTree ()
 Update the AabbTree, which is an axis-aligned bounding box r-tree used to accelerate spatial searches. More...
 
std::shared_ptr
< SurgSim::DataStructures::AabbTree
getAabbTree ()
 Get the AabbTree. More...
 
bool isValid () const
 Check if this shape contains a valid mesh. More...
 
- Public Member Functions inherited from SurgSim::Math::Shape
virtual ~Shape ()
 
virtual std::string getClassName () const
 Get class name. More...
 
- Public Member Functions inherited from SurgSim::Framework::Accessible
 Accessible ()
 Default Constructor. More...
 
 ~Accessible ()
 Destructor. More...
 
template<class T >
getValue (const std::string &name) const
 Retrieves the value with the name by executing the getter if it is found and tries to convert it to the given type. More...
 
boost::any getValue (const std::string &name) const
 Retrieves the value with the name by executing the getter if it is found. More...
 
template<class T >
bool getValue (const std::string &name, T *value) const
 Retrieves the value with the name by executing the getter if it is found, and converts it to the type of the output parameter. More...
 
void setValue (const std::string &name, const boost::any &value)
 Sets a value of a property that has setter. More...
 
bool isReadable (const std::string &name) const
 Check whether a property is readable. More...
 
bool isWriteable (const std::string &name) const
 Check whether a property is writable. More...
 
void setGetter (const std::string &name, GetterType func)
 Sets a getter for a given property. More...
 
void setSetter (const std::string &name, SetterType func)
 Sets a setter for a given property. More...
 
void setAccessors (const std::string &name, GetterType getter, SetterType setter)
 Sets the accessors getter and setter in one function. More...
 
void removeAccessors (const std::string &name)
 Removes all the accessors (getter and setter) for a given property. More...
 
void forwardProperty (const std::string &name, const Accessible &target, const std::string &targetProperty)
 Adds a property with the given name that uses the targets accessors, in effect forwarding the value to the target. More...
 
void setSerializable (const std::string &name, EncoderType encoder, DecoderType decoder)
 Sets the functions used to convert data from and to a YAML::Node. More...
 
YAML::Node encode () const
 Encode this Accessible to a YAML::Node. More...
 
void decode (const YAML::Node &node)
 Decode this Accessible from a YAML::Node, will throw an exception if the data type cannot be converted. More...
 
template<>
boost::any getValue (const std::string &name) const
 
- Public Member Functions inherited from SurgSim::Framework::Asset
 Asset ()
 Constructor. More...
 
virtual ~Asset ()
 Destructor. More...
 
void load (const std::string &fileName, const SurgSim::Framework::ApplicationData &data)
 Load a file with given name using 'data' as look up path(s). More...
 
void load (const std::string &fileName)
 Overloaded function using SurgSim::Framework::Runtime::getApplicationData() as look up path(s). More...
 
std::string getFileName () const
 Return the name of file loaded by this class. More...
 

Protected Member Functions

virtual bool doLoad (const std::string &filePath) override
 Derived classes will overwrite this method to do actual loading. More...
 
- Protected Member Functions inherited from SurgSim::Framework::Asset
void serializeFileName (SurgSim::Framework::Accessible *accessible)
 Derived classes (which also inherit from SurgSim::Framework::Accessible) should call this function with 'this' pointer as the parameter in their constructors to register file name property for serialization. More...
 

Private Member Functions

void computeVolumeIntegrals ()
 Compute useful volume integrals based on the triangle mesh, which are used to get the volume , center and second moment of volume. More...
 

Private Attributes

SurgSim::Math::Vector3d m_center
 Center (considering a uniform distribution in the mesh volume) More...
 
double m_volume
 Volume (in m^-3) More...
 
SurgSim::Math::Matrix33d m_secondMomentOfVolume
 Second moment of volume. More...
 
std::shared_ptr
< SurgSim::DataStructures::TriangleMesh
m_mesh
 The triangle mesh contained by this shape. More...
 
std::shared_ptr
< SurgSim::DataStructures::TriangleMesh
m_initialMesh
 The initial triangle mesh contained by this shape. More...
 
std::shared_ptr
< SurgSim::DataStructures::AabbTree
m_aabbTree
 The aabb tree used to accelerate collision detection against the mesh. More...
 

Additional Inherited Members

- Public Types inherited from SurgSim::Math::Shape
typedef ::SurgSim::Math::Vector3d Vector3d
 
typedef ::SurgSim::Math::Matrix33d Matrix33d
 
typedef
SurgSim::Framework::ObjectFactory
< SurgSim::Math::Shape
FactoryType
 
- Public Types inherited from SurgSim::Framework::Accessible
typedef std::function
< boost::any(void)> 
GetterType
 
typedef std::function< void(boost::any)> SetterType
 
typedef std::function
< YAML::Node(void)> 
EncoderType
 
typedef std::function< void(const
YAML::Node *)> 
DecoderType
 
- Static Public Member Functions inherited from SurgSim::Math::Shape
static FactoryTypegetFactory ()
 

Detailed Description

Mesh shape: shape made of a triangle mesh The triangle mesh needs to be watertight to produce valid volume, center and second moment of volume.

If it is not the case and you need valid geometric properties, use SurfaceMeshShape instead. Various geometrical properties (volume based) are computed from the triangle mesh using David Eberly's work: http://www.geometrictools.com/Documentation/PolyhedralMassProperties.pdf

Note
The internal mesh should not be modified, otherwise the geometric properties will be invalid.
Practical use cases:
* Fixed/Rigid object, the mesh will not change anyway.
* Deformable object, the mesh will be updated, but the geometric properties will not be used.
See also
SurfaceMeshShape

Constructor & Destructor Documentation

SurgSim::Math::MeshShape::MeshShape ( )

Constructor.

template<class VertexData , class EdgeData , class TriangleData >
SurgSim::Math::MeshShape::MeshShape ( const SurgSim::DataStructures::TriangleMeshBase< VertexData, EdgeData, TriangleData > &  mesh)
explicit

Constructor.

Parameters
meshThe triangle mesh to build the shape from
Exceptions
Raisean exception if the mesh is invalid

Member Function Documentation

void SurgSim::Math::MeshShape::computeVolumeIntegrals ( )
private

Compute useful volume integrals based on the triangle mesh, which are used to get the volume , center and second moment of volume.

bool SurgSim::Math::MeshShape::doLoad ( const std::string &  filePath)
overrideprotectedvirtual

Derived classes will overwrite this method to do actual loading.

Note
This method is not required to do any check on the validity or the existence of the file.
Parameters
filePathAbsolute path to the file.
Returns
True if loading is successful; Otherwise, false.

Implements SurgSim::Framework::Asset.

std::shared_ptr< SurgSim::DataStructures::AabbTree > SurgSim::Math::MeshShape::getAabbTree ( )

Get the AabbTree.

Returns
The object's associated AabbTree
SurgSim::Math::Vector3d SurgSim::Math::MeshShape::getCenter ( ) const
overridevirtual

Get the volumetric center of the shape.

Note
this parameter is valid with respect to the initial mesh
Returns
The center of the shape

Implements SurgSim::Math::Shape.

std::shared_ptr< SurgSim::DataStructures::TriangleMesh > SurgSim::Math::MeshShape::getInitialMesh ( )

Gets the initial mesh.

Returns
The collision mesh associated to this MeshShape
std::shared_ptr< SurgSim::DataStructures::TriangleMesh > SurgSim::Math::MeshShape::getMesh ( )

Get mesh.

Returns
The collision mesh associated to this MeshShape
SurgSim::Math::Matrix33d SurgSim::Math::MeshShape::getSecondMomentOfVolume ( ) const
overridevirtual

Get the second central moment of the volume, commonly used to calculate the moment of inertia matrix.

Note
this parameter is valid with respect to the initial mesh
Returns
The 3x3 symmetric second moment matrix

Implements SurgSim::Math::Shape.

int SurgSim::Math::MeshShape::getType ( )
overridevirtual
Returns
the type of the shape

Implements SurgSim::Math::Shape.

double SurgSim::Math::MeshShape::getVolume ( ) const
overridevirtual

Get the volume of the shape.

Note
this parameter is valid with respect to the initial mesh
Returns
The volume of the shape (in m-3)

Implements SurgSim::Math::Shape.

bool SurgSim::Math::MeshShape::isValid ( ) const
virtual

Check if this shape contains a valid mesh.

Equals 'MeshShape::getMesh() != nullptr && MeshShape::getMesh()->isValid()'

Returns
true if this shape contains a valid mesh; otherwise, false.

Implements SurgSim::Math::Shape.

void SurgSim::Math::MeshShape::setPose ( const SurgSim::Math::RigidTransform3d pose)

Set the object's global pose.

Parameters
posethe rigid transform to apply
SurgSim::Math::MeshShape::SURGSIM_CLASSNAME ( SurgSim::Math::MeshShape  )
void SurgSim::Math::MeshShape::updateAabbTree ( )

Update the AabbTree, which is an axis-aligned bounding box r-tree used to accelerate spatial searches.

Member Data Documentation

std::shared_ptr<SurgSim::DataStructures::AabbTree> SurgSim::Math::MeshShape::m_aabbTree
private

The aabb tree used to accelerate collision detection against the mesh.

SurgSim::Math::Vector3d SurgSim::Math::MeshShape::m_center
private

Center (considering a uniform distribution in the mesh volume)

std::shared_ptr<SurgSim::DataStructures::TriangleMesh> SurgSim::Math::MeshShape::m_initialMesh
private

The initial triangle mesh contained by this shape.

std::shared_ptr<SurgSim::DataStructures::TriangleMesh> SurgSim::Math::MeshShape::m_mesh
private

The triangle mesh contained by this shape.

SurgSim::Math::Matrix33d SurgSim::Math::MeshShape::m_secondMomentOfVolume
private

Second moment of volume.

double SurgSim::Math::MeshShape::m_volume
private

Volume (in m^-3)


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