opensurgsim
Representation.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_REPRESENTATION_H
17 #define SURGSIM_PHYSICS_REPRESENTATION_H
18 
19 #include <string>
20 #include <typeindex>
21 
22 #include "SurgSim/Framework/Representation.h"
23 #include "SurgSim/Math/Vector.h"
24 #include "SurgSim/Physics/ConstraintType.h"
25 
26 namespace SurgSim
27 {
28 
29 namespace DataStructures
30 {
31 struct Location;
32 }
33 
34 namespace Framework
35 {
36 class Logger;
37 }
38 
39 namespace Collision
40 {
41 class Representation;
42 }
43 
44 namespace Physics
45 {
46 
47 class Constraint;
48 class ConstraintData;
49 class ConstraintImplementation;
50 class Localization;
51 
54 {
55 public:
58  explicit Representation(const std::string& name);
59 
61  virtual ~Representation();
62 
64  virtual void resetState();
65 
68  size_t getNumDof() const;
69 
72  void setIsGravityEnabled(bool isGravityEnabled);
73 
76  bool isGravityEnabled() const;
77 
81  void setIsDrivingSceneElementPose(bool isDrivingSceneElementPose);
82 
86  bool isDrivingSceneElementPose();
87 
91  virtual void beforeUpdate(double dt);
92 
95  virtual void update(double dt);
96 
100  virtual void afterUpdate(double dt);
101 
105  virtual std::shared_ptr<Localization> createLocalization(const SurgSim::DataStructures::Location& location);
106 
114  virtual void applyCorrection(double dt, const Eigen::VectorBlock<SurgSim::Math::Vector>& deltaVelocity);
115 
117  std::shared_ptr<SurgSim::Collision::Representation> getCollisionRepresentation() const;
118 
122  virtual void setCollisionRepresentation(std::shared_ptr<SurgSim::Collision::Representation> representation);
123 
127  std::shared_ptr<ConstraintImplementation> getConstraintImplementation(SurgSim::Physics::ConstraintType type);
128 
129 protected:
134  void setNumDof(size_t numDof);
135 
138  const SurgSim::Math::Vector3d& getGravity() const;
139 
141  std::shared_ptr<SurgSim::Collision::Representation> m_collisionRepresentation;
142 
146  void driveSceneElementPose(const SurgSim::Math::RigidTransform3d& pose);
147 
149  std::shared_ptr<SurgSim::Framework::Logger> m_logger;
150 
151 private:
154 
156  Representation& operator =(const Representation&);
157 
159  const SurgSim::Math::Vector3d m_gravity;
160 
162  size_t m_numDof;
163 
165  bool m_isGravityEnabled;
166 
168  bool m_isDrivingSceneElementPose;
169 };
170 
171 }; // namespace Physics
172 
173 }; // namespace SurgSim
174 
175 #endif // SURGSIM_PHYSICS_REPRESENTATION_H
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
std::shared_ptr< SurgSim::Collision::Representation > m_collisionRepresentation
This entity&#39;s collision representation, these are usually very specific to the physics representation...
Definition: Representation.h:141
Eigen::Transform< double, 3, Eigen::Isometry > RigidTransform3d
A 3D rigid (isometric) transform, represented as doubles.
Definition: RigidTransform.h:46
The Representation class defines the base class for all physics objects.
Definition: Representation.h:53
A Location defines a local position w.r.t.
Definition: Location.h:39
Eigen::Matrix< double, 3, 1 > Vector3d
A 3D vector of doubles.
Definition: Vector.h:57
Definitions of small fixed-size vector types.
std::shared_ptr< SurgSim::Framework::Logger > m_logger
Logger for this class.
Definition: Representation.h:149
Representations are manifestations of a SceneElement.
Definition: Representation.h:33