opensurgsim
DeformableCollisionRepresentation.h
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013, 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_PHYSICS_DEFORMABLECOLLISIONREPRESENTATION_H
17 #define SURGSIM_PHYSICS_DEFORMABLECOLLISIONREPRESENTATION_H
18 
19 #include <memory>
20 #include <string>
21 
22 #include "SurgSim/Collision/Representation.h"
23 #include "SurgSim/Framework/ObjectFactory.h"
24 
25 namespace SurgSim
26 {
27 namespace Math
28 {
29 class Shape;
30 class MeshShape;
31 }
32 
33 namespace Physics
34 {
35 class DeformableRepresentation;
36 
37 SURGSIM_STATIC_REGISTRATION(DeformableCollisionRepresentation);
38 
43 {
44 public:
45 
48  explicit DeformableCollisionRepresentation(const std::string& name);
49 
52 
54 
58  void setShape(std::shared_ptr<SurgSim::Math::Shape> shape);
59 
60  std::shared_ptr<Math::Shape> getShape() const override;
61 
64  void setDeformableRepresentation(std::shared_ptr<SurgSim::Physics::DeformableRepresentation> representation);
65 
67  const std::shared_ptr<SurgSim::Physics::DeformableRepresentation> getDeformableRepresentation() const;
68 
69  void setCollisionDetectionType(Collision::CollisionDetectionType type) override;
70 
71  void setSelfCollisionDetectionType(Collision::CollisionDetectionType type) override;
72 
73  int getShapeType() const override;
74 
75  void updateDcdData() override;
76 
77  void updateCcdData(double interval) override;
78 
79  void updateShapeData() override;
80 
81  Math::Aabbd getBoundingBox() const override;
82 
83 private:
84  bool doInitialize() override;
85  bool doWakeUp() override;
86 
88  std::shared_ptr<SurgSim::Math::Shape> m_shape, m_previousShape;
89 
92  Math::Aabbd m_aabb;
93 
95  std::weak_ptr<SurgSim::Physics::DeformableRepresentation> m_deformable;
96 
97  double m_oldVolume;
98  double m_previousOldVolume;
99  double m_aabbThreshold;
100 };
101 
102 } // namespace Physics
103 } // namespace SurgSim
104 
105 #endif
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
A collision representation that can be attached to a deformable, when this contains a mesh with the s...
Definition: DeformableCollisionRepresentation.h:42
The type of collision detection.
Definition: Representation.h:60