Public Member Functions | Private Attributes | 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 <SurgSim/Collision/CollisionPair.h>

Public Member Functions

 CollisionPair ()
 Default Constructor. More...
 
 CollisionPair (const std::shared_ptr< Representation > &first, const std::shared_ptr< Representation > &second)
 Normal constructor. More...
 
 ~CollisionPair ()
 Destructor. More...
 
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...
 
std::shared_ptr< RepresentationgetFirst () const
 
std::shared_ptr< RepresentationgetSecond () const
 
bool hasContacts () const
 
void addContact (const double &depth, const SurgSim::Math::Vector3d &contactPoint, const SurgSim::Math::Vector3d &normal, const std::pair< SurgSim::DataStructures::Location, SurgSim::DataStructures::Location > &penetrationPoints)
 Adds a contact to the collision pair. More...
 
void addContact (const double &depth, const SurgSim::Math::Vector3d &normal, const std::pair< SurgSim::DataStructures::Location, SurgSim::DataStructures::Location > &penetrationPoints)
 Adds a contact to the collision pair. More...
 
void addContact (const std::shared_ptr< Contact > &contact)
 Adds a contact. More...
 
const std::list< std::shared_ptr< Contact > > & getContacts () const
 
void clearContacts ()
 Reset clear the list of contacts, invalidating all the contacts. More...
 
void swapRepresentations ()
 Swap the representation pair so that first becomes second and second becomes first. More...
 
bool isSwapped () const
 Query if this the pair has been swapped from when it was constructed. More...
 

Private Attributes

std::pair< std::shared_ptr< Representation >, std::shared_ptr< Representation > > m_representations
 Pair of objects that are colliding. More...
 
std::list< std::shared_ptr< Contact > > m_contacts
 List of current contacts. More...
 
bool m_isSwapped
 

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.

Constructor & Destructor Documentation

SurgSim::Collision::CollisionPair::CollisionPair ( )

Default Constructor.

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

Normal constructor.

SurgSim::Collision::CollisionPair::~CollisionPair ( )

Destructor.

Member Function Documentation

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

Adds a contact to the collision pair.

Parameters
depthThe depth of the intersection.
contactPointThe contact point, between the two bodies.
normalThe normal of the contact pointing into the first representation.
penetrationPointsThe points furthest into the opposing object
void SurgSim::Collision::CollisionPair::addContact ( const double &  depth,
const SurgSim::Math::Vector3d normal,
const std::pair< SurgSim::DataStructures::Location, SurgSim::DataStructures::Location > &  penetrationPoints 
)

Adds a 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
void SurgSim::Collision::CollisionPair::addContact ( const std::shared_ptr< Contact > &  contact)

Adds a contact.

Parameters
contactThe contact between the first and the second representation.
void SurgSim::Collision::CollisionPair::clearContacts ( )

Reset clear the list of contacts, invalidating all the contacts.

const std::list< std::shared_ptr< Contact > > & SurgSim::Collision::CollisionPair::getContacts ( ) const
Returns
All the contacts.
std::shared_ptr< Representation > SurgSim::Collision::CollisionPair::getFirst ( ) const
Returns
The representation considered to be the first
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.
std::shared_ptr< Representation > SurgSim::Collision::CollisionPair::getSecond ( ) const
Returns
The representation considered to be the second
bool SurgSim::Collision::CollisionPair::hasContacts ( ) const
Returns
true if there are any contacts assigned to the pair, false otherwise
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.
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.
void SurgSim::Collision::CollisionPair::swapRepresentations ( )

Swap the representation pair so that first becomes second and second becomes first.

Member Data Documentation

std::list<std::shared_ptr<Contact> > SurgSim::Collision::CollisionPair::m_contacts
private

List of current contacts.

bool SurgSim::Collision::CollisionPair::m_isSwapped
private
std::pair<std::shared_ptr<Representation>, std::shared_ptr<Representation> > SurgSim::Collision::CollisionPair::m_representations
private

Pair of objects that are colliding.


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