ContactCalculation.h
Go to the documentation of this file.
// This file is a part of the OpenSurgSim project.
// Copyright 2013-2015, SimQuest Solutions Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SURGSIM_COLLISION_CONTACTCALCULATION_H
#define SURGSIM_COLLISION_CONTACTCALCULATION_H
#include <memory>
#include <mutex>
#include "SurgSim/Collision/CollisionPair.h"
#include "SurgSim/Math/RigidTransform.h"
#include "SurgSim/Math/Shape.h"
namespace SurgSim
{
namespace Math
{
class Shape;
}
namespace Collision
{
class ContactCalculation
{
public:
ContactCalculation();
virtual ~ContactCalculation();
void calculateContact(std::shared_ptr<CollisionPair> pair);
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);
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);
virtual std::pair<int, int> getShapeTypes() = 0;
static void registerDcdContactCalculation(const std::shared_ptr<ContactCalculation>& calculation);
static void registerCcdContactCalculation(const std::shared_ptr<ContactCalculation>& calculation);
typedef
std::array<std::array<std::shared_ptr<ContactCalculation>, Math::SHAPE_TYPE_COUNT>, Math::SHAPE_TYPE_COUNT>
TableType;
static const TableType& getDcdContactTable();
static const TableType& getCcdContactTable();
private:
virtual void doCalculateContact(std::shared_ptr<CollisionPair> pair);
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 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);
static void initializeTables();
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 TableType m_contactDcdCalculations;
static TableType m_contactCcdCalculations;
static std::once_flag m_initializationFlag;
};
}; // namespace Collision
}; // namespace SurgSim
#endif
SurgSim::Collision::ContactCalculation::m_contactDcdCalculations
static TableType m_contactDcdCalculations
Static table of Dcd contact calculations.
Definition: ContactCalculation.h:133
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Collision::ContactCalculation::m_contactCcdCalculations
static TableType m_contactCcdCalculations
Static table of Ccd contact calculations.
Definition: ContactCalculation.h:134
SurgSim::Collision::ContactCalculation
Base class responsible for calculating contact data between two objects.
Definition: ContactCalculation.h:41
SurgSim::Math::SHAPE_TYPE_COUNT
Definition: Shape.h:59
SurgSim::Collision::ContactCalculation::TableType
std::array< std::array< std::shared_ptr< ContactCalculation >, Math::SHAPE_TYPE_COUNT >, Math::SHAPE_TYPE_COUNT > TableType
Definition: ContactCalculation.h:84
RigidTransform.h
Definitions of 2x2 and 3x3 rigid (isometric) transforms.
SurgSim::Math::PosedShape
PosedShape is a transformed shape with a record of the pose used to transform it. ...
Definition: Shape.h:117
SurgSim::Math::PosedShapeMotion
PosedShapeMotion is embedding the motion of a PosedShape, providing a posed shape at 2 different inst...
Definition: Shape.h:145
SurgSim::Collision::ContactCalculation::m_initializationFlag
static std::once_flag m_initializationFlag
Flag used for initialization.
Definition: ContactCalculation.h:135
Shape.h
CollisionPair.h