DART  6.7.3
dart::dynamics::HeightmapShape< S_ > Class Template Reference

Shape for a height map. More...

#include <HeightmapShape.hpp>

Inheritance diagram for dart::dynamics::HeightmapShape< S_ >:
dart::dynamics::Shape dart::common::Subject dart::common::VersionCounter

Public Types

using S = S_
 
using HeightField = Eigen::Matrix< S, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor >
 
enum  ShapeType {
  SPHERE , BOX , ELLIPSOID , CYLINDER ,
  CAPSULE , CONE , 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

 HeightmapShape ()
 Constructor. More...
 
 ~HeightmapShape () override=default
 Destructor. More...
 
const std::string & getType () const override
 Returns a string representing the shape type. More...
 
Eigen::Matrix3d computeInertia (double mass) const override
 Computes the inertia. More...
 
void setScale (const Eigen::Vector3d &scale)
 Sets scale of this heightmap. More...
 
const Eigen::Vector3d & getScale () const
 Returns scale of this heightmap. More...
 
void setHeightField (const std::size_t &width, const std::size_t &depth, const std::vector< S > &heights)
 Sets the height field. More...
 
const HeightFieldgetHeightField () const
 Returns the height field. More...
 
HeightFieldgetHeightFieldModifiable () const
 Returns the modified height field. See also setHeightField(). More...
 
void flipY () const
 Flips the y values in the height field. More...
 
std::size_t getWidth () const
 Returns the width dimension of the height field. More...
 
std::size_t getDepth () const
 Returns the height dimension of the height field. More...
 
S getMinHeight () const
 Returns the minimum height set by setHeightField() More...
 
S getMaxHeight () const
 Returns the maximum height set by setHeightField() 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...
 
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. More...
 
bool checkDataVariance (DataVariance type) const
 True iff this Shape has the specified type of DataVariance. More...
 
virtual void refreshData ()
 Instruct this shape to update its data. More...
 
virtual void notifyAlphaUpdate (double alpha)
 Notify that the alpha of this shape has updated. More...
 
virtual void notifyAlphaUpdated (double alpha)
 Notify that the alpha of this shape has updated. More...
 
virtual void notifyColorUpdate (const Eigen::Vector4d &color)
 Notify that the color (rgba) of this shape has updated. More...
 
virtual void notifyColorUpdated (const Eigen::Vector4d &color)
 Notify that the color (rgba) of this shape has updated. More...
 
std::size_t incrementVersion () override final
 Increment the version of this Shape and notify its subscribers. More...
 
virtual std::size_t getVersion () const
 Get the version number of this object. More...
 

Static Public Member Functions

static const std::string & getStaticType ()
 Returns shape type for this class. More...
 

Public Attributes

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

Protected Member Functions

void updateBoundingBox () const override
 Updates bounding box. More...
 
void updateVolume () const override
 Updates volume. More...
 
void computeBoundingBox (Eigen::Vector3d &min, Eigen::Vector3d &max) const
 Computes the bounding box of the height field. More...
 
void sendDestructionNotification () const
 Send a destruction notification to all Observers. More...
 
void addObserver (Observer *_observer) const
 Add an Observer to the list of Observers. More...
 
void removeObserver (Observer *_observer) const
 Remove an Observer from the list of Observers. More...
 
void setVersionDependentObject (VersionCounter *dependent)
 

Protected Attributes

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

Static Protected Attributes

static std::atomic_int mCounter { 1000 }
 

Private Attributes

Eigen::Vector3d mScale
 Scale of the heightmap. More...
 
HeightField mHeights
 Height field. More...
 
S mMinHeight
 Minimum heights. More...
 
S mMaxHeight
 Maximum heights. More...
 
VersionChangedSignal mVersionChangedSignal
 Triggered by incrementVersion() More...
 
VersionCountermDependent
 

Detailed Description

template<typename S_>
class dart::dynamics::HeightmapShape< S_ >

Shape for a height map.

Template Parameters
S_Data type used for height map. At this point, only double and float are supported. Short and char can be added at a later point.

Member Typedef Documentation

◆ HeightField

template<typename S_ >
using dart::dynamics::HeightmapShape< S_ >::HeightField = Eigen::Matrix<S, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>

◆ S

template<typename S_ >
using dart::dynamics::HeightmapShape< S_ >::S = S_

◆ VersionChangedSignal

using dart::dynamics::Shape::VersionChangedSignal = common::Signal<void(Shape* shape, std::size_t version)>
inherited

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
STATIC 
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.
Enumerator
SPHERE 
BOX 
ELLIPSOID 
CYLINDER 
CAPSULE 
CONE 
PLANE 
MULTISPHERE 
MESH 
SOFT_MESH 
LINE_SEGMENT 
HEIGHTMAP 
UNSUPPORTED 

Constructor & Destructor Documentation

◆ HeightmapShape()

template<typename S >
dart::dynamics::HeightmapShape< S >::HeightmapShape

Constructor.

◆ ~HeightmapShape()

template<typename S_ >
dart::dynamics::HeightmapShape< S_ >::~HeightmapShape ( )
overridedefault

Destructor.

Member Function Documentation

◆ addDataVariance()

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

Add a type of variance to this shape.

All other variance types will remain the same.

◆ addObserver()

void dart::common::Subject::addObserver ( Observer _observer) const
protectedinherited

Add an Observer to the list of Observers.

◆ checkDataVariance()

bool dart::dynamics::Shape::checkDataVariance ( DataVariance  type) const
inherited

True iff this Shape has the specified type of DataVariance.

◆ computeBoundingBox()

template<typename S >
void dart::dynamics::HeightmapShape< S >::computeBoundingBox ( Eigen::Vector3d &  min,
Eigen::Vector3d &  max 
) const
protected

Computes the bounding box of the height field.

Parameters
[out]minMininum of box
[out]maxMaxinum of box

◆ computeInertia()

template<typename S >
Eigen::Matrix3d dart::dynamics::HeightmapShape< S >::computeInertia ( double  mass) const
overridevirtual

Computes the inertia.

This base class computes the intertia based on the bounding box. Subclasses may choose to provide a more accurate computation of the inertia.

Implements dart::dynamics::Shape.

◆ computeInertiaFromDensity()

Eigen::Matrix3d dart::dynamics::Shape::computeInertiaFromDensity ( double  density) const
inherited

◆ computeInertiaFromMass()

Eigen::Matrix3d dart::dynamics::Shape::computeInertiaFromMass ( double  mass) const
inherited

◆ flipY()

template<typename S >
void dart::dynamics::HeightmapShape< S >::flipY

Flips the y values in the height field.

◆ getBoundingBox()

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

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.

◆ getDataVariance()

unsigned int dart::dynamics::Shape::getDataVariance ( ) const
inherited

Get the data variance of this shape.

◆ getDepth()

template<typename S >
std::size_t dart::dynamics::HeightmapShape< S >::getDepth

Returns the height dimension of the height field.

◆ getHeightField()

template<typename S >
auto dart::dynamics::HeightmapShape< S >::getHeightField

Returns the height field.

◆ getHeightFieldModifiable()

template<typename S >
auto dart::dynamics::HeightmapShape< S >::getHeightFieldModifiable

Returns the modified height field. See also setHeightField().

◆ getID()

std::size_t dart::dynamics::Shape::getID ( ) const
inherited

◆ getMaxHeight()

template<typename S >
auto dart::dynamics::HeightmapShape< S >::getMaxHeight

Returns the maximum height set by setHeightField()

◆ getMinHeight()

template<typename S >
auto dart::dynamics::HeightmapShape< S >::getMinHeight

Returns the minimum height set by setHeightField()

◆ getScale()

template<typename S >
const Eigen::Vector3d & dart::dynamics::HeightmapShape< S >::getScale

Returns scale of this heightmap.

◆ getShapeType()

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

◆ getStaticType()

template<typename S >
const std::string & dart::dynamics::HeightmapShape< S >::getStaticType
static

Returns shape type for this class.

◆ getType()

template<typename S >
const std::string & dart::dynamics::HeightmapShape< S >::getType ( ) const
overridevirtual

Returns a string representing the shape type.

See also
is()

Implements dart::dynamics::Shape.

◆ getVersion()

std::size_t dart::common::VersionCounter::getVersion ( ) const
virtualinherited

Get the version number of this object.

◆ getVolume()

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

Returns volume of this shape.

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

◆ getWidth()

template<typename S >
std::size_t dart::dynamics::HeightmapShape< S >::getWidth

Returns the width dimension of the height field.

◆ incrementVersion()

std::size_t dart::dynamics::Shape::incrementVersion ( )
finaloverridevirtualinherited

Increment the version of this Shape and notify its subscribers.

Reimplemented from dart::common::VersionCounter.

◆ is()

template<typename ShapeT >
bool dart::dynamics::Shape::is
inherited

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()

◆ notifyAlphaUpdate()

void dart::dynamics::Shape::notifyAlphaUpdate ( double  alpha)
virtualinherited

Notify that the alpha of this shape has updated.

◆ notifyAlphaUpdated()

void dart::dynamics::Shape::notifyAlphaUpdated ( double  alpha)
virtualinherited

Notify that the alpha of this shape has updated.

Reimplemented in dart::dynamics::MeshShape.

◆ notifyColorUpdate()

void dart::dynamics::Shape::notifyColorUpdate ( const Eigen::Vector4d &  color)
virtualinherited

Notify that the color (rgba) of this shape has updated.

◆ notifyColorUpdated()

void dart::dynamics::Shape::notifyColorUpdated ( const Eigen::Vector4d &  color)
virtualinherited

Notify that the color (rgba) of this shape has updated.

Reimplemented in dart::dynamics::ArrowShape.

◆ refreshData()

void dart::dynamics::Shape::refreshData ( )
virtualinherited

Instruct this shape to update its data.

◆ removeDataVariance()

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

Remove a type of variance from this shape.

All other variance types will remain the same.

◆ removeObserver()

void dart::common::Subject::removeObserver ( Observer _observer) const
protectedinherited

Remove an Observer from the list of Observers.

◆ sendDestructionNotification()

void dart::common::Subject::sendDestructionNotification ( ) const
protectedinherited

Send a destruction notification to all Observers.

This will cause all Observers to behave as if this Subject has been permanently deleted, so it should only be called when that behavior is desired.

◆ setDataVariance()

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

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.

◆ setHeightField()

template<typename S >
void dart::dynamics::HeightmapShape< S >::setHeightField ( const std::size_t &  width,
const std::size_t &  depth,
const std::vector< S > &  heights 
)

Sets the height field.

The data in heights will be copied locally. It would be nice to have the option to use the values in heights directly instead of copying them locally to a vector in this class (this would avoid any data being kept twice). However some collision engine implementations may require to transform the height values, e.g. bullet needs the y values flipped. Therefore, a (mutable) copy of the height values passed in heights will be kept in this class. The copied data can be modified via getHeightFieldModifiable() and with flipY().

Parameters
[in]widthWidth of the field (x axis)
[in]depthDepth of the field (-y axis)
[in]heightsThe height data of size width * depth. The heights are interpreted as z values, while width goes in x direction and depth in -y (it goes to -y because traditionally images are read from top row to bottom row). In the geometry which is to be generated from this shape, the min/max height value is also the min/max z value (so if the minimum height value is -100, the lowest terrain point will be -100, times the z scale to be applied).

◆ setScale()

template<typename S >
void dart::dynamics::HeightmapShape< S >::setScale ( const Eigen::Vector3d &  scale)

Sets scale of this heightmap.

Parameters
[in]scaleScale of the height map.

◆ setVersionDependentObject()

void dart::common::VersionCounter::setVersionDependentObject ( VersionCounter dependent)
protectedinherited

◆ updateBoundingBox()

template<typename S >
void dart::dynamics::HeightmapShape< S >::updateBoundingBox ( ) const
overrideprotectedvirtual

Updates bounding box.

Implements dart::dynamics::Shape.

◆ updateVolume()

template<typename S >
void dart::dynamics::HeightmapShape< S >::updateVolume
overrideprotectedvirtual

Updates volume.

This base class provides a simple implementation which returns the volume of the bounding box. Subclasses may opt to provide a more accurate computation of the volume.

Implements dart::dynamics::Shape.

Member Data Documentation

◆ mBoundingBox

math::BoundingBox dart::dynamics::Shape::mBoundingBox
mutableprotectedinherited

The bounding box (in the local coordinate frame) of the shape.

◆ mCounter

std::atomic_int dart::dynamics::Shape::mCounter { 1000 }
staticprotectedinherited

◆ mDependent

VersionCounter* dart::common::VersionCounter::mDependent
privateinherited

◆ mHeights

template<typename S_ >
HeightField dart::dynamics::HeightmapShape< S_ >::mHeights
mutableprivate

Height field.

◆ mID

const std::size_t dart::dynamics::Shape::mID
protectedinherited

Unique id.

◆ mIsBoundingBoxDirty

bool dart::dynamics::Shape::mIsBoundingBoxDirty
mutableprotectedinherited

Whether bounding box needs update.

◆ mIsVolumeDirty

bool dart::dynamics::Shape::mIsVolumeDirty
mutableprotectedinherited

Whether volume needs update.

◆ mMaxHeight

template<typename S_ >
S dart::dynamics::HeightmapShape< S_ >::mMaxHeight
private

Maximum heights.

Is computed each time the height field is set with setHeightField().

◆ mMinHeight

template<typename S_ >
S dart::dynamics::HeightmapShape< S_ >::mMinHeight
private

Minimum heights.

Is computed each time the height field is set with setHeightField().

◆ mObservers

std::set<Observer*> dart::common::Subject::mObservers
mutableprotectedinherited

List of current Observers.

◆ mScale

template<typename S_ >
Eigen::Vector3d dart::dynamics::HeightmapShape< S_ >::mScale
private

Scale of the heightmap.

◆ mType

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

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

◆ mVariance

unsigned int dart::dynamics::Shape::mVariance
protectedinherited

The DataVariance of this Shape.

◆ mVersion

std::size_t dart::common::VersionCounter::mVersion
protectedinherited

◆ mVersionChangedSignal

VersionChangedSignal dart::dynamics::Shape::mVersionChangedSignal
privateinherited

Triggered by incrementVersion()

◆ mVolume

double dart::dynamics::Shape::mVolume
mutableprotectedinherited

Volume enclosed by the geometry.

◆ onVersionChanged

common::SlotRegister<VersionChangedSignal> dart::dynamics::Shape::onVersionChanged
inherited

Use this to subscribe to version change signals.