PhysicsManagerState.h
Go to the documentation of this file.
// This file is a part of the OpenSurgSim project.
// Copyright 2013-2015, SimQuest Solutions Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SURGSIM_PHYSICS_PHYSICSMANAGERSTATE_H
#define SURGSIM_PHYSICS_PHYSICSMANAGERSTATE_H
#include <memory>
#include <vector>
#include <unordered_map>
#include "SurgSim/Collision/CollisionPair.h"
#include "SurgSim/Collision/ContactFilter.h"
#include "SurgSim/Collision/Representation.h"
#include "SurgSim/Particles/Representation.h"
#include "SurgSim/Physics/Constraint.h"
#include "SurgSim/Physics/MlcpMapping.h"
#include "SurgSim/Physics/MlcpPhysicsProblem.h"
#include "SurgSim/Physics/MlcpPhysicsSolution.h"
#include "SurgSim/Physics/Representation.h"
namespace SurgSim
{
namespace Physics
{
class ConstraintComponent;
enum ConstraintGroupType
{
CONSTRAINT_GROUP_TYPE_CONTACT = 0,
CONSTRAINT_GROUP_TYPE_SCENE,
CONSTRAINT_GROUP_TYPE_COUNT
};
class PhysicsManagerState
{
public:
PhysicsManagerState();
~PhysicsManagerState();
void setRepresentations(const std::vector<std::shared_ptr<Representation>>& val);
const std::vector<std::shared_ptr<Representation>>& getRepresentations();
void setActiveRepresentations(const std::vector<std::shared_ptr<Representation>>& activeRepresentations);
const std::vector<std::shared_ptr<Representation>>& getActiveRepresentations() const;
void setCollisionRepresentations(const std::vector<std::shared_ptr<SurgSim::Collision::Representation>>& val);
const std::vector<std::shared_ptr<SurgSim::Collision::Representation>>& getCollisionRepresentations();
void setActiveCollisionRepresentations(const std::vector<std::shared_ptr<SurgSim::Collision::Representation>>& val);
const std::vector<std::shared_ptr<SurgSim::Collision::Representation>>& getActiveCollisionRepresentations();
void setParticleRepresentations(const std::vector<std::shared_ptr<SurgSim::Particles::Representation>>& val);
const std::vector<std::shared_ptr<SurgSim::Particles::Representation>>& getParticleRepresentations();
void setActiveParticleRepresentations(const std::vector<std::shared_ptr<SurgSim::Particles::Representation>>& val);
const std::vector<std::shared_ptr<SurgSim::Particles::Representation>>& getActiveParticleRepresentations();
void setConstraintComponents(const std::vector<std::shared_ptr<ConstraintComponent>>& val);
const std::vector<std::shared_ptr<ConstraintComponent>>& getConstraintComponents();
const std::unordered_map<std::shared_ptr<SurgSim::Collision::Representation>,
std::shared_ptr<SurgSim::Physics::Representation>>& getCollisionToPhysicsMap() const;
void setCollisionPairs(const std::vector<std::shared_ptr<SurgSim::Collision::CollisionPair>>& val);
const std::vector<std::shared_ptr<SurgSim::Collision::CollisionPair>>& getCollisionPairs();
void setContactFilters(const std::vector<std::shared_ptr<SurgSim::Collision::ContactFilter>>& val);
std::vector<std::shared_ptr<SurgSim::Collision::ContactFilter>> getContactFilters() const;
void setConstraintGroup(ConstraintGroupType type, const std::vector<std::shared_ptr<Constraint>>& constraints);
const std::vector<std::shared_ptr<Constraint>>& getConstraintGroup(int type) const;
void setActiveConstraints(const std::vector<std::shared_ptr<Constraint>>& activeConstraints);
const std::vector<std::shared_ptr<Constraint>>& getActiveConstraints() const;
MlcpPhysicsProblem& getMlcpProblem();
const MlcpPhysicsProblem& getMlcpProblem() const;
MlcpPhysicsSolution& getMlcpSolution();
const MlcpPhysicsSolution& getMlcpSolution() const;
const MlcpMapping<Representation>& getRepresentationsMapping() const;
void setRepresentationsMapping(const MlcpMapping<Representation>& representationsMapping);
const MlcpMapping<Constraint>& getConstraintsMapping() const;
void setConstraintsMapping(const MlcpMapping<Constraint>& constraintsMapping);
void setTimeOfImpact(double timeOfImpact);
double getTimeOfImpact();
bool shouldAbortGroup() const;
void setAbortGroup(bool val);
private:
std::vector<std::shared_ptr<Representation>> m_representations;
std::vector<std::shared_ptr<Representation>> m_activeRepresentations;
std::vector<std::shared_ptr<SurgSim::Collision::Representation>> m_collisionRepresentations;
std::vector<std::shared_ptr<SurgSim::Collision::Representation>> m_activeCollisionRepresentations;
std::vector <std::shared_ptr<Collision::ContactFilter>> m_contactFilters;
std::vector<std::shared_ptr<SurgSim::Particles::Representation>> m_particleRepresentations;
std::vector<std::shared_ptr<SurgSim::Particles::Representation>> m_activeParticleRepresentations;
std::vector<std::shared_ptr<ConstraintComponent>> m_constraintComponents;
std::unordered_map<std::shared_ptr<SurgSim::Collision::Representation>,
std::shared_ptr<SurgSim::Physics::Representation>> m_collisionsToPhysicsMap;
std::vector<std::shared_ptr<SurgSim::Collision::CollisionPair>> m_collisionPairs;
std::unordered_map<int, std::vector<std::shared_ptr<Constraint>>> m_constraints;
std::vector<std::shared_ptr<Constraint>> m_activeConstraints;
MlcpMapping<Representation> m_representationsIndexMapping;
MlcpMapping<Constraint> m_constraintsIndexMapping;
MlcpPhysicsProblem m_mlcpPhysicsProblem;
MlcpPhysicsSolution m_mlcpPhysicsSolution;
bool m_abortGroup;
double m_timeOfImpact;
};
}; // Physics
}; // SurgSim
#endif
Representation.h
Representation.h
SurgSim::Physics::PhysicsManagerState::getRepresentations
const std::vector< std::shared_ptr< Representation > > & getRepresentations()
Gets the physics representations.
Definition: PhysicsManagerState.cpp:59
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
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::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::getRepresentationsMapping
const MlcpMapping< Representation > & getRepresentationsMapping() const
Gets the representations mapping.
Definition: PhysicsManagerState.cpp:220
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
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::ConstraintGroupType
ConstraintGroupType
Definition: PhysicsManagerState.h:41
SurgSim::Physics::PhysicsManagerState::m_activeConstraints
std::vector< std::shared_ptr< Constraint > > m_activeConstraints
The list of active constraints.
Definition: PhysicsManagerState.h:242
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
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::getCollisionPairs
const std::vector< std::shared_ptr< SurgSim::Collision::CollisionPair > > & getCollisionPairs()
Gets collision pairs.
Definition: PhysicsManagerState.cpp:157
MlcpMapping.h
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
MlcpPhysicsSolution.h
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
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::getActiveRepresentations
const std::vector< std::shared_ptr< Representation > > & getActiveRepresentations() const
Gets the active physics representations.
Definition: PhysicsManagerState.cpp:70
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
SurgSim::Physics::PhysicsManagerState::shouldAbortGroup
bool shouldAbortGroup() const
Definition: PhysicsManagerState.cpp:250
MlcpPhysicsProblem.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
SurgSim::Physics::PhysicsManagerState::getTimeOfImpact
double getTimeOfImpact()
Definition: PhysicsManagerState.cpp:245
SurgSim::Physics::PhysicsManagerState::getCollisionRepresentations
const std::vector< std::shared_ptr< SurgSim::Collision::Representation > > & getCollisionRepresentations()
Gets the collision representations.
Definition: PhysicsManagerState.cpp:90
SurgSim::Physics::PhysicsManagerState::PhysicsManagerState
PhysicsManagerState()
Constructor.
Definition: PhysicsManagerState.cpp:29
SurgSim::Physics::PhysicsManagerState::getContactFilters
std::vector< std::shared_ptr< SurgSim::Collision::ContactFilter > > getContactFilters() const
Definition: PhysicsManagerState.cpp:167
SurgSim::Physics::CONSTRAINT_GROUP_TYPE_CONTACT
Definition: PhysicsManagerState.h:43
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::getConstraintComponents
const std::vector< std::shared_ptr< ConstraintComponent > > & getConstraintComponents()
Gets the constraint components.
Definition: PhysicsManagerState.cpp:147
Representation.h
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::Physics::PhysicsManagerState::m_representations
std::vector< std::shared_ptr< Representation > > m_representations
Definition: PhysicsManagerState.h:208
SurgSim::Physics::CONSTRAINT_GROUP_TYPE_SCENE
Definition: PhysicsManagerState.h:44
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::getMlcpSolution
MlcpPhysicsSolution & getMlcpSolution()
Gets the Mlcp solution.
Definition: PhysicsManagerState.cpp:210
SurgSim::Physics::PhysicsManagerState::getMlcpProblem
MlcpPhysicsProblem & getMlcpProblem()
Gets the Mlcp problem.
Definition: PhysicsManagerState.cpp:200
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::m_abortGroup
bool m_abortGroup
Flag for the abort group case.
Definition: PhysicsManagerState.h:258
Constraint.h
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::PhysicsManagerState::getActiveConstraints
const std::vector< std::shared_ptr< Constraint > > & getActiveConstraints() const
Definition: PhysicsManagerState.cpp:195
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::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::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
Definition: PhysicsManagerState.h:48
ContactFilter.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::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::CONSTRAINT_GROUP_TYPE_COUNT
Definition: PhysicsManagerState.h:45
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_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
CollisionPair.h
SurgSim::Physics::PhysicsManagerState::m_mlcpPhysicsProblem
MlcpPhysicsProblem m_mlcpPhysicsProblem
Mlcp problem for this Physics Manager State.
Definition: PhysicsManagerState.h:252
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::~PhysicsManagerState
~PhysicsManagerState()
Destructor.
Definition: PhysicsManagerState.cpp:36