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

#include <ContactTrackerSubsystem.h>

List of all members.

Public Member Functions

 ContactSnapshot ()
 Default constructor sets timestamp to NaN.
void clear ()
 Restore to default-constructed condition.
void setTimestamp (Real time)
 Set the time at which this snapshot was taken.
Real getTimestamp () const
 At what simulation time was this contact snapshot taken?
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.
bool hasContact (ContactId id) const
 Does this snapshot contain a Contact object with the given ContactId?
bool hasContact (ContactSurfaceIndex surf1, ContactSurfaceIndex surf2) const
 Does this snapshot contain a Contact object for the given surface pair (in either order)?
int getNumContacts () const
 Find out how many Contacts are in this snapshot.
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.
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()).
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()).

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

ContactSnapshot (  )  [inline]

Default constructor sets timestamp to NaN.


Member Function Documentation

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

References Contact::getContactId(), Contact::getSurface1(), and Contact::getSurface2().

void clear (  )  [inline]

Restore to default-constructed condition.

const Contact& 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& 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 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()).

int getNumContacts (  )  const [inline]

Find out how many Contacts are in this snapshot.

Referenced by SimTK::operator<<().

Real getTimestamp (  )  const [inline]

At what simulation time was this contact snapshot taken?

Referenced by SimTK::operator<<().

bool hasContact ( ContactSurfaceIndex  surf1,
ContactSurfaceIndex  surf2 
) const [inline]

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

bool hasContact ( ContactId  id  )  const [inline]

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

void setTimestamp ( Real  time  )  [inline]

Set the time at which this snapshot was taken.


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

Generated on Thu Aug 12 16:37:59 2010 for SimTKcore by  doxygen 1.6.1