opensurgsim
Public Member Functions | List of all members
SurgSim::Collision::CollisionPair Class Reference

Collision Pair class, it signifies a pair of items that should be checked with the collision algorithm, this structure will be used for input as well as output, as contacts get appended to the contacts list when found. More...

#include <CollisionPair.h>

Public Member Functions

 CollisionPair ()
 Default Constructor.
 
 CollisionPair (const std::shared_ptr< Representation > &first, const std::shared_ptr< Representation > &second)
 Normal constructor.
 
 ~CollisionPair ()
 Destructor.
 
void setRepresentations (const std::shared_ptr< Representation > &first, const std::shared_ptr< Representation > &second)
 Sets the representations in this pair, representations cannot be the same instance and neither can be nullptr. More...
 
const std::pair< std::shared_ptr< Representation >, std::shared_ptr< Representation > > & getRepresentations () const
 Function that returns the pair of representations of the objects that are colliding. More...
 
CollisionDetectionType getType () const
 Get the collision detection type for this pair. More...
 
std::shared_ptr< RepresentationgetFirst () const
 
std::shared_ptr< RepresentationgetSecond () const
 
bool hasContacts () const
 
void addCcdContact (const double &depth, const double &time, const SurgSim::Math::Vector3d &contactPoint, const SurgSim::Math::Vector3d &normal, const std::pair< SurgSim::DataStructures::Location, SurgSim::DataStructures::Location > &penetrationPoints)
 Adds a CCD contact to the collision pair. More...
 
void addDcdContact (const double &depth, const SurgSim::Math::Vector3d &normal, const std::pair< SurgSim::DataStructures::Location, SurgSim::DataStructures::Location > &penetrationPoints)
 Adds a DCD contact to the collision pair. More...
 
void addContact (const std::shared_ptr< Contact > &contact)
 Adds a contact. More...
 
void updateRepresentations ()
 Update the representations by adding the contacts to them.
 
std::list< std::shared_ptr< Contact > > & getContacts ()
 
void clearContacts ()
 Reset clear the list of contacts, invalidating all the contacts.
 
void swapRepresentations ()
 Swap the representation pair so that first becomes second and second becomes first.
 
bool isSwapped () const
 Query if this the pair has been swapped from when it was constructed. More...
 
bool mayIntersect () const
 

Detailed Description

Collision Pair class, it signifies a pair of items that should be checked with the collision algorithm, this structure will be used for input as well as output, as contacts get appended to the contacts list when found.

Member Function Documentation

§ addCcdContact()

void SurgSim::Collision::CollisionPair::addCcdContact ( const double &  depth,
const double &  time,
const SurgSim::Math::Vector3d contactPoint,
const SurgSim::Math::Vector3d normal,
const std::pair< SurgSim::DataStructures::Location, SurgSim::DataStructures::Location > &  penetrationPoints 
)

Adds a CCD contact to the collision pair.

Parameters
depthThe depth of the intersection.
timeThe actual time of contact as determined by the CCD algorithm.
contactPointThe contact point, between the two bodies at time "time"
normalThe normal of the contact pointing into the first representation.
penetrationPointsThe points furthest into the opposing object

§ addContact()

void SurgSim::Collision::CollisionPair::addContact ( const std::shared_ptr< Contact > &  contact)

Adds a contact.

Parameters
contactThe contact between the first and the second representation.

§ addDcdContact()

void SurgSim::Collision::CollisionPair::addDcdContact ( const double &  depth,
const SurgSim::Math::Vector3d normal,
const std::pair< SurgSim::DataStructures::Location, SurgSim::DataStructures::Location > &  penetrationPoints 
)

Adds a DCD contact to the collision pair.

Parameters
depthThe depth of the intersection.
normalThe normal of the contact pointing into the first representation.
penetrationPointsThe points furthest into the opposing object

§ getContacts()

std::list< std::shared_ptr< Contact > > & SurgSim::Collision::CollisionPair::getContacts ( )
Returns
All the contacts.

§ getFirst()

std::shared_ptr< Representation > SurgSim::Collision::CollisionPair::getFirst ( ) const
Returns
The representation considered to be the first

§ getRepresentations()

const std::pair< std::shared_ptr< Representation >, std::shared_ptr< Representation > > & SurgSim::Collision::CollisionPair::getRepresentations ( ) const

Function that returns the pair of representations of the objects that are colliding.

Returns
The pair of representations that are colliding.

§ getSecond()

std::shared_ptr< Representation > SurgSim::Collision::CollisionPair::getSecond ( ) const
Returns
The representation considered to be the second

§ getType()

CollisionDetectionType SurgSim::Collision::CollisionPair::getType ( ) const

Get the collision detection type for this pair.

Returns
The collision detection type

§ hasContacts()

bool SurgSim::Collision::CollisionPair::hasContacts ( ) const
Returns
true if there are any contacts assigned to the pair, false otherwise

§ isSwapped()

bool SurgSim::Collision::CollisionPair::isSwapped ( ) const

Query if this the pair has been swapped from when it was constructed.

Returns
true if swapped, false if not.

§ mayIntersect()

bool SurgSim::Collision::CollisionPair::mayIntersect ( ) const
Returns
whether the two represenations might have an intersection
Note
The bounding boxes are taken, if the bounding box is empty it is always considered for collision

§ setRepresentations()

void SurgSim::Collision::CollisionPair::setRepresentations ( const std::shared_ptr< Representation > &  first,
const std::shared_ptr< Representation > &  second 
)

Sets the representations in this pair, representations cannot be the same instance and neither can be nullptr.

Parameters
firstThe first Collision Representation.
secondThe second Collision Representation.

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