Simbody
|
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>
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 Contact & | getContact (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 Contact & | getContactById (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()). |
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.
SimTK::ContactSnapshot::ContactSnapshot | ( | ) | [inline] |
Default constructor sets timestamp to NaN.
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] |
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.
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] |