ContactCalculation.h
Go to the documentation of this file.
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013-2015, SimQuest Solutions Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 #ifndef SURGSIM_COLLISION_CONTACTCALCULATION_H
17 #define SURGSIM_COLLISION_CONTACTCALCULATION_H
18 
19 #include <memory>
20 #include <mutex>
21 
24 #include "SurgSim/Math/Shape.h"
25 
26 namespace SurgSim
27 {
28 
29 namespace Math
30 {
31 class Shape;
32 }
33 
34 namespace Collision
35 {
36 
42 {
43 public:
46 
48  virtual ~ContactCalculation();
49 
52  void calculateContact(std::shared_ptr<CollisionPair> pair);
53 
57  std::list<std::shared_ptr<Contact>> calculateDcdContact(
58  const Math::PosedShape<std::shared_ptr<Math::Shape>> posedShape1,
59  const Math::PosedShape<std::shared_ptr<Math::Shape>> posedShape2);
60 
66  std::list<std::shared_ptr<Contact>> calculateCcdContact(
67  const Math::PosedShapeMotion<std::shared_ptr<Math::Shape>> posedShapeMotion1,
68  const Math::PosedShapeMotion<std::shared_ptr<Math::Shape>> posedShapeMotion2);
69 
72  virtual std::pair<int, int> getShapeTypes() = 0;
73 
76  static void registerDcdContactCalculation(const std::shared_ptr<ContactCalculation>& calculation);
77 
80  static void registerCcdContactCalculation(const std::shared_ptr<ContactCalculation>& calculation);
81 
82  typedef
83  std::array<std::array<std::shared_ptr<ContactCalculation>, Math::SHAPE_TYPE_COUNT>, Math::SHAPE_TYPE_COUNT>
85 
86  static const TableType& getDcdContactTable();
87  static const TableType& getCcdContactTable();
88 private:
89 
92  virtual void doCalculateContact(std::shared_ptr<CollisionPair> pair);
93 
99  virtual std::list<std::shared_ptr<Contact>> doCalculateDcdContact(
100  const Math::PosedShape<std::shared_ptr<Math::Shape>>& posedShape1,
101  const Math::PosedShape<std::shared_ptr<Math::Shape>>& posedShape2);
102 
108  virtual std::list<std::shared_ptr<Contact>> doCalculateCcdContact(
109  const Math::PosedShapeMotion<std::shared_ptr<Math::Shape>>& posedShapeMotion1,
110  const Math::PosedShapeMotion<std::shared_ptr<Math::Shape>>& posedShapeMotion2);
111 
113  static void initializeTables();
114 
118  static void privateDcdRegister(
119  const std::shared_ptr<ContactCalculation>& calculation,
120  const std::pair<int, int>& types);
121  static void privateDcdRegister(const std::shared_ptr<ContactCalculation>& calculation);
123 
127  static void privateCcdRegister(
128  const std::shared_ptr<ContactCalculation>& calculation,
129  const std::pair<int, int>& types);
130  static void privateCcdRegister(const std::shared_ptr<ContactCalculation>& calculation);
132 
135  static std::once_flag m_initializationFlag;
136 };
137 
138 }; // namespace Collision
139 }; // namespace SurgSim
140 
141 #endif
static TableType m_contactDcdCalculations
Static table of Dcd contact calculations.
Definition: ContactCalculation.h:133
Definition: CompoundShapeToGraphics.cpp:29
static TableType m_contactCcdCalculations
Static table of Ccd contact calculations.
Definition: ContactCalculation.h:134
Base class responsible for calculating contact data between two objects.
Definition: ContactCalculation.h:41
Definition: Shape.h:59
std::array< std::array< std::shared_ptr< ContactCalculation >, Math::SHAPE_TYPE_COUNT >, Math::SHAPE_TYPE_COUNT > TableType
Definition: ContactCalculation.h:84
Definitions of 2x2 and 3x3 rigid (isometric) transforms.
PosedShape is a transformed shape with a record of the pose used to transform it. ...
Definition: Shape.h:117
PosedShapeMotion is embedding the motion of a PosedShape, providing a posed shape at 2 different inst...
Definition: Shape.h:145
static std::once_flag m_initializationFlag
Flag used for initialization.
Definition: ContactCalculation.h:135