Simbody  3.5
SimTK::DecorativeGeometry Class Reference

This is the client-side interface to an implementation-independent representation of "Decorations" suitable for visualization, annotation, logging, or debugging but which cannot have any effect on the behavior of a System or the evolution of a Study. More...

+ Inheritance diagram for SimTK::DecorativeGeometry:

Public Types

enum  Representation {
  DrawPoints = 1,
  DrawWireframe = 2,
  DrawSurface = 3,
  DrawDefault = -1
}
 Drawing modes. More...
 

Public Member Functions

 DecorativeGeometry ()
 Default constructor creates an empty handle. More...
 
 ~DecorativeGeometry ()
 
 DecorativeGeometry (const DecorativeGeometry &source)
 Copy construction is deep; the source object will be cloned to create an independent copy. More...
 
DecorativeGeometryoperator= (const DecorativeGeometry &source)
 Copy assignment is deep; the handle will be cleared if necessary and then the source object will be cloned to create an independent copy. More...
 
DecorativeGeometrysetBodyId (int bodyId)
 By default the geometry should be placed relative to the Ground frame. More...
 
DecorativeGeometrysetIndexOnBody (int index)
 For selection or other purposes, you may want to use this method to store an index that can identify this particular piece of geometry. More...
 
DecorativeGeometrysetUserRef (void *userRef)
 Use this method to store an arbitrary reference pointer with this DecorativeGeometry object. More...
 
DecorativeGeometrysetTransform (const Transform &X_BG)
 This transform shifts the generated polygons with respect to this object's local frame. More...
 
DecorativeGeometrysetResolution (Real)
 Each concrete DecorativeGeometry object is expected to have a default resolution that gets the point across but is cheap to draw and hence probably somewhat "chunky". More...
 
DecorativeGeometrysetScaleFactors (const Vec3 &scale)
 Each concrete DecorativeGeometry object is expected to have a default size around "1", whatever that means for a particular object, and most objects also allow a user-specified size on construction. More...
 
DecorativeGeometrysetScale (Real scale)
 Convenience method to set all three scale factors to the same value. More...
 
int getBodyId () const
 Return the bodyId that was supplied to the most recent setBodyId() call for this DecorativeGeometry object, or zero if that method has not been called. More...
 
int getIndexOnBody () const
 Return the index that was supplied to the most recent setIndexOnBody() call for this DecorativeGeometry object, or -1 if that method has not been called. More...
 
void * getUserRef () const
 Return the pointer value that was supplied to the most recent setUserRef() call for this DecorativeGeometry object, or zero (nullptr) if that method has not been called. More...
 
Real getResolution () const
 Return the current setting of the "resolution" factor. More...
 
const TransformgetTransform () const
 Return the current value of the object's transform. More...
 
const Vec3getScaleFactors () const
 Return the current setting of the "scale" factors. More...
 
DecorativeGeometrysetColor (const Vec3 &rgb)
 Request a specific color for this DecorativeGeometry object. More...
 
DecorativeGeometrysetOpacity (Real)
 Request a level of transparency for this DecorativeGeometry. More...
 
DecorativeGeometrysetLineThickness (Real)
 Request an adjustment to the default rendering of lines and curves. More...
 
const Vec3getColor () const
 Return the color specified for this object, if any, otherwise Vec3(-1) indicating that the default color will be used. More...
 
Real getOpacity () const
 Return the opacity specified for this object. More...
 
Real getLineThickness () const
 Return the line thickness specified for this object, if any, otherwise return -1 to indicate that the default line thickness should be used. More...
 
DecorativeGeometrysetFaceCamera (int shouldFace)
 Set whether the geometry acts as a billboard, always rotating to face the camera. More...
 
int getFaceCamera () const
 Get whether the geometry acts as a billboard, always rotating to face the camera. More...
 
DecorativeGeometrysetRepresentation (const Representation &)
 Request a particular rendering representation of this DecorativeGeometry object. More...
 
Representation getRepresentation () const
 Returns drawing mode: -1 means "use default"; see above for others. More...
 
void implementGeometry (DecorativeGeometryImplementation &) const
 
bool isOwnerHandle () const
 
bool isEmptyHandle () const
 
 DecorativeGeometry (class DecorativeGeometryRep *r)
 
bool hasRep () const
 
const DecorativeGeometryRep & getRep () const
 
DecorativeGeometryRep & updRep ()
 

Protected Attributes

DecorativeGeometryRep * rep
 

Detailed Description

This is the client-side interface to an implementation-independent representation of "Decorations" suitable for visualization, annotation, logging, or debugging but which cannot have any effect on the behavior of a System or the evolution of a Study.

DO NOT confuse this with real geometry (like contact geometry) which can represent physically meaningful objects that may interact and change the behavior of a System. However, all geometry objects can generate DecorativeGeometry for their visualization.

Why is there a DecorativeGeometry facility at the System level at all, so far away from any application program? That's because for crude visualization and debugging purposes, the Subsystems themselves are best able to produce some illustrative geometry. Otherwise, you need a special purpose visualization tool which understands what's going on inside each subsystem. If you don't mind taking what you get, just ask each subsystem to generate what it thinks would be helpful visualization. To do that, the subysystems need a way to talk about geometry without knowing anything about how that geometry will eventually get onto someone's screen. And that's why we're here!

Each DecorativeGeometry object has its own local coordinate system and is defined self-consistently but independent of anything else. Clients can associate these with a reference frame (e.g. a body), and place the local frame of the geometry objects on the reference frame, or at a fixed transform from the reference frame. That places the DecorativeGeometry objects in a scene. We support both 3D objects which are attached to actors in the scene, and 2D "screen" objects like titles which are attached to the display rather than the actors. The classes here deal only with the local-frame definitions of the geometric objects, not their placement in the scene.

This is an abstract handle class using the PIMPL design pattern to hide the private implementation. This is effectively an abstract class although the virtual function table is hidden in the private part.

Member Enumeration Documentation

Drawing modes.

Enumerator
DrawPoints 

Use a cloud of points.

DrawWireframe 

Use a line drawing.

DrawSurface 

Use a shaded surface.

DrawDefault 

Let someone else decide.

Constructor & Destructor Documentation

SimTK::DecorativeGeometry::DecorativeGeometry ( )
inline

Default constructor creates an empty handle.

SimTK::DecorativeGeometry::~DecorativeGeometry ( )
SimTK::DecorativeGeometry::DecorativeGeometry ( const DecorativeGeometry source)

Copy construction is deep; the source object will be cloned to create an independent copy.

SimTK::DecorativeGeometry::DecorativeGeometry ( class DecorativeGeometryRep *  r)
inlineexplicit

Member Function Documentation

DecorativeGeometry& SimTK::DecorativeGeometry::operator= ( const DecorativeGeometry source)

Copy assignment is deep; the handle will be cleared if necessary and then the source object will be cloned to create an independent copy.

DecorativeGeometry& SimTK::DecorativeGeometry::setBodyId ( int  bodyId)

By default the geometry should be placed relative to the Ground frame.

If you want it attached to another reference frame (body), say so here. The geometry should be rendered with respect to the indicated body frame; however, the interpretation of this integer Id is left to the implementation. If you don't set the bodyId yourself it will be zero. For use in Simbody, the bodyId is interpreted as a MobilizedBodyIndex that can be mapped to a MobilizedBody that carries a reference frame.

The bodyId is copied if you copy the DecorativeGeometry object. If you are copying to a different body you'll need to change the bodyId afterwards.

DecorativeGeometry& SimTK::DecorativeGeometry::setIndexOnBody ( int  index)

For selection or other purposes, you may want to use this method to store an index that can identify this particular piece of geometry.

As an alternative, or addition, see setUserRef(). In any case the index is simply stored with the object and returned if you ask for it. If you don't set it the value is -1. The index is copied if you copy the DecorativeGeometry object. Be sure to change it afterwards if that is not the correct index for the copy.

DecorativeGeometry& SimTK::DecorativeGeometry::setUserRef ( void *  userRef)

Use this method to store an arbitrary reference pointer with this DecorativeGeometry object.

This is particularly useful in selection operations where the rendering of this object has been picked by a user and you want to map it back to some meaningful object in your model. You can also use the setIndexOnBody() method to store some additional identifying information. If you don't set this pointer it will be set to zero (nullptr). This value is stored and returned only; no interpretation is done and the pointed-to object will not be deleted when the DecorativeGeometry object is deleted.

Warning
The value of the userRef pointer is copied if you make a copy of the DecorativeGeometry object. That is likely to be incorrect in many circumstances, depending on how you are using this value. Be sure to clear or change the pointer if necessary after you make a copy.
DecorativeGeometry& SimTK::DecorativeGeometry::setTransform ( const Transform X_BG)

This transform shifts the generated polygons with respect to this object's local frame.

Subsequent calls with other transforms simply replace the earlier one; they do not accumulate. The default transform is identity and you can call setTransform(Transform()) to put the transform back into its original state. This value affects the generated polygonal data.

DecorativeGeometry& SimTK::DecorativeGeometry::setResolution ( Real  )

Each concrete DecorativeGeometry object is expected to have a default resolution that gets the point across but is cheap to draw and hence probably somewhat "chunky".

The resolution parameter here scales that default up or down. The face density in the displayed representation is roughly proportional to this value. 1.0 means to use the default resolution. Values less than 1.0 are lower resolution, and values greater than 1.0 are higher resolution. A value less than or equal to zero here is interpreted as an instruction to "use the default".

DecorativeGeometry& SimTK::DecorativeGeometry::setScaleFactors ( const Vec3 scale)

Each concrete DecorativeGeometry object is expected to have a default size around "1", whatever that means for a particular object, and most objects also allow a user-specified size on construction.

The x,y,z scale factors here are given in the object's coordinate frame, and apply to the object as the user built it, or to the default if the user didn't specify a size. The default scaling is 1,1,1 and any value less than or equal to zero here is interpreted as a request to "use the default" in that direction.

DecorativeGeometry& SimTK::DecorativeGeometry::setScale ( Real  scale)
inline

Convenience method to set all three scale factors to the same value.

int SimTK::DecorativeGeometry::getBodyId ( ) const

Return the bodyId that was supplied to the most recent setBodyId() call for this DecorativeGeometry object, or zero if that method has not been called.

Copy construction and copy assignment copy the bodyId. This is intended to identify the body frame to which this geometry's placement should be relative; with the default zero value meaning the Ground or World frame.

int SimTK::DecorativeGeometry::getIndexOnBody ( ) const

Return the index that was supplied to the most recent setIndexOnBody() call for this DecorativeGeometry object, or -1 if that method has not been called.

Copy construction and copy assignment copy the index. Interpretation of this integer is up to the caller.

void* SimTK::DecorativeGeometry::getUserRef ( ) const

Return the pointer value that was supplied to the most recent setUserRef() call for this DecorativeGeometry object, or zero (nullptr) if that method has not been called.

Copy construction and copy assignment copy the pointer. Interpretation of this value is up to the caller.

Real SimTK::DecorativeGeometry::getResolution ( ) const

Return the current setting of the "resolution" factor.

A return value of -1 means "use the default".

const Transform& SimTK::DecorativeGeometry::getTransform ( ) const

Return the current value of the object's transform.

If none has been set this will be the identity transform. Note that this transform specifies how the polygons are placed with respect to the object's local frame.

const Vec3& SimTK::DecorativeGeometry::getScaleFactors ( ) const

Return the current setting of the "scale" factors.

A return value of -1 in one of the factors means to "use the default" (which is typically 1) in that direction.

DecorativeGeometry& SimTK::DecorativeGeometry::setColor ( const Vec3 rgb)

Request a specific color for this DecorativeGeometry object.

The default is that the color is determined elsewhere. To explicitly request the default, set the color to Vec3(-1). The implementation will check the 0'th element (that is, the "R" element) and if it is less than zero will ignore the other two elements and use the default for all three.

DecorativeGeometry& SimTK::DecorativeGeometry::setOpacity ( Real  )

Request a level of transparency for this DecorativeGeometry.

This does NOT affect the generated geometry here. The default is that opacity is determined elsewhere.

DecorativeGeometry& SimTK::DecorativeGeometry::setLineThickness ( Real  )

Request an adjustment to the default rendering of lines and curves.

This does NOT affect geometry generated here; it is a request passed on to the renderer which will probably pass it on to the hardware. A value less than or equal to zero here is interpreted as "use the default".

const Vec3& SimTK::DecorativeGeometry::getColor ( ) const

Return the color specified for this object, if any, otherwise Vec3(-1) indicating that the default color will be used.

Real SimTK::DecorativeGeometry::getOpacity ( ) const

Return the opacity specified for this object.

Real SimTK::DecorativeGeometry::getLineThickness ( ) const

Return the line thickness specified for this object, if any, otherwise return -1 to indicate that the default line thickness should be used.

DecorativeGeometry& SimTK::DecorativeGeometry::setFaceCamera ( int  shouldFace)

Set whether the geometry acts as a billboard, always rotating to face the camera.

The default is typically no except for text. If you want 3D text that moves with your model, set this to false. Here 0 means false, 1 means true, and -1 means "use default".

int SimTK::DecorativeGeometry::getFaceCamera ( ) const

Get whether the geometry acts as a billboard, always rotating to face the camera.

Returns 0 for no, 1 for yes, -1 for "is using default".

DecorativeGeometry& SimTK::DecorativeGeometry::setRepresentation ( const Representation )

Request a particular rendering representation of this DecorativeGeometry object.

The default is that the rendering representation choice is made elsewhere.

Representation SimTK::DecorativeGeometry::getRepresentation ( ) const

Returns drawing mode: -1 means "use default"; see above for others.

void SimTK::DecorativeGeometry::implementGeometry ( DecorativeGeometryImplementation ) const
bool SimTK::DecorativeGeometry::isOwnerHandle ( ) const
bool SimTK::DecorativeGeometry::isEmptyHandle ( ) const
bool SimTK::DecorativeGeometry::hasRep ( ) const
inline
const DecorativeGeometryRep& SimTK::DecorativeGeometry::getRep ( ) const
inline
DecorativeGeometryRep& SimTK::DecorativeGeometry::updRep ( )
inline

Member Data Documentation

DecorativeGeometryRep* SimTK::DecorativeGeometry::rep
protected

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