PhysicsManagerState.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_PHYSICSMANAGERSTATE_H
17 #define SURGSIM_PHYSICS_PHYSICSMANAGERSTATE_H
18 
19 #include <memory>
20 #include <vector>
21 #include <unordered_map>
22 
32 
33 
34 namespace SurgSim
35 {
36 namespace Physics
37 {
38 
39 class ConstraintComponent;
40 
42 {
46 };
47 
49 {
50 public:
53 
56 
59  void setRepresentations(const std::vector<std::shared_ptr<Representation>>& val);
60 
63  const std::vector<std::shared_ptr<Representation>>& getRepresentations();
64 
67  void setActiveRepresentations(const std::vector<std::shared_ptr<Representation>>& activeRepresentations);
68 
71  const std::vector<std::shared_ptr<Representation>>& getActiveRepresentations() const;
72 
75  void setCollisionRepresentations(const std::vector<std::shared_ptr<SurgSim::Collision::Representation>>& val);
76 
79  const std::vector<std::shared_ptr<SurgSim::Collision::Representation>>& getCollisionRepresentations();
80 
83  void setActiveCollisionRepresentations(const std::vector<std::shared_ptr<SurgSim::Collision::Representation>>& val);
84 
87  const std::vector<std::shared_ptr<SurgSim::Collision::Representation>>& getActiveCollisionRepresentations();
88 
91  void setParticleRepresentations(const std::vector<std::shared_ptr<SurgSim::Particles::Representation>>& val);
92 
95  const std::vector<std::shared_ptr<SurgSim::Particles::Representation>>& getParticleRepresentations();
96 
99  void setActiveParticleRepresentations(const std::vector<std::shared_ptr<SurgSim::Particles::Representation>>& val);
100 
103  const std::vector<std::shared_ptr<SurgSim::Particles::Representation>>& getActiveParticleRepresentations();
104 
107  void setConstraintComponents(const std::vector<std::shared_ptr<ConstraintComponent>>& val);
108 
111  const std::vector<std::shared_ptr<ConstraintComponent>>& getConstraintComponents();
112 
115  const std::unordered_map<std::shared_ptr<SurgSim::Collision::Representation>,
116  std::shared_ptr<SurgSim::Physics::Representation>>& getCollisionToPhysicsMap() const;
117 
121  void setCollisionPairs(const std::vector<std::shared_ptr<SurgSim::Collision::CollisionPair>>& val);
122 
125  const std::vector<std::shared_ptr<SurgSim::Collision::CollisionPair>>& getCollisionPairs();
126 
129  void setContactFilters(const std::vector<std::shared_ptr<SurgSim::Collision::ContactFilter>>& val);
130 
132  std::vector<std::shared_ptr<SurgSim::Collision::ContactFilter>> getContactFilters() const;
133 
134 
139  void setConstraintGroup(ConstraintGroupType type, const std::vector<std::shared_ptr<Constraint>>& constraints);
140 
144  const std::vector<std::shared_ptr<Constraint>>& getConstraintGroup(int type) const;
145 
148  void setActiveConstraints(const std::vector<std::shared_ptr<Constraint>>& activeConstraints);
149 
151  const std::vector<std::shared_ptr<Constraint>>& getActiveConstraints() const;
152 
156 
159  const MlcpPhysicsProblem& getMlcpProblem() const;
160 
164 
167  const MlcpPhysicsSolution& getMlcpSolution() const;
168 
173 
176  void setRepresentationsMapping(const MlcpMapping<Representation>& representationsMapping);
177 
182 
185  void setConstraintsMapping(const MlcpMapping<Constraint>& constraintsMapping);
186 
189  void setTimeOfImpact(double timeOfImpact);
190 
192  double getTimeOfImpact();
193 
195  bool shouldAbortGroup() const;
196 
199  void setAbortGroup(bool val);
200 
201 private:
202 
208  std::vector<std::shared_ptr<Representation>> m_representations;
209 
211  std::vector<std::shared_ptr<Representation>> m_activeRepresentations;
212 
214  std::vector<std::shared_ptr<SurgSim::Collision::Representation>> m_collisionRepresentations;
215 
217  std::vector<std::shared_ptr<SurgSim::Collision::Representation>> m_activeCollisionRepresentations;
218 
220  std::vector <std::shared_ptr<Collision::ContactFilter>> m_contactFilters;
221 
223  std::vector<std::shared_ptr<SurgSim::Particles::Representation>> m_particleRepresentations;
224 
226  std::vector<std::shared_ptr<SurgSim::Particles::Representation>> m_activeParticleRepresentations;
227 
229  std::vector<std::shared_ptr<ConstraintComponent>> m_constraintComponents;
230 
232  std::unordered_map<std::shared_ptr<SurgSim::Collision::Representation>,
233  std::shared_ptr<SurgSim::Physics::Representation>> m_collisionsToPhysicsMap;
234 
236  std::vector<std::shared_ptr<SurgSim::Collision::CollisionPair>> m_collisionPairs;
237 
239  std::unordered_map<int, std::vector<std::shared_ptr<Constraint>>> m_constraints;
240 
242  std::vector<std::shared_ptr<Constraint>> m_activeConstraints;
243 
246 
249 
253 
256 
259 
262 };
263 
264 }; // Physics
265 }; // SurgSim
266 
267 #endif
SurgSim::Physics::CONSTRAINT_GROUP_TYPE_CONTACT
Definition: PhysicsManagerState.h:43
SurgSim::Physics::PhysicsManagerState::getCollisionPairs
const std::vector< std::shared_ptr< SurgSim::Collision::CollisionPair > > & getCollisionPairs()
Gets collision pairs.
Definition: PhysicsManagerState.cpp:157
CollisionPair.h
SurgSim::Physics::PhysicsManagerState::m_collisionsToPhysicsMap
std::unordered_map< std::shared_ptr< SurgSim::Collision::Representation >, std::shared_ptr< SurgSim::Physics::Representation > > m_collisionsToPhysicsMap
Mapping of collision representations to their respective physics representation.
Definition: PhysicsManagerState.h:233
SurgSim::Physics::PhysicsManagerState::m_constraintsIndexMapping
MlcpMapping< Constraint > m_constraintsIndexMapping
Constraints mapping.
Definition: PhysicsManagerState.h:248
SurgSim::Physics::PhysicsManagerState::m_contactFilters
std::vector< std::shared_ptr< Collision::ContactFilter > > m_contactFilters
List of all the collision filters known to the state.
Definition: PhysicsManagerState.h:220
Representation.h
SurgSim::Physics::PhysicsManagerState::shouldAbortGroup
bool shouldAbortGroup() const
Definition: PhysicsManagerState.cpp:250
SurgSim::Physics::PhysicsManagerState::getTimeOfImpact
double getTimeOfImpact()
Definition: PhysicsManagerState.cpp:245
SurgSim::Physics::PhysicsManagerState::~PhysicsManagerState
~PhysicsManagerState()
Destructor.
Definition: PhysicsManagerState.cpp:36
SurgSim::Physics::PhysicsManagerState::getCollisionRepresentations
const std::vector< std::shared_ptr< SurgSim::Collision::Representation > > & getCollisionRepresentations()
Gets the collision representations.
Definition: PhysicsManagerState.cpp:90
Constraint.h
SurgSim::Physics::PhysicsManagerState::PhysicsManagerState
PhysicsManagerState()
Constructor.
Definition: PhysicsManagerState.cpp:29
SurgSim::Physics::PhysicsManagerState::getRepresentations
const std::vector< std::shared_ptr< Representation > > & getRepresentations()
Gets the physics representations.
Definition: PhysicsManagerState.cpp:59
SurgSim::Physics::MlcpPhysicsProblem
A description of a physical mixed LCP system to be solved.
Definition: MlcpPhysicsProblem.h:43
SurgSim::Physics::PhysicsManagerState::setAbortGroup
void setAbortGroup(bool val)
Set whether to abort the current grouped computation.
Definition: PhysicsManagerState.cpp:255
SurgSim::Physics::PhysicsManagerState::m_constraintComponents
std::vector< std::shared_ptr< ConstraintComponent > > m_constraintComponents
List of the constraint components.
Definition: PhysicsManagerState.h:229
SurgSim::Physics::PhysicsManagerState::setConstraintGroup
void setConstraintGroup(ConstraintGroupType type, const std::vector< std::shared_ptr< Constraint >> &constraints)
Sets the group of constraints to a given value, the grouping indicates what type of constraint we are...
Definition: PhysicsManagerState.cpp:172
SurgSim::Physics::PhysicsManagerState::m_activeParticleRepresentations
std::vector< std::shared_ptr< SurgSim::Particles::Representation > > m_activeParticleRepresentations
List of all the active particle representations known to the state.
Definition: PhysicsManagerState.h:226
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Physics::PhysicsManagerState::m_representations
std::vector< std::shared_ptr< Representation > > m_representations
Definition: PhysicsManagerState.h:208
SurgSim::Physics::PhysicsManagerState::setCollisionRepresentations
void setCollisionRepresentations(const std::vector< std::shared_ptr< SurgSim::Collision::Representation >> &val)
Sets the collision representations for the state.
Definition: PhysicsManagerState.cpp:83
SurgSim::Physics::PhysicsManagerState::getCollisionToPhysicsMap
const std::unordered_map< std::shared_ptr< SurgSim::Collision::Representation >, std::shared_ptr< SurgSim::Physics::Representation > > & getCollisionToPhysicsMap() const
Definition: PhysicsManagerState.cpp:78
SurgSim::Physics::PhysicsManagerState::m_activeRepresentations
std::vector< std::shared_ptr< Representation > > m_activeRepresentations
The list of active representations.
Definition: PhysicsManagerState.h:211
MlcpMapping.h
SurgSim::Physics::PhysicsManagerState::getParticleRepresentations
const std::vector< std::shared_ptr< SurgSim::Particles::Representation > > & getParticleRepresentations()
Gets the particle representations.
Definition: PhysicsManagerState.cpp:112
SurgSim::Physics::PhysicsManagerState::getMlcpSolution
MlcpPhysicsSolution & getMlcpSolution()
Gets the Mlcp solution.
Definition: PhysicsManagerState.cpp:210
SurgSim::Physics::PhysicsManagerState::setTimeOfImpact
void setTimeOfImpact(double timeOfImpact)
Set the time of impact.
Definition: PhysicsManagerState.cpp:240
SurgSim::Physics::MlcpPhysicsSolution
The description of a solution to a physical MLCP problem.
Definition: MlcpPhysicsSolution.h:34
SurgSim::Physics::PhysicsManagerState::setActiveConstraints
void setActiveConstraints(const std::vector< std::shared_ptr< Constraint >> &activeConstraints)
Filter the map of constraints into the active constraints list.
Definition: PhysicsManagerState.cpp:189
SurgSim::Physics::PhysicsManagerState::setCollisionPairs
void setCollisionPairs(const std::vector< std::shared_ptr< SurgSim::Collision::CollisionPair >> &val)
Sets collision pairs that should be considered, while this is not being verified the collision pairs ...
Definition: PhysicsManagerState.cpp:152
SurgSim::Physics::CONSTRAINT_GROUP_TYPE_COUNT
Definition: PhysicsManagerState.h:45
SurgSim::Physics::PhysicsManagerState::getActiveCollisionRepresentations
const std::vector< std::shared_ptr< SurgSim::Collision::Representation > > & getActiveCollisionRepresentations()
Gets the list of active collision representations.
Definition: PhysicsManagerState.cpp:102
SurgSim::Physics::PhysicsManagerState::getActiveConstraints
const std::vector< std::shared_ptr< Constraint > > & getActiveConstraints() const
Definition: PhysicsManagerState.cpp:195
SurgSim::Physics::PhysicsManagerState::setActiveRepresentations
void setActiveRepresentations(const std::vector< std::shared_ptr< Representation >> &activeRepresentations)
Set the list of representations into the active representations list.
Definition: PhysicsManagerState.cpp:64
SurgSim::Physics::PhysicsManagerState::setActiveCollisionRepresentations
void setActiveCollisionRepresentations(const std::vector< std::shared_ptr< SurgSim::Collision::Representation >> &val)
Sets the active collision representations for the state.
Definition: PhysicsManagerState.cpp:95
SurgSim::Physics::PhysicsManagerState::setConstraintsMapping
void setConstraintsMapping(const MlcpMapping< Constraint > &constraintsMapping)
Set the constraints mapping.
Definition: PhysicsManagerState.cpp:235
SurgSim::Physics::PhysicsManagerState::getConstraintGroup
const std::vector< std::shared_ptr< Constraint > > & getConstraintGroup(int type) const
Gets constraint group.
Definition: PhysicsManagerState.cpp:179
SurgSim::Physics::PhysicsManagerState::setActiveParticleRepresentations
void setActiveParticleRepresentations(const std::vector< std::shared_ptr< SurgSim::Particles::Representation >> &val)
Sets the active particle representations for the state.
Definition: PhysicsManagerState.cpp:117
SurgSim::Physics::PhysicsManagerState::getActiveRepresentations
const std::vector< std::shared_ptr< Representation > > & getActiveRepresentations() const
Gets the active physics representations.
Definition: PhysicsManagerState.cpp:70
SurgSim::Physics::MlcpMapping
Definition: MlcpMapping.h:27
SurgSim::Physics::PhysicsManagerState::m_particleRepresentations
std::vector< std::shared_ptr< SurgSim::Particles::Representation > > m_particleRepresentations
List of all the particle representations known to the state.
Definition: PhysicsManagerState.h:223
SurgSim::Physics::PhysicsManagerState
Definition: PhysicsManagerState.h:48
SurgSim::Physics::PhysicsManagerState::setContactFilters
void setContactFilters(const std::vector< std::shared_ptr< SurgSim::Collision::ContactFilter >> &val)
Set the list of contact filters.
Definition: PhysicsManagerState.cpp:162
MlcpPhysicsSolution.h
SurgSim::Physics::PhysicsManagerState::setRepresentations
void setRepresentations(const std::vector< std::shared_ptr< Representation >> &val)
Sets the physics representations for the state, these are the basis for all the computations.
Definition: PhysicsManagerState.cpp:41
ContactFilter.h
SurgSim::Physics::PhysicsManagerState::m_mlcpPhysicsSolution
MlcpPhysicsSolution m_mlcpPhysicsSolution
Mlcp solution for this Physics Manager State.
Definition: PhysicsManagerState.h:255
SurgSim::Physics::PhysicsManagerState::m_constraints
std::unordered_map< int, std::vector< std::shared_ptr< Constraint > > > m_constraints
The local map of constraints.
Definition: PhysicsManagerState.h:239
SurgSim::Physics::PhysicsManagerState::setConstraintComponents
void setConstraintComponents(const std::vector< std::shared_ptr< ConstraintComponent >> &val)
Sets the list of constraint components.
Definition: PhysicsManagerState.cpp:128
SurgSim::Physics::PhysicsManagerState::getContactFilters
std::vector< std::shared_ptr< SurgSim::Collision::ContactFilter > > getContactFilters() const
Definition: PhysicsManagerState.cpp:167
SurgSim::Physics::ConstraintGroupType
ConstraintGroupType
Definition: PhysicsManagerState.h:41
SurgSim::Physics::PhysicsManagerState::m_mlcpPhysicsProblem
MlcpPhysicsProblem m_mlcpPhysicsProblem
Mlcp problem for this Physics Manager State.
Definition: PhysicsManagerState.h:252
Representation.h
SurgSim::Physics::PhysicsManagerState::getConstraintComponents
const std::vector< std::shared_ptr< ConstraintComponent > > & getConstraintComponents()
Gets the constraint components.
Definition: PhysicsManagerState.cpp:147
SurgSim::Physics::PhysicsManagerState::m_representationsIndexMapping
MlcpMapping< Representation > m_representationsIndexMapping
Representation mapping.
Definition: PhysicsManagerState.h:245
SurgSim::Physics::PhysicsManagerState::getConstraintsMapping
const MlcpMapping< Constraint > & getConstraintsMapping() const
Gets the constraints mapping.
Definition: PhysicsManagerState.cpp:230
SurgSim::Physics::PhysicsManagerState::getActiveParticleRepresentations
const std::vector< std::shared_ptr< SurgSim::Particles::Representation > > & getActiveParticleRepresentations()
Gets the list of active particle representations.
Definition: PhysicsManagerState.cpp:123
SurgSim::Physics::PhysicsManagerState::getMlcpProblem
MlcpPhysicsProblem & getMlcpProblem()
Gets the Mlcp problem.
Definition: PhysicsManagerState.cpp:200
SurgSim::Physics::PhysicsManagerState::m_collisionPairs
std::vector< std::shared_ptr< SurgSim::Collision::CollisionPair > > m_collisionPairs
The local list of collision pairs.
Definition: PhysicsManagerState.h:236
SurgSim::Physics::PhysicsManagerState::m_collisionRepresentations
std::vector< std::shared_ptr< SurgSim::Collision::Representation > > m_collisionRepresentations
List of all the collision representations known to the state.
Definition: PhysicsManagerState.h:214
SurgSim::Physics::CONSTRAINT_GROUP_TYPE_SCENE
Definition: PhysicsManagerState.h:44
SurgSim::Physics::PhysicsManagerState::m_abortGroup
bool m_abortGroup
Flag for the abort group case.
Definition: PhysicsManagerState.h:258
Representation.h
SurgSim::Physics::PhysicsManagerState::getRepresentationsMapping
const MlcpMapping< Representation > & getRepresentationsMapping() const
Gets the representations mapping.
Definition: PhysicsManagerState.cpp:220
SurgSim::Physics::PhysicsManagerState::m_activeCollisionRepresentations
std::vector< std::shared_ptr< SurgSim::Collision::Representation > > m_activeCollisionRepresentations
List of all the active collision representations known to the state.
Definition: PhysicsManagerState.h:217
SurgSim::Physics::PhysicsManagerState::setRepresentationsMapping
void setRepresentationsMapping(const MlcpMapping< Representation > &representationsMapping)
Set the representations mapping.
Definition: PhysicsManagerState.cpp:225
SurgSim::Physics::PhysicsManagerState::m_timeOfImpact
double m_timeOfImpact
last time of impact for a CCD calculation
Definition: PhysicsManagerState.h:261
MlcpPhysicsProblem.h
SurgSim::Physics::PhysicsManagerState::setParticleRepresentations
void setParticleRepresentations(const std::vector< std::shared_ptr< SurgSim::Particles::Representation >> &val)
Sets the particle representations for the state.
Definition: PhysicsManagerState.cpp:107
SurgSim::Physics::PhysicsManagerState::m_activeConstraints
std::vector< std::shared_ptr< Constraint > > m_activeConstraints
The list of active constraints.
Definition: PhysicsManagerState.h:242