SurgSim::Collision::ContactCalculation Class Referenceabstract

Base class responsible for calculating contact data between two objects. More...

`#include <SurgSim/Collision/ContactCalculation.h>`

Inheritance diagram for SurgSim::Collision::ContactCalculation:

## Public Types

typedef std::array< std::array< std::shared_ptr< ContactCalculation >, Math::SHAPE_TYPE_COUNT >, Math::SHAPE_TYPE_COUNT > | TableType

## Public Member Functions

| ContactCalculation ()
| Constructor. More...
virtual | ~ContactCalculation ()
| Destructor. More...
void | calculateContact (std::shared_ptr< CollisionPair > pair)
| Calculate the contacts for a given pair. More...
std::list< std::shared_ptr< Contact > > | calculateDcdContact (const Math::PosedShape< std::shared_ptr< Math::Shape >> posedShape1, const Math::PosedShape< std::shared_ptr< Math::Shape >> posedShape2)
| Calculate the dcd contacts between two posed/transformed shapes. More...
std::list< std::shared_ptr< Contact > > | calculateCcdContact (const Math::PosedShapeMotion< std::shared_ptr< Math::Shape >> posedShapeMotion1, const Math::PosedShapeMotion< std::shared_ptr< Math::Shape >> posedShapeMotion2)
| Calculate the ccd contacts between two posed/transformed shapes. More...
virtual std::pair< int, int > | getShapeTypes ()=0
| Virtual function that returns the shapes that this ContactCalculation class handles. More...

## Static Public Member Functions

static void | registerDcdContactCalculation (const std::shared_ptr< ContactCalculation > &calculation)
| Register an instance of a contact calculation in the table. More...
static void | registerCcdContactCalculation (const std::shared_ptr< ContactCalculation > &calculation)
| Register an instance of a contact calculation in the table. More...
static const TableType & | getDcdContactTable ()
static const TableType & | getCcdContactTable ()

## Private Member Functions

virtual void | doCalculateContact (std::shared_ptr< CollisionPair > pair)
| Calculate the actual contact between two shapes of the given CollisionPair. More...
virtual std::list< std::shared_ptr< Contact > > | doCalculateDcdContact (const Math::PosedShape< std::shared_ptr< Math::Shape >> &posedShape1, const Math::PosedShape< std::shared_ptr< Math::Shape >> &posedShape2)
| Virtual function receives the call from the public interface, usually will type the shapes statically to their known types and then execute a specific contact calculation between the two shapes. More...
virtual std::list< std::shared_ptr< Contact > > | doCalculateCcdContact (const Math::PosedShapeMotion< std::shared_ptr< Math::Shape >> &posedShapeMotion1, const Math::PosedShapeMotion< std::shared_ptr< Math::Shape >> &posedShapeMotion2)
| Virtual function receives the call from the public interface, usually will type the shapes statically to their known types and then execute a specific contact calculation between the two shapes. More...

## Static Private Member Functions

static void | initializeTables ()
| Statically initialize the tables, used via call once. More...
static void | privateDcdRegister (const std::shared_ptr< ContactCalculation > &calculation, const std::pair< int, int > &types)
static void | privateDcdRegister (const std::shared_ptr< ContactCalculation > &calculation)
static void | privateCcdRegister (const std::shared_ptr< ContactCalculation > &calculation, const std::pair< int, int > &types)
static void | privateCcdRegister (const std::shared_ptr< ContactCalculation > &calculation)

## Static Private Attributes

static TableType | m_contactDcdCalculations
| Static table of Dcd contact calculations. More...
static TableType | m_contactCcdCalculations
| Static table of Ccd contact calculations. More...
static std::once_flag | m_initializationFlag
| Flag used for initialization. More...

## Detailed Description

Base class responsible for calculating contact data between two objects.

It is used for determining whether two objects intersect. If there is contact, new Contacts are calculated.

See also
  Contact

## Member Typedef Documentation

## TableType

typedef std::array<std::array<std::shared_ptr<ContactCalculation>, Math::SHAPE_TYPE_COUNT>, Math::SHAPE_TYPE_COUNT> SurgSim::Collision::ContactCalculation::TableType

## Constructor & Destructor Documentation

## ContactCalculation()

SurgSim::Collision::ContactCalculation::ContactCalculation | ( |  | ) |

Constructor.

## ~ContactCalculation()

SurgSim::Collision::ContactCalculation::~ContactCalculation | ( |  | ) |

virtual

Destructor.

## Member Function Documentation

## calculateCcdContact()

std::list< std::shared_ptr< SurgSim::Collision::Contact > > SurgSim::Collision::ContactCalculation::calculateCcdContact | ( | const Math::PosedShapeMotion< std::shared_ptr< Math::Shape >> | posedShapeMotion1,
|  | const Math::PosedShapeMotion< std::shared_ptr< Math::Shape >> | posedShapeMotion2
| ) |  |

Calculate the ccd contacts between two posed/transformed shapes.

Parameters

  posedShapeMotion1,posedShapeMotion2 | The two posed shape motion to calculate ccd contact for

Returns
  a list of ccd contacts between the two given shapes

Note
  The contact information is related to the end of the time range, so solving these contact will
  solve the collision at the end of the time range.

## calculateContact()

void SurgSim::Collision::ContactCalculation::calculateContact | ( | std::shared_ptr< CollisionPair > | pair | ) |

Calculate the contacts for a given pair.

Parameters

  pair | A CollisionPair that is under consideration, new contacts will be added to this pair

## calculateDcdContact()

std::list< std::shared_ptr< Contact > > SurgSim::Collision::ContactCalculation::calculateDcdContact | ( | const Math::PosedShape< std::shared_ptr< Math::Shape >> | posedShape1,
|  | const Math::PosedShape< std::shared_ptr< Math::Shape >> | posedShape2
| ) |  |

Calculate the dcd contacts between two posed/transformed shapes.

Parameters

  posedShape1,posedShape2 | The two posed shape to consider for this dcd contact calculation

Returns
  a list of contacts between the two given posed shapes

## doCalculateCcdContact()

std::list< std::shared_ptr< Contact > > SurgSim::Collision::ContactCalculation::doCalculateCcdContact | ( | const Math::PosedShapeMotion< std::shared_ptr< Math::Shape >> & | posedShapeMotion1,
|  | const Math::PosedShapeMotion< std::shared_ptr< Math::Shape >> & | posedShapeMotion2
| ) |  |

private virtual

Virtual function receives the call from the public interface, usually will type the shapes statically to their known types and then execute a specific contact calculation between the two shapes.

Parameters

  posedShapeMotion1,posedShapeMotion2 | The two posed shapes motion to calculate ccd contact for

Returns
  a list of ccd contacts between the two given posed shapes motion

Reimplemented in SurgSim::Collision::ShapeShapeContactCalculation< Shape1, Shape2 >, SurgSim::Collision::ShapeShapeContactCalculation< Math::MeshShape, Math::PlaneShape >, SurgSim::Collision::ShapeShapeContactCalculation< Math::MeshShape, Math::MeshShape >, SurgSim::Collision::ShapeShapeContactCalculation< Math::SegmentMeshShape, Math::SegmentMeshShape >, SurgSim::Collision::ShapeShapeContactCalculation< Math::BoxShape, Math::DoubleSidedPlaneShape >, SurgSim::Collision::ShapeShapeContactCalculation< Math::BoxShape, Math::CapsuleShape >, SurgSim::Collision::ShapeShapeContactCalculation< Math::MeshShape, Math::ParticlesShape >, SurgSim::Collision::ShapeShapeContactCalculation< Math::SegmentMeshShape, Math::MeshShape >, SurgSim::Collision::ShapeShapeContactCalculation< Math::SphereShape, Math::SphereShape >, SurgSim::Collision::ShapeShapeContactCalculation< Math::SphereShape, Math::PlaneShape >, SurgSim::Collision::ShapeShapeContactCalculation< Math::MeshShape, Math::SurfaceMeshShape >, SurgSim::Collision::ShapeShapeContactCalculation< Math::CapsuleShape, Math::SphereShape >, SurgSim::Collision::ShapeShapeContactCalculation< Math::SphereShape, Math::DoubleSidedPlaneShape >, SurgSim::Collision::ShapeShapeContactCalculation< Math::BoxShape, Math::PlaneShape >, SurgSim::Collision::ShapeShapeContactCalculation< Math::BoxShape, Math::SphereShape >, SurgSim::Collision::DefaultContactCalculation, and SurgSim::Collision::CompoundShapeContact.

## doCalculateContact()

void SurgSim::Collision::ContactCalculation::doCalculateContact | ( | std::shared_ptr< CollisionPair > | pair | ) |

private virtual

Calculate the actual contact between two shapes of the given CollisionPair.

Parameters

  pair | The symmetric pair that is under consideration.

Reimplemented in SurgSim::Collision::DefaultContactCalculation.

## doCalculateDcdContact()

std::list< std::shared_ptr< Contact > > SurgSim::Collision::ContactCalculation::doCalculateDcdContact | ( | const Math::PosedShape< std::shared_ptr< Math::Shape >> & | posedShape1,
|  | const Math::PosedShape< std::shared_ptr< Math::Shape >> & | posedShape2
| ) |  |

private virtual

Virtual function receives the call from the public interface, usually will type the shapes statically to their known types and then execute a specific contact calculation between the two shapes.

Parameters

  posedShape1,posedShape2 | The two posed shapes to calculate dcd contact for

Returns
  a list of dcd contacts between the two given posed shapes

Reimplemented in SurgSim::Collision::ShapeShapeContactCalculation< Shape1, Shape2 >, SurgSim::Collision::ShapeShapeContactCalculation< Math::MeshShape, Math::PlaneShape >, SurgSim::Collision::ShapeShapeContactCalculation< Math::MeshShape, Math::MeshShape >, SurgSim::Collision::ShapeShapeContactCalculation< Math::SegmentMeshShape, Math::SegmentMeshShape >, SurgSim::Collision::ShapeShapeContactCalculation< Math::BoxShape, Math::DoubleSidedPlaneShape >, SurgSim::Collision::ShapeShapeContactCalculation< Math::BoxShape, Math::CapsuleShape >, SurgSim::Collision::ShapeShapeContactCalculation< Math::MeshShape, Math::ParticlesShape >, SurgSim::Collision::ShapeShapeContactCalculation< Math::SegmentMeshShape, Math::MeshShape >, SurgSim::Collision::ShapeShapeContactCalculation< Math::SphereShape, Math::SphereShape >, SurgSim::Collision::ShapeShapeContactCalculation< Math::SphereShape, Math::PlaneShape >, SurgSim::Collision::ShapeShapeContactCalculation< Math::MeshShape, Math::SurfaceMeshShape >, SurgSim::Collision::ShapeShapeContactCalculation< Math::CapsuleShape, Math::SphereShape >, SurgSim::Collision::ShapeShapeContactCalculation< Math::SphereShape, Math::DoubleSidedPlaneShape >, SurgSim::Collision::ShapeShapeContactCalculation< Math::BoxShape, Math::PlaneShape >, SurgSim::Collision::ShapeShapeContactCalculation< Math::BoxShape, Math::SphereShape >, SurgSim::Collision::OctreeContact, SurgSim::Collision::DefaultContactCalculation, and SurgSim::Collision::CompoundShapeContact.

## getCcdContactTable()

const ContactCalculation::TableType & SurgSim::Collision::ContactCalculation::getCcdContactTable | ( |  | ) |

static

## getDcdContactTable()

const ContactCalculation::TableType & SurgSim::Collision::ContactCalculation::getDcdContactTable | ( |  | ) |

static

## getShapeTypes()

virtual std::pair<int, int> SurgSim::Collision::ContactCalculation::getShapeTypes | ( |  | ) |

pure virtual

Virtual function that returns the shapes that this ContactCalculation class handles.

Returns
  Return the shape types this class handles.

Implemented in SurgSim::Collision::SegmentSelfContact, SurgSim::Collision::BoxSphereContact, SurgSim::Collision::BoxPlaneContact, SurgSim::Collision::TriangleMeshParticlesContact, SurgSim::Collision::TriangleMeshSurfaceMeshContact, SurgSim::Collision::BoxDoubleSidedPlaneContact, SurgSim::Collision::SphereDoubleSidedPlaneContact, SurgSim::Collision::TriangleMeshTriangleMeshContact, SurgSim::Collision::CapsuleSphereContact, SurgSim::Collision::SpherePlaneContact, SurgSim::Collision::BoxCapsuleContact, SurgSim::Collision::DefaultContactCalculation, SurgSim::Collision::SphereSphereContact, SurgSim::Collision::TriangleMeshPlaneContact, SurgSim::Collision::SegmentMeshTriangleMeshContact, SurgSim::Collision::CompoundShapeContact, SurgSim::Collision::OctreeCapsuleContact, SurgSim::Collision::OctreeDoubleSidedPlaneContact, SurgSim::Collision::OctreePlaneContact, and SurgSim::Collision::OctreeSphereContact.

## initializeTables()

void SurgSim::Collision::ContactCalculation::initializeTables | ( |  | ) |

static private

Statically initialize the tables, used via call once.

## privateCcdRegister() [1/2]

void SurgSim::Collision::ContactCalculation::privateCcdRegister | ( | const std::shared_ptr< ContactCalculation > & | calculation,
|  | const std::pair< int, int > & | types
| ) |  |

static private

registration to call at static scope (does not protect the initialization via call_once) Mirroring the public functions

## privateCcdRegister() [2/2]

void SurgSim::Collision::ContactCalculation::privateCcdRegister | ( | const std::shared_ptr< ContactCalculation > & | calculation | ) |

static private

registration to call at static scope (does not protect the initialization via call_once) Mirroring the public functions

## privateDcdRegister() [1/2]

void SurgSim::Collision::ContactCalculation::privateDcdRegister | ( | const std::shared_ptr< ContactCalculation > & | calculation,
|  | const std::pair< int, int > & | types
| ) |  |

static private

registration to call at static scope (does not protect the initialization via call_once) Mirroring the public functions

## privateDcdRegister() [2/2]

void SurgSim::Collision::ContactCalculation::privateDcdRegister | ( | const std::shared_ptr< ContactCalculation > & | calculation | ) |

static private

registration to call at static scope (does not protect the initialization via call_once) Mirroring the public functions

## registerCcdContactCalculation()

void SurgSim::Collision::ContactCalculation::registerCcdContactCalculation | ( | const std::shared_ptr< ContactCalculation > & | calculation | ) |

static

Register an instance of a contact calculation in the table.

Parameters

  calculation | The calculation to be registered

## registerDcdContactCalculation()

void SurgSim::Collision::ContactCalculation::registerDcdContactCalculation | ( | const std::shared_ptr< ContactCalculation > & | calculation | ) |

static

Register an instance of a contact calculation in the table.

Parameters

  calculation | The calculation to be registered

## Member Data Documentation

## m_contactCcdCalculations

ContactCalculation::TableType SurgSim::Collision::ContactCalculation::m_contactCcdCalculations

static private

Static table of Ccd contact calculations.

## m_contactDcdCalculations

ContactCalculation::TableType SurgSim::Collision::ContactCalculation::m_contactDcdCalculations

static private

Static table of Dcd contact calculations.

## m_initializationFlag

std::once_flag SurgSim::Collision::ContactCalculation::m_initializationFlag

static private

Flag used for initialization.

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

- SurgSim/Collision/ContactCalculation.h
- SurgSim/Collision/ContactCalculation.cpp