OctreeContact.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_OCTREECONTACT_H
#define SURGSIM_COLLISION_OCTREECONTACT_H
#include <memory>
#include "SurgSim/Collision/ContactCalculation.h"
#include "SurgSim/Math/BoxShape.h"
#include "SurgSim/Math/OctreeShape.h"
#include "SurgSim/Math/RigidTransform.h"
namespace SurgSim
{
namespace Collision
{
class CollisionPair;
class ShapeCollisionRepresentation;
class OctreeContact : public ContactCalculation
{
protected:
virtual std::list<std::shared_ptr<Contact>> boxContactCalculation(
const SurgSim::Math::BoxShape& boxShape, const SurgSim::Math::RigidTransform3d& boxPose,
const SurgSim::Math::Shape& otherShape, const SurgSim::Math::RigidTransform3d& otherPose) = 0;
private:
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) override;
void calculateContactWithNode(
std::shared_ptr<const SurgSim::Math::OctreeShape::NodeType> node,
Math::RigidTransform3d octreePose,
const std::shared_ptr<Math::Shape>& shape,
const Math::RigidTransform3d& shapePose,
SurgSim::DataStructures::OctreePath* nodePath,
std::list<std::shared_ptr<Contact>>* result);
class Vector3dHash
{
public:
size_t operator()(const SurgSim::Math::Vector3d& id) const;
};
std::unordered_map<SurgSim::Math::Vector3d, std::shared_ptr<SurgSim::Math::BoxShape>, Vector3dHash> m_shapes;
};
};
};
#endif // SURGSIM_COLLISION_OCTREECONTACT_H
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Math::BoxShape
Box shape: box centered on (0 0 0), aligned with the axis with different sizes along X...
Definition: BoxShape.h:33
BoxShape.h
SurgSim::Collision::OctreeContact
Abstract base class to calculate intersections between an Octree and other shapes.
Definition: OctreeContact.h:38
SurgSim::Collision::OctreeContact::m_shapes
std::unordered_map< SurgSim::Math::Vector3d, std::shared_ptr< SurgSim::Math::BoxShape >, Vector3dHash > m_shapes
The shapes used for the contact calculations are cached for performance.
Definition: OctreeContact.h:84
SurgSim::DataStructures::OctreePath
std::vector< size_t > OctreePath
Typedef of octree path The path is a vector of children indexes (each within 0 to 7) that lead to the...
Definition: OctreeNode.h:43
SurgSim::Collision::ContactCalculation
Base class responsible for calculating contact data between two objects.
Definition: ContactCalculation.h:41
SurgSim::Collision::OctreeContact::Vector3dHash
Enable a Vector3d to be used as a key in an unordered map.
Definition: OctreeContact.h:77
RigidTransform.h
Definitions of 2x2 and 3x3 rigid (isometric) transforms.
SurgSim::Collision::OctreeContact::Vector3dHash::operator()
size_t operator()(const SurgSim::Math::Vector3d &id) const
Definition: OctreeContact.cpp:33
SurgSim::Math::RigidTransform3d
Eigen::Transform< double, 3, Eigen::Isometry > RigidTransform3d
A 3D rigid (isometric) transform, represented as doubles.
Definition: RigidTransform.h:46
SurgSim::Math::PosedShape
PosedShape is a transformed shape with a record of the pose used to transform it. ...
Definition: Shape.h:117
SurgSim::Collision::OctreeContact::doCalculateDcdContact
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) override
Virtual function receives the call from the public interface, usually will type the shapes statically...
Definition: OctreeContact.cpp:39
ContactCalculation.h
SurgSim::Collision::OctreeContact::boxContactCalculation
virtual std::list< std::shared_ptr< Contact > > boxContactCalculation(const SurgSim::Math::BoxShape &boxShape, const SurgSim::Math::RigidTransform3d &boxPose, const SurgSim::Math::Shape &otherShape, const SurgSim::Math::RigidTransform3d &otherPose)=0
Do the calculation between an octree node (BoxShape) and the other shape.
SurgSim::Collision::OctreeContact::calculateContactWithNode
void calculateContactWithNode(std::shared_ptr< const SurgSim::Math::OctreeShape::NodeType > node, Math::RigidTransform3d octreePose, const std::shared_ptr< Math::Shape > &shape, const Math::RigidTransform3d &shapePose, SurgSim::DataStructures::OctreePath *nodePath, std::list< std::shared_ptr< Contact >> *result)
Calculate the collision between a specific octree node and a shape This function will check for conta...
Definition: OctreeContact.cpp:56
OctreeShape.h
SurgSim::Math::Vector3d
Eigen::Matrix< double, 3, 1 > Vector3d
A 3D vector of doubles.
Definition: Vector.h:57
SurgSim::Math::Shape
Generic rigid shape class defining a shape.
Definition: Shape.h:65