DART  6.6.2
dart::dynamics::LineSegmentShape Class Reference

The LineSegmentShape facilitates creating graphs of line segments. More...

#include <LineSegmentShape.hpp>

Inheritance diagram for dart::dynamics::LineSegmentShape:
dart::dynamics::Shape dart::common::Subject

Public Types

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...
 

Public Member Functions

 LineSegmentShape (float _thickness=1.0f)
 Default constructor. More...
 
 LineSegmentShape (const Eigen::Vector3d &_v1, const Eigen::Vector3d &_v2, float _thickness=1.0f)
 Constructor for creating a simple line segment that connects two vertices. More...
 
const std::string & getType () const override
 Returns a string representing the shape type. More...
 
void setThickness (float _thickness)
 Set the line thickness/width for rendering. More...
 
float getThickness () const
 Get the line thickness/width used for rendering. More...
 
std::size_t addVertex (const Eigen::Vector3d &_v)
 Add a vertex as a child to the last vertex that was added. More...
 
std::size_t addVertex (const Eigen::Vector3d &_v, std::size_t _parent)
 Add a vertex as a child to the specified vertex. More...
 
void removeVertex (std::size_t _idx)
 Remove a vertex from the list of vertices. More...
 
void setVertex (std::size_t _idx, const Eigen::Vector3d &_v)
 Change the location of the specified vertex. More...
 
const Eigen::Vector3d & getVertex (std::size_t _idx) const
 Get the location of the specified vertex. More...
 
const std::vector< Eigen::Vector3d > & getVertices () const
 Get all the vertices. More...
 
void addConnection (std::size_t _idx1, std::size_t _idx2)
 Create a connection between the two specified vertices. More...
 
void removeConnection (std::size_t _vertexIdx1, std::size_t _vertexIdx2)
 Search for a connection between two vertices and break it if it exists. More...
 
void removeConnection (std::size_t _connectionIdx)
 Remove the specified connection entry. More...
 
const common::aligned_vector< Eigen::Vector2i > & getConnections () const
 Get all the connections. More...
 
Eigen::Matrix3d computeInertia (double mass) const override
 The returned inertia matrix will be like a very thin cylinder. 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...
 
int 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...
 

Static Public Member Functions

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

Protected Member Functions

void updateBoundingBox () const override
 Updates bounding box. More...
 
void updateVolume () const override
 Updates volume. 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...
 

Protected Attributes

float mThickness
 Line thickness for rendering. More...
 
std::vector< Eigen::Vector3d > mVertices
 Vector of vertices. More...
 
common::aligned_vector< Eigen::Vector2i > mConnections
 Vector of connections. More...
 
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...
 
int mID
 Unique id. More...
 
unsigned int mVariance
 The DataVariance of this Shape. More...
 
ShapeType mType
 
std::set< Observer * > mObservers
 List of current Observers. More...
 

Static Protected Attributes

static const Eigen::Vector3d mDummyVertex = Eigen::Vector3d::Zero()
 A dummy vertex that can be returned when an out-of-bounds vertex is requested. More...
 
static int mCounter = 1000
 

Detailed Description

The LineSegmentShape facilitates creating graphs of line segments.

The graph can consist of a single line segment or many interconnected line segments. Note: LineSegmentShape may NOT be used as a collision shape for BodyNodes, but it may be used for visualization purposes.

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

◆ LineSegmentShape() [1/2]

dart::dynamics::LineSegmentShape::LineSegmentShape ( float  _thickness = 1.0f)

Default constructor.

◆ LineSegmentShape() [2/2]

dart::dynamics::LineSegmentShape::LineSegmentShape ( const Eigen::Vector3d &  _v1,
const Eigen::Vector3d &  _v2,
float  _thickness = 1.0f 
)

Constructor for creating a simple line segment that connects two vertices.

Member Function Documentation

◆ addConnection()

void dart::dynamics::LineSegmentShape::addConnection ( std::size_t  _idx1,
std::size_t  _idx2 
)

Create a connection between the two specified vertices.

◆ 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.

◆ addVertex() [1/2]

std::size_t dart::dynamics::LineSegmentShape::addVertex ( const Eigen::Vector3d &  _v)

Add a vertex as a child to the last vertex that was added.

◆ addVertex() [2/2]

std::size_t dart::dynamics::LineSegmentShape::addVertex ( const Eigen::Vector3d &  _v,
std::size_t  _parent 
)

Add a vertex as a child to the specified vertex.

◆ checkDataVariance()

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

True iff this Shape has the specified type of DataVariance.

◆ computeInertia()

Eigen::Matrix3d dart::dynamics::LineSegmentShape::computeInertia ( double  mass) const
overridevirtual

The returned inertia matrix will be like a very thin cylinder.

The _mass will be evenly distributed across all lines.

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

◆ 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.

◆ getConnections()

const common::aligned_vector< Eigen::Vector2i > & dart::dynamics::LineSegmentShape::getConnections ( ) const

Get all the connections.

◆ getDataVariance()

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

Get the data variance of this shape.

◆ getID()

int dart::dynamics::Shape::getID ( ) const
inherited

◆ getShapeType()

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

◆ getStaticType()

const std::string & dart::dynamics::LineSegmentShape::getStaticType ( )
static

Returns shape type for this class.

◆ getThickness()

float dart::dynamics::LineSegmentShape::getThickness ( ) const

Get the line thickness/width used for rendering.

◆ getType()

const std::string & dart::dynamics::LineSegmentShape::getType ( ) const
overridevirtual

Returns a string representing the shape type.

See also
is()

Implements dart::dynamics::Shape.

◆ getVertex()

const Eigen::Vector3d & dart::dynamics::LineSegmentShape::getVertex ( std::size_t  _idx) const

Get the location of the specified vertex.

Returns a zero vector if an out-of-bounds vertex is requested.

◆ getVertices()

const std::vector< Eigen::Vector3d > & dart::dynamics::LineSegmentShape::getVertices ( ) const

Get all the vertices.

◆ 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.

◆ 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.

◆ removeConnection() [1/2]

void dart::dynamics::LineSegmentShape::removeConnection ( std::size_t  _connectionIdx)

Remove the specified connection entry.

Note that this will impact the indices of all connections that come after _connectionIdx. This is more efficient but less robust than removeConnection(std::size_t,std::size_t)

◆ removeConnection() [2/2]

void dart::dynamics::LineSegmentShape::removeConnection ( std::size_t  _vertexIdx1,
std::size_t  _vertexIdx2 
)

Search for a connection between two vertices and break it if it exists.

This is less efficient but more robust than removeConnection(std::size_t).

◆ 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.

◆ removeVertex()

void dart::dynamics::LineSegmentShape::removeVertex ( std::size_t  _idx)

Remove a vertex from the list of vertices.

IMPORTANT: Note that this alters the indices of all vertices that follow it in the list, which also clobbers the validity of the list of connections for all those vertices. A safer and more efficient method might be to recycle vertices by moving them around with setVertex() and/or altering their connections.

◆ 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.

◆ setThickness()

void dart::dynamics::LineSegmentShape::setThickness ( float  _thickness)

Set the line thickness/width for rendering.

◆ setVertex()

void dart::dynamics::LineSegmentShape::setVertex ( std::size_t  _idx,
const Eigen::Vector3d &  _v 
)

Change the location of the specified vertex.

◆ updateBoundingBox()

void dart::dynamics::LineSegmentShape::updateBoundingBox ( ) const
overrideprotectedvirtual

Updates bounding box.

Implements dart::dynamics::Shape.

◆ updateVolume()

void dart::dynamics::LineSegmentShape::updateVolume ( ) const
overrideprotectedvirtual

Updates 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.

◆ mConnections

common::aligned_vector<Eigen::Vector2i> dart::dynamics::LineSegmentShape::mConnections
protected

Vector of connections.

◆ mCounter

int dart::dynamics::Shape::mCounter = 1000
staticprotectedinherited

◆ mDummyVertex

const Eigen::Vector3d dart::dynamics::LineSegmentShape::mDummyVertex = Eigen::Vector3d::Zero()
staticprotected

A dummy vertex that can be returned when an out-of-bounds vertex is requested.

◆ mID

int 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.

◆ mObservers

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

List of current Observers.

◆ mThickness

float dart::dynamics::LineSegmentShape::mThickness
protected

Line thickness for rendering.

◆ 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.

◆ mVertices

std::vector<Eigen::Vector3d> dart::dynamics::LineSegmentShape::mVertices
protected

Vector of vertices.

◆ mVolume

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

Volume enclosed by the geometry.