OctreeContact.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_OCTREECONTACT_H
17 #define SURGSIM_COLLISION_OCTREECONTACT_H
18 
19 #include <memory>
20 
22 #include "SurgSim/Math/BoxShape.h"
25 
26 namespace SurgSim
27 {
28 namespace Collision
29 {
30 
31 class CollisionPair;
32 class ShapeCollisionRepresentation;
33 
39 {
40 protected:
47  virtual std::list<std::shared_ptr<Contact>> boxContactCalculation(
48  const SurgSim::Math::BoxShape& boxShape, const SurgSim::Math::RigidTransform3d& boxPose,
49  const SurgSim::Math::Shape& otherShape, const SurgSim::Math::RigidTransform3d& otherPose) = 0;
50 
51 private:
52  std::list<std::shared_ptr<Contact>> doCalculateDcdContact(
53  const Math::PosedShape<std::shared_ptr<Math::Shape>>& posedShape1,
54  const Math::PosedShape<std::shared_ptr<Math::Shape>>& posedShape2) override;
55 
69  std::shared_ptr<const SurgSim::Math::OctreeShape::NodeType> node,
70  Math::RigidTransform3d octreePose,
71  const std::shared_ptr<Math::Shape>& shape,
72  const Math::RigidTransform3d& shapePose,
74  std::list<std::shared_ptr<Contact>>* result);
75 
78  {
79  public:
80  size_t operator()(const SurgSim::Math::Vector3d& id) const;
81  };
82 
84  std::unordered_map<SurgSim::Math::Vector3d, std::shared_ptr<SurgSim::Math::BoxShape>, Vector3dHash> m_shapes;
85 };
86 
87 };
88 };
89 
90 #endif // SURGSIM_COLLISION_OCTREECONTACT_H
Definition: CompoundShapeToGraphics.cpp:29
Box shape: box centered on (0 0 0), aligned with the axis with different sizes along X...
Definition: BoxShape.h:33
Abstract base class to calculate intersections between an Octree and other shapes.
Definition: OctreeContact.h:38
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
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
Base class responsible for calculating contact data between two objects.
Definition: ContactCalculation.h:41
Enable a Vector3d to be used as a key in an unordered map.
Definition: OctreeContact.h:77
Definitions of 2x2 and 3x3 rigid (isometric) transforms.
size_t operator()(const SurgSim::Math::Vector3d &id) const
Definition: OctreeContact.cpp:33
Eigen::Transform< double, 3, Eigen::Isometry > RigidTransform3d
A 3D rigid (isometric) transform, represented as doubles.
Definition: RigidTransform.h:46
PosedShape is a transformed shape with a record of the pose used to transform it. ...
Definition: Shape.h:117
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
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.
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
Eigen::Matrix< double, 3, 1 > Vector3d
A 3D vector of doubles.
Definition: Vector.h:57
Generic rigid shape class defining a shape.
Definition: Shape.h:65