Simbody  3.5
SimTK::ContactSnapshot Class Reference

Objects of this class represent collections of surface-pair interactions that are being tracked at a particular instant during a simulation. More...

Public Member Functions

 ContactSnapshot ()
 Default constructor sets timestamp to NaN. More...
 
void clear ()
 Restore to default-constructed condition. More...
 
void setTimestamp (Real time)
 Set the time at which this snapshot was taken. More...
 
Real getTimestamp () const
 At what simulation time was this contact snapshot taken? More...
 
void adoptContact (Contact &contact)
 Add this Contact object to this snapshot; this is a shallow, reference-counted copy so the Contact object is not duplicated. More...
 
bool hasContact (ContactId id) const
 Does this snapshot contain a Contact object with the given ContactId? More...
 
bool hasContact (ContactSurfaceIndex surf1, ContactSurfaceIndex surf2) const
 Does this snapshot contain a Contact object for the given surface pair (in either order)? More...
 
int getNumContacts () const
 Find out how many Contacts are in this snapshot. More...
 
const ContactgetContact (int n) const
 Get a reference to the n'th Contact in this snapshot; note that the position of a given Contact in this array is not guaranteed to remain unchanged when Contacts are removed from this snapshot. More...
 
const ContactgetContactById (ContactId id) const
 If this snapshot contains a contact with the given id, return a reference to it; otherwise, return a reference to an empty contact handle (you can check with isEmpty()). More...
 
ContactId getContactIdForSurfacePair (ContactSurfaceIndex surf1, ContactSurfaceIndex surf2) const
 If this snapshot contains a contact for the given pair of contact surfaces (order doesn't matter), return its ContactId; otherwise, return an invalid ContactId (you can check with isValid()). More...
 

Detailed Description

Objects of this class represent collections of surface-pair interactions that are being tracked at a particular instant during a simulation.

These are suitable for use as state variables for remembering past contact status and as calculated cache entries containing the current contact status. Each tracked surface pair has an integer ContactId that is persistent for as long as a particular interaction is being tracked. We maintain a map providing very fast access to individual Contact entries by ContactId. There is also a map from ContactSurfaceIndex pairs to ContactId that can be used to see whether we are already tracking a Contact between those surfaces; there can be at most one Contact between a given surface pair at any given moment.

Constructor & Destructor Documentation

SimTK::ContactSnapshot::ContactSnapshot ( )
inline

Default constructor sets timestamp to NaN.

Member Function Documentation

void SimTK::ContactSnapshot::clear ( )
inline

Restore to default-constructed condition.

void SimTK::ContactSnapshot::setTimestamp ( Real  time)
inline

Set the time at which this snapshot was taken.

Real SimTK::ContactSnapshot::getTimestamp ( ) const
inline

At what simulation time was this contact snapshot taken?

void SimTK::ContactSnapshot::adoptContact ( Contact contact)
inline

Add this Contact object to this snapshot; this is a shallow, reference-counted copy so the Contact object is not duplicated.

The Contact is assigned a slot in the array of Contact objects that can be used for very fast access; however, that index may change if other Contact objects are removed from the snapshot.

bool SimTK::ContactSnapshot::hasContact ( ContactId  id) const
inline

Does this snapshot contain a Contact object with the given ContactId?

bool SimTK::ContactSnapshot::hasContact ( ContactSurfaceIndex  surf1,
ContactSurfaceIndex  surf2 
) const
inline

Does this snapshot contain a Contact object for the given surface pair (in either order)?

int SimTK::ContactSnapshot::getNumContacts ( ) const
inline

Find out how many Contacts are in this snapshot.

const Contact& SimTK::ContactSnapshot::getContact ( int  n) const
inline

Get a reference to the n'th Contact in this snapshot; note that the position of a given Contact in this array is not guaranteed to remain unchanged when Contacts are removed from this snapshot.

When in doubt, look up the contact by ContactId instead.

See also
getContactById()
const Contact& SimTK::ContactSnapshot::getContactById ( ContactId  id) const
inline

If this snapshot contains a contact with the given id, return a reference to it; otherwise, return a reference to an empty contact handle (you can check with isEmpty()).

ContactId SimTK::ContactSnapshot::getContactIdForSurfacePair ( ContactSurfaceIndex  surf1,
ContactSurfaceIndex  surf2 
) const
inline

If this snapshot contains a contact for the given pair of contact surfaces (order doesn't matter), return its ContactId; otherwise, return an invalid ContactId (you can check with isValid()).


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