dart
Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
dart::dynamics::Shape Class Referenceabstract
Inheritance diagram for dart::dynamics::Shape:
Inheritance graph
[legend]
Collaboration diagram for dart::dynamics::Shape:
Collaboration graph
[legend]

Public Types

enum  ShapeType {
  SPHERE, BOX, ELLIPSOID, CYLINDER,
  CAPSULE, CONE, PYRAMID, RECTANGULAR_PYRAMID,
  PLANE, MULTISPHERE, MESH, SOFT_MESH,
  LINE_SEGMENT, HEIGHTMAP, UNSUPPORTED
}
 
enum  DataVariance {
  STATIC = 0, DYNAMIC_TRANSFORM = 1 << 1, DYNAMIC_PRIMITIVE = 1 << 2, DYNAMIC_COLOR = 1 << 3,
  DYNAMIC_VERTICES = 1 << 4, DYNAMIC_ELEMENTS = 1 << 5, DYNAMIC = 0xFF
}
 DataVariance can be used by renderers to determine whether it should expect data for this shape to change during each update. More...
 
using VersionChangedSignal = common::Signal< void(Shape *shape, std::size_t version)>
 

Public Member Functions

 Shape (ShapeType _type)
 Constructor. More...
 
 Shape ()
 Constructor.
 
virtual ~Shape ()
 Destructor.
 
virtual const std::string & getType () const =0
 Returns a string representing the shape type. More...
 
template<typename ShapeT >
bool is () const
 Get true if the types of this Shape and the template parameter (a shape class) are identical. More...
 
const math::BoundingBoxgetBoundingBox () const
 Get the bounding box of the shape in its local coordinate frame. More...
 
virtual Eigen::Matrix3d computeInertia (double mass) const =0
 Computes the inertia.
 
Eigen::Matrix3d computeInertiaFromDensity (double density) const
 
Eigen::Matrix3d computeInertiaFromMass (double mass) const
 
double getVolume () const
 Returns volume of this shape. More...
 
std::size_t getID () const
 
ShapeType getShapeType () const
 
void setDataVariance (unsigned int _variance)
 Set the data variance of this shape. More...
 
void addDataVariance (unsigned int _variance)
 Add a type of variance to this shape. More...
 
void removeDataVariance (unsigned int _variance)
 Remove a type of variance from this shape. More...
 
unsigned int getDataVariance () const
 Get the data variance of this shape.
 
bool checkDataVariance (DataVariance type) const
 True iff this Shape has the specified type of DataVariance.
 
virtual void refreshData ()
 Instruct this shape to update its data.
 
virtual void notifyAlphaUpdate (double alpha)
 Notify that the alpha of this shape has updated.
 
virtual void notifyAlphaUpdated (double alpha)
 Notify that the alpha of this shape has updated.
 
virtual void notifyColorUpdate (const Eigen::Vector4d &color)
 Notify that the color (rgba) of this shape has updated.
 
virtual void notifyColorUpdated (const Eigen::Vector4d &color)
 Notify that the color (rgba) of this shape has updated.
 
std::size_t incrementVersion () override final
 Increment the version of this Shape and notify its subscribers.
 
- Public Member Functions inherited from dart::common::Subject
virtual ~Subject ()
 Destructor will notify all Observers that it is destructing.
 
- Public Member Functions inherited from dart::common::VersionCounter
 VersionCounter ()
 Default constructor.
 
virtual std::size_t getVersion () const
 Get the version number of this object.
 

Public Attributes

common::SlotRegister< VersionChangedSignalonVersionChanged
 Use this to subscribe to version change signals.
 

Protected Member Functions

virtual void updateVolume () const =0
 Updates volume.
 
virtual void updateBoundingBox () const =0
 Updates bounding box.
 
- Protected Member Functions inherited from dart::common::Subject
void sendDestructionNotification () const
 Send a destruction notification to all Observers. More...
 
void addObserver (Observer *_observer) const
 Add an Observer to the list of Observers.
 
void removeObserver (Observer *_observer) const
 Remove an Observer from the list of Observers.
 
- Protected Member Functions inherited from dart::common::VersionCounter
void setVersionDependentObject (VersionCounter *dependent)
 

Protected Attributes

math::BoundingBox mBoundingBox
 The bounding box (in the local coordinate frame) of the shape.
 
bool mIsBoundingBoxDirty
 Whether bounding box needs update.
 
double mVolume
 Volume enclosed by the geometry.
 
bool mIsVolumeDirty
 Whether volume needs update.
 
const std::size_t mID
 Unique id.
 
unsigned int mVariance
 The DataVariance of this Shape.
 
ShapeType mType
 
- Protected Attributes inherited from dart::common::Subject
std::set< Observer * > mObservers
 List of current Observers.
 
- Protected Attributes inherited from dart::common::VersionCounter
std::size_t mVersion
 

Static Protected Attributes

static std::atomic_int mCounter {PRIMITIVE_MAGIC_NUMBER}
 

Member Enumeration Documentation

◆ DataVariance

DataVariance can be used by renderers to determine whether it should expect data for this shape to change during each update.

Enumerator
DYNAMIC_TRANSFORM 

No data will ever change.

DYNAMIC_PRIMITIVE 

The relative transform of the Shape might change.

DYNAMIC_COLOR 

The primitive properties (such as x/y/z scaling) of the shape might change.

DYNAMIC_VERTICES 

The coloring or textures of the shape might change.

DYNAMIC_ELEMENTS 

Vertex positions of a mesh might change (this does not include adding or removing vertices) (this enum is not relevant for primitive shapes)

DYNAMIC 

The number of elements and/or arrangement of elements might change (this includes adding and removing vertices) (this enum is not relevant for primitive shapes)

◆ ShapeType

Deprecated:
Deprecated in 6.1. Please use getType() instead.

Constructor & Destructor Documentation

◆ Shape()

dart::dynamics::Shape::Shape ( ShapeType  _type)
explicit

Constructor.

Deprecated:
Deprecated in 6.1.

Please use getType() instead.

Member Function Documentation

◆ addDataVariance()

void dart::dynamics::Shape::addDataVariance ( unsigned int  _variance)

Add a type of variance to this shape.

All other variance types will remain the same.

◆ getBoundingBox()

const math::BoundingBox & dart::dynamics::Shape::getBoundingBox ( ) const

Get the bounding box of the shape in its local coordinate frame.

The dimension will be automatically determined by the sub-classes such as BoxShape, EllipsoidShape, CylinderShape, and MeshShape.

◆ getShapeType()

Shape::ShapeType dart::dynamics::Shape::getShapeType ( ) const
Deprecated:
Deprecated in 6.1. Please use getType() instead.

◆ getType()

virtual const std::string& dart::dynamics::Shape::getType ( ) const
pure virtual

◆ getVolume()

double dart::dynamics::Shape::getVolume ( ) const

Returns volume of this shape.

The volume will be automatically calculated by the sub-classes such as BoxShape, EllipsoidShape, CylinderShape, and MeshShape.

◆ is()

template<typename ShapeT >
bool dart::dynamics::Shape::is ( ) const

Get true if the types of this Shape and the template parameter (a shape class) are identical.

This function is a syntactic sugar, which is identical to: (getType() == ShapeType::getStaticType()).

Example code:

auto shape = bodyNode->getShapeNode(0)->getShape();
if (shape->is<BoxShape>())
std::cout << "The shape type is box!\n";
See also
getType()

◆ removeDataVariance()

void dart::dynamics::Shape::removeDataVariance ( unsigned int  _variance)

Remove a type of variance from this shape.

All other variance types will remain the same.

◆ setDataVariance()

void dart::dynamics::Shape::setDataVariance ( unsigned int  _variance)

Set the data variance of this shape.

Use the DataVariance to indicate what kind of shape information might change during run time so that renderers can optimize reliably.

Member Data Documentation

◆ mType

ShapeType dart::dynamics::Shape::mType
protected
Deprecated:
Deprecated in 6.1.

Please use getType() instead. Type of primitive shpae.


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