SurgSim::Math::CompoundShape Class Reference

`#include <SurgSim/Math/CompoundShape.h>`

Inheritance diagram for SurgSim::Math::CompoundShape:

## Public Types

typedef std::pair< std::shared_ptr< Shape >, RigidTransform3d > | SubShape
Public Types inherited from SurgSim::Math::Shape
typedef ::SurgSim::Math::Vector3d | Vector3d
typedef ::SurgSim::Math::Matrix33d | Matrix33d
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
Public Types inherited from SurgSim::Framework::FactoryBase< Shape >
typedef ObjectFactory< Shape > | FactoryType

## Public Member Functions

| CompoundShape ()
| Constructor. More...
| ~CompoundShape ()
| Destructor. More...
| SURGSIM_CLASSNAME (SurgSim::Math::CompoundShape)
size_t | addShape (const std::shared_ptr< Shape > &shape, const RigidTransform3d &pose=RigidTransform3d::Identity())
| Add a shape to this shape, you can optionally supply a pose for the added shape. More...
void | setShapes (const std::vector< SubShape > &shapes)
| Sets the shapes for this object, the shapes should be a list of shapes together with their respective poses, this will clear all the previously contained shapes. More...
const std::vector< SubShape > & | getShapes () const
const std::shared_ptr< Shape > & | getShape (size_t index) const
RigidTransform3d | getPose (size_t index) const
void | setPoses (const std::vector< RigidTransform3d > &poses)
| Sets the poses for all shapes. More...
void | setPose (size_t index, const RigidTransform3d &pose)
| Set the pose for the specified shape. More...
size_t | getNumShapes () const
void | clearShapes ()
| clears all the enclosed shapes More...
int | getType () const override
double | getVolume () const override
Vector3d | getCenter () const override
| Get the volumetric center of the shape. More...
Matrix33d | getSecondMomentOfVolume () const override
| Get the second central moment of the volume, commonly used to calculate the moment of inertia matrix. More...
bool | isValid () const override
| Check if the shape is valid. More...
const Math::Aabbd & | getBoundingBox () const override
bool | isTransformable () const override
std::shared_ptr< Shape > | getTransformed (const RigidTransform3d &pose) const override
| Get a copy of this shape with an applied rigid transform. More...
Public Member Functions inherited from SurgSim::Math::Shape
| Shape ()
| Constructor. More...
virtual | ~Shape ()
| Destructor. More...
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 >
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...
void | setDecoder (const std::string &name, DecoderType decoder)
| Sets the functions used to convert data from a YAML::Node. More...
YAML::Node | encode () const
| Encode this Accessible to a YAML::Node. More...
void | decode (const YAML::Node &node, const std::vector< std::string > &ignoredProperties=std::vector< std::string >())
| 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

## Private Types

typedef boost::shared_lock< boost::shared_mutex > | ReadLock
typedef boost::unique_lock< boost::shared_mutex > | WriteLock

## Private Member Functions

void | invalidateData ()
| Clears the data for the volume, center and secondMoment and aabb so it can be recalculated when needed again. More...

## Private Attributes

std::vector< SubShape > | m_shapes
boost::shared_mutex | m_mutex
DataStructures::OptionalValue< Vector3d > | m_center
DataStructures::OptionalValue< double > | m_volume
DataStructures::OptionalValue< Matrix33d > | m_secondMoment
DataStructures::OptionalValue< Math::Aabbd > | m_localAabb

## Additional Inherited Members

Static Public Member Functions inherited from SurgSim::Framework::FactoryBase< Shape >
static FactoryType & | getFactory ()
Protected Attributes inherited from SurgSim::Math::Shape
Math::Aabbd | m_aabb

## Member Typedef Documentation

## ReadLock

typedef boost::shared_lock<boost::shared_mutex> SurgSim::Math::CompoundShape::ReadLock

private

## SubShape

typedef std::pair<std::shared_ptr<Shape>, RigidTransform3d> SurgSim::Math::CompoundShape::SubShape

## WriteLock

typedef boost::unique_lock<boost::shared_mutex> SurgSim::Math::CompoundShape::WriteLock

private

## Constructor & Destructor Documentation

## CompoundShape()

SurgSim::Math::CompoundShape::CompoundShape | ( |  | ) |

Constructor.

## ~CompoundShape()

SurgSim::Math::CompoundShape::~CompoundShape | ( |  | ) |

Destructor.

## Member Function Documentation

## addShape()

size_t SurgSim::Math::CompoundShape::addShape | ( | const std::shared_ptr< Shape > & | shape,
|  | const RigidTransform3d & | pose = `RigidTransform3d::Identity()`
| ) |  |

Add a shape to this shape, you can optionally supply a pose for the added shape.

Parameters

  shape | to be added
  pose | for the newly added shape

Returns
  the index of the newly added shape

## clearShapes()

void SurgSim::Math::CompoundShape::clearShapes | ( |  | ) |

clears all the enclosed shapes

## getBoundingBox()

const Math::Aabbd & SurgSim::Math::CompoundShape::getBoundingBox | ( |  | ) | const

override virtual

Returns
  the bounding box for the shape

Reimplemented from SurgSim::Math::Shape.

## getCenter()

Vector3d SurgSim::Math::CompoundShape::getCenter | ( |  | ) | const

override virtual

Get the volumetric center of the shape.

Returns
  The center of the shape

Implements SurgSim::Math::Shape.

## getNumShapes()

size_t SurgSim::Math::CompoundShape::getNumShapes | ( |  | ) | const

Returns
  the number of shapes in this shape

## getPose()

RigidTransform3d SurgSim::Math::CompoundShape::getPose | ( | size_t | index | ) | const

Returns
  the pose of a specific shape

Exceptions

  SurgSim::AssertionFailure | if the index exceeds the current number of shapes

## getSecondMomentOfVolume()

Matrix33d SurgSim::Math::CompoundShape::getSecondMomentOfVolume | ( |  | ) | const

override virtual

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

Returns
  The 3x3 symmetric second moment matrix

Implements SurgSim::Math::Shape.

## getShape()

const std::shared_ptr< Shape > & SurgSim::Math::CompoundShape::getShape | ( | size_t | index | ) | const

Returns
  a specific shape

Exceptions

  SurgSim::AssertionFailure | if the index exceeds the current number of shapes

## getShapes()

const std::vector< CompoundShape::SubShape > & SurgSim::Math::CompoundShape::getShapes | ( |  | ) | const

Returns
  all the contained shapes and their respective poses

## getTransformed()

std::shared_ptr< Shape > SurgSim::Math::CompoundShape::getTransformed | ( | const RigidTransform3d & | pose | ) | const

override virtual

Get a copy of this shape with an applied rigid transform.

Parameters

  pose | The pose to transform the shape by

Returns
  the posed shape

Reimplemented from SurgSim::Math::Shape.

## getType()

int SurgSim::Math::CompoundShape::getType | ( |  | ) | const

override virtual

Returns
  the type of shape

Implements SurgSim::Math::Shape.

## getVolume()

double SurgSim::Math::CompoundShape::getVolume | ( |  | ) | const

override virtual

Returns
  the volume of the shape

Note
  that currently this is a very simple sum of all the volumes of the enclosed shapes it will disregard any overlapping shapes.

Implements SurgSim::Math::Shape.

## invalidateData()

void SurgSim::Math::CompoundShape::invalidateData | ( |  | ) |

private

Clears the data for the volume, center and secondMoment and aabb so it can be recalculated when needed again.

## isTransformable()

bool SurgSim::Math::CompoundShape::isTransformable | ( |  | ) | const

override virtual

Returns
  true if the the shape can be transformed

Reimplemented from SurgSim::Math::Shape.

## isValid()

bool SurgSim::Math::CompoundShape::isValid | ( |  | ) | const

override virtual

Check if the shape is valid.

Returns
  True if shape is valid; Otherwise, false.

Implements SurgSim::Math::Shape.

## setPose()

void SurgSim::Math::CompoundShape::setPose | ( | size_t | index,
|  | const RigidTransform3d & | pose
| ) |  |

Set the pose for the specified shape.

Parameters

  index | index of the target shape
  pose | new pose for the indicated shape

Exceptions

  SurgSim::AssertionFailure | if the index exceeds the current number of shapes

## setPoses()

void SurgSim::Math::CompoundShape::setPoses | ( | const std::vector< RigidTransform3d > & | poses | ) |

Sets the poses for all shapes.

Parameters

  poses | array of poses to be copied to each shape

Exceptions

  SurgSimm::AssertialFailure | if the size of poses.size() != getNumShapes()

## setShapes()

void SurgSim::Math::CompoundShape::setShapes | ( | const std::vector< SubShape > & | shapes | ) |

Sets the shapes for this object, the shapes should be a list of shapes together with their respective poses, this will clear all the previously contained shapes.

Parameters

  shapes | list of shapes

## SURGSIM_CLASSNAME()

SurgSim::Math::CompoundShape::SURGSIM_CLASSNAME | ( | SurgSim::Math::CompoundShape |  | ) |

## Member Data Documentation

## m_center

DataStructures::OptionalValue<Vector3d> SurgSim::Math::CompoundShape::m_center

mutable private

Storage for the physical properties of this shape mutable so they can be recalculated inside the const functions getVolume(), getCenter(), getSecondMommentOfVolume()

## m_localAabb

DataStructures::OptionalValue<Math::Aabbd> SurgSim::Math::CompoundShape::m_localAabb

mutable private

Storage for the physical properties of this shape mutable so they can be recalculated inside the const functions getVolume(), getCenter(), getSecondMommentOfVolume()

## m_mutex

boost::shared_mutex SurgSim::Math::CompoundShape::m_mutex

mutable private

## m_secondMoment

DataStructures::OptionalValue<Matrix33d> SurgSim::Math::CompoundShape::m_secondMoment

mutable private

Storage for the physical properties of this shape mutable so they can be recalculated inside the const functions getVolume(), getCenter(), getSecondMommentOfVolume()

## m_shapes

std::vector<SubShape> SurgSim::Math::CompoundShape::m_shapes

private

## m_volume

DataStructures::OptionalValue<double> SurgSim::Math::CompoundShape::m_volume

mutable private

Storage for the physical properties of this shape mutable so they can be recalculated inside the const functions getVolume(), getCenter(), getSecondMommentOfVolume()

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

- SurgSim/Math/CompoundShape.h
- SurgSim/Math/CompoundShape.cpp