opensurgsim
RigidCollisionRepresentation.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_RIGIDCOLLISIONREPRESENTATION_H
17 #define SURGSIM_PHYSICS_RIGIDCOLLISIONREPRESENTATION_H
18 
19 #include <memory>
20 
21 #include "SurgSim/Collision/Representation.h"
22 #include "SurgSim/Framework/ObjectFactory.h"
23 
24 namespace SurgSim
25 {
26 namespace Physics
27 {
28 class RigidRepresentationBase;
29 
30 SURGSIM_STATIC_REGISTRATION(RigidCollisionRepresentation);
31 
36 {
37 public:
40  explicit RigidCollisionRepresentation(const std::string& name);
41 
44 
46 
47  bool doInitialize() override;
48  bool doWakeUp() override;
49 
51 
54  int getShapeType() const override;
55 
58  std::shared_ptr<Math::Shape> getShape() const override;
59 
65  void setShape(std::shared_ptr<SurgSim::Math::Shape> shape);
66 
69  void setRigidRepresentation(std::shared_ptr<SurgSim::Physics::RigidRepresentationBase> representation);
70 
73  std::shared_ptr<SurgSim::Physics::RigidRepresentationBase> getRigidRepresentation();
74 
75  void updateShapeData() override;
76  void updateCcdData(double timeOfImpact) override;
77 
78  Math::Aabbd getBoundingBox() const override;
79 
80 private:
81  std::weak_ptr<SurgSim::Physics::RigidRepresentationBase> m_physicsRepresentation;
82  std::shared_ptr<SurgSim::Math::Shape> m_shape;
83  Math::Aabbd m_aabb;
84  Math::RigidTransform3d m_previousCcdPreviousPose;
85 };
86 
87 }; // namespace Collision
88 }; // namespace SurgSim
89 
90 #endif // SURGSIM_PHYSICS_RIGIDCOLLISIONREPRESENTATION_H
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
std::shared_ptr< Math::Shape > getShape() const override
Get the shape.
Definition: RigidCollisionRepresentation.cpp:97
void setRigidRepresentation(std::shared_ptr< SurgSim::Physics::RigidRepresentationBase > representation)
Set rigid representation.
Definition: RigidCollisionRepresentation.cpp:81
void setShape(std::shared_ptr< SurgSim::Math::Shape > shape)
Set the shape The default is to use the shape of the Rigid Representation, this will override that sh...
Definition: RigidCollisionRepresentation.cpp:103
Eigen::Transform< double, 3, Eigen::Isometry > RigidTransform3d
A 3D rigid (isometric) transform, represented as doubles.
Definition: RigidTransform.h:46
SurgSim::Math::RigidTransform3d getPose() const override
Get the pose of the representation in world coordinates.
Definition: RigidCollisionRepresentation.cpp:119
void updateCcdData(double timeOfImpact) override
Update the data (the motionShape) in preparation for a CCD contact calcul ation.
Definition: RigidCollisionRepresentation.cpp:169
bool doInitialize() override
Interface to be implemented by derived classes.
Definition: RigidCollisionRepresentation.cpp:44
std::shared_ptr< SurgSim::Physics::RigidRepresentationBase > getRigidRepresentation()
Gets physics representation.
Definition: RigidCollisionRepresentation.cpp:87
Collision Representation class that wraps a RigidRepresentation, this can be used to strictly tie the...
Definition: RigidCollisionRepresentation.h:35
Math::Aabbd getBoundingBox() const override
Definition: RigidCollisionRepresentation.cpp:235
int getShapeType() const override
Get the shape type id.
Definition: RigidCollisionRepresentation.cpp:92
The type of collision detection.
Definition: Representation.h:60
RigidCollisionRepresentation(const std::string &name)
Constructor.
Definition: RigidCollisionRepresentation.cpp:32
void updateShapeData() override
Update the basic Shape&#39;s state from the physics state, so that the bounding box can correctly be dete...
Definition: RigidCollisionRepresentation.cpp:128
bool doWakeUp() override
Interface to be implemented by derived classes.
Definition: RigidCollisionRepresentation.cpp:57
virtual ~RigidCollisionRepresentation()
Destructor.
Definition: RigidCollisionRepresentation.cpp:40