PhysicsManager.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_PHYSICS_PHYSICSMANAGER_H
17 #define SURGSIM_PHYSICS_PHYSICSMANAGER_H
18 
19 #include <boost/thread/mutex.hpp>
20 
21 #include <list>
22 #include <memory>
23 #include <vector>
24 
28 
29 
30 namespace SurgSim
31 {
32 
33 namespace Collision
34 {
35 class CollisionPair;
36 class Representation;
37 class ContactFilter;
38 }
39 
40 namespace Framework
41 {
42 class Component;
43 }
44 
45 namespace Particles
46 {
47 class Representation;
48 }
49 
50 namespace Physics
51 {
52 
53 class Computation;
54 
60 {
61 public:
62 
65  virtual ~PhysicsManager();
66 
68  int getType() const override;
69 
70  friend class PhysicsManagerTest;
71 
75  void getFinalState(SurgSim::Physics::PhysicsManagerState* s) const;
76 
80  void addComputation(std::shared_ptr<SurgSim::Physics::Computation> computation);
81 
85  void setComputations(std::vector<std::shared_ptr<Physics::Computation>> computations);
86 
87 protected:
88  bool executeAdditions(const std::shared_ptr<SurgSim::Framework::Component>& component) override;
89 
90  bool executeRemovals(const std::shared_ptr<SurgSim::Framework::Component>& component) override;
91 
96  bool doInitialize() override;
97 
98  bool doStartUp() override;
99 
100  bool doUpdate(double dt) override;
101 
102  void doBeforeStop() override;
103 
104  std::vector<std::shared_ptr<Representation>> m_representations;
105 
106  std::vector<std::shared_ptr<Collision::Representation>> m_collisionRepresentations;
107 
108  std::vector<std::shared_ptr<Collision::ContactFilter>> m_contactFilters;
109 
110  std::vector<std::shared_ptr<Particles::Representation>> m_particleRepresentations;
111 
112  std::vector<std::shared_ptr<ConstraintComponent>> m_constraintComponents;
113 
114 
116  std::vector<std::shared_ptr<SurgSim::Physics::Computation>> m_computations;
117 
120 };
121 
124 std::vector<std::shared_ptr<Physics::Computation>> createDcdPipeline(bool copyState = false);
125 
128 std::vector<std::shared_ptr<Physics::Computation>> createCcdPipeline(bool copyState = false);
129 }; // namespace Physics
130 }; // namespace SurgSim
131 
132 #endif
Definition: CompoundShapeToGraphics.cpp:29
std::vector< std::shared_ptr< Particles::Representation > > m_particleRepresentations
Definition: PhysicsManager.h:110
PhyicsManager handles the physics and motion calculation, it uses Computations to separate the algori...
Definition: PhysicsManager.h:59
Base Component Manager class.
Definition: ComponentManager.h:49
DataStructures::Vertices< ParticleData > Particles
Definition: Particles.h:53
std::vector< std::shared_ptr< Physics::Computation > > createDcdPipeline(bool copyState)
Creates default DCD pipeline, this currently does basic DCD without regard to CCD.
Definition: PhysicsManager.cpp:174
std::vector< std::shared_ptr< Collision::ContactFilter > > m_contactFilters
Definition: PhysicsManager.h:108
std::vector< std::shared_ptr< Representation > > m_representations
Definition: PhysicsManager.h:104
Definition: PhysicsManagerState.h:48
std::vector< std::shared_ptr< Physics::Computation > > createCcdPipeline(bool copyState)
Create default CCD pipeline, this currently does basic CCD without regard to DCD. ...
Definition: PhysicsManager.cpp:196
std::vector< std::shared_ptr< SurgSim::Physics::Computation > > m_computations
A list of computations, to perform the physics update.
Definition: PhysicsManager.h:116
SurgSim::Framework::LockedContainer< SurgSim::Physics::PhysicsManagerState > m_finalState
A thread-safe copy of the last PhysicsManagerState in the previous update.
Definition: PhysicsManager.h:119
std::vector< std::shared_ptr< Collision::Representation > > m_collisionRepresentations
Definition: PhysicsManager.h:106
std::vector< std::shared_ptr< ConstraintComponent > > m_constraintComponents
Definition: PhysicsManager.h:112