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...
CollisionDetectionType | getType () const
| Get the collision detection type for this pair. More...
std::shared_ptr< Representation > | getFirst () const
std::shared_ptr< Representation > | getSecond () 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. More...
std::list< std::shared_ptr< Contact > > & | getContacts ()
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...
bool | mayIntersect () const

## Private Attributes

std::pair< std::shared_ptr< Representation >, std::shared_ptr< Representation > > | m_representations
| Pair of objects that are colliding. More...
CollisionDetectionType | m_type
| Collision detection type for this pair. 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

## CollisionPair() [1/2]

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

Default Constructor.

## CollisionPair() [2/2]

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

Normal constructor.

## ~CollisionPair()

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

Destructor.

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

  depth | The depth of the intersection.
  time | The actual time of contact as determined by the CCD algorithm.
  contactPoint | The contact point, between the two bodies at time "time"
  normal | The normal of the contact pointing into the first representation.
  penetrationPoints | The points furthest into the opposing object

## addContact()

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

Adds a contact.

Parameters

  contact | The 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

  depth | The depth of the intersection.
  normal | The normal of the contact pointing into the first representation.
  penetrationPoints | The points furthest into the opposing object

## clearContacts()

void SurgSim::Collision::CollisionPair::clearContacts | ( |  | ) |

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

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

  first | The first Collision Representation.
  second | The second Collision Representation.

## swapRepresentations()

void SurgSim::Collision::CollisionPair::swapRepresentations | ( |  | ) |

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

## updateRepresentations()

void SurgSim::Collision::CollisionPair::updateRepresentations | ( |  | ) |

Update the representations by adding the contacts to them.

## Member Data Documentation

## m_contacts

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

private

List of current contacts.

## m_isSwapped

bool SurgSim::Collision::CollisionPair::m_isSwapped

private

## m_representations

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

private

Pair of objects that are colliding.

## m_type

CollisionDetectionType SurgSim::Collision::CollisionPair::m_type

private

Collision detection type for this pair.

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

- SurgSim/Collision/CollisionPair.h
- SurgSim/Collision/CollisionPair.cpp