Constraint.h
Go to the documentation of this file.
// This file is a part of the OpenSurgSim project.
// Copyright 2013, 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_CONSTRAINT_H
#define SURGSIM_PHYSICS_CONSTRAINT_H
#include "SurgSim/DataStructures/Location.h"
#include "SurgSim/Physics/ConstraintData.h"
#include "SurgSim/Physics/ConstraintImplementation.h"
#include "SurgSim/Physics/MlcpPhysicsProblem.h"
#include <array>
#include <memory>
namespace SurgSim
{
namespace Physics
{
class Constraint
{
public:
Constraint(
ConstraintType constraintType,
std::shared_ptr<ConstraintData> data,
std::shared_ptr<Representation> representation0,
const SurgSim::DataStructures::Location& location0,
std::shared_ptr<Representation> representation1,
const SurgSim::DataStructures::Location& location1);
virtual ~Constraint();
void setInformation(
ConstraintType constraintType,
std::shared_ptr<ConstraintData> data,
std::shared_ptr<Representation> representation0,
const SurgSim::DataStructures::Location& location0,
std::shared_ptr<Representation> representation1,
const SurgSim::DataStructures::Location& location1);
const std::pair<std::shared_ptr<ConstraintImplementation>, std::shared_ptr<ConstraintImplementation>>&
getImplementations() const;
const std::pair<std::shared_ptr<Localization>, std::shared_ptr<Localization>>&
getLocalizations() const;
std::shared_ptr<ConstraintData> getData() const;
size_t getNumDof() const;
ConstraintType getType();
void build(double dt,
MlcpPhysicsProblem* mlcpPhysicsProblem,
size_t indexOfRepresentation0,
size_t indexOfRepresentation1,
size_t indexOfConstraint);
bool isActive();
void setActive(bool flag);
protected:
std::array<Math::MlcpConstraintType, NUM_CONSTRAINT_TYPES> m_mlcpMap;
std::shared_ptr<ConstraintData> m_data;
std::pair<std::shared_ptr<ConstraintImplementation>, std::shared_ptr<ConstraintImplementation>> m_implementations;
std::pair<std::shared_ptr<Localization>, std::shared_ptr<Localization>> m_localizations;
size_t m_numDof;
ConstraintType m_constraintType;
virtual void doBuild(double dt,
const ConstraintData& data,
MlcpPhysicsProblem* mlcpPhysicsProblem,
size_t indexOfRepresentation0,
size_t indexOfRepresentation1,
size_t indexOfConstraint);
bool m_active;
};
}; // namespace Physics
}; // namespace SurgSim
#endif // SURGSIM_PHYSICS_CONSTRAINT_H
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Physics::Constraint::setActive
void setActive(bool flag)
Definition: Constraint.cpp:93
SurgSim::Physics::Constraint::m_implementations
std::pair< std::shared_ptr< ConstraintImplementation >, std::shared_ptr< ConstraintImplementation > > m_implementations
Pair of implementations defining the 2 sides of the constraint.
Definition: Constraint.h:116
SurgSim::Physics::MlcpPhysicsProblem
A description of a physical mixed LCP system to be solved.
Definition: MlcpPhysicsProblem.h:43
SurgSim::DataStructures::Location
A Location defines a local position w.r.t.
Definition: Location.h:39
SurgSim::Physics::Constraint::m_numDof
size_t m_numDof
The degrees of freedom that this constraint has.
Definition: Constraint.h:120
SurgSim::Physics::Constraint::isActive
bool isActive()
Definition: Constraint.cpp:87
SurgSim::Physics::Constraint::m_active
bool m_active
Flag to indicate whether this constraint is active or not.
Definition: Constraint.h:140
SurgSim::Physics::Constraint::build
void build(double dt, MlcpPhysicsProblem *mlcpPhysicsProblem, size_t indexOfRepresentation0, size_t indexOfRepresentation1, size_t indexOfConstraint)
Builds subset of an Mlcp physics problem associated to this constraint.
Definition: Constraint.cpp:78
SurgSim::Physics::ConstraintData
Base class for all CosntraintData Derived classes should be specific to a given constraint.
Definition: ConstraintData.h:27
SurgSim::Physics::Constraint::getType
ConstraintType getType()
Gets the ConstraintType.
Definition: Constraint.cpp:73
ConstraintImplementation.h
MlcpPhysicsProblem.h
SurgSim::Physics::Constraint::~Constraint
virtual ~Constraint()
Destructor.
Definition: Constraint.cpp:46
SurgSim::Physics::Constraint::m_localizations
std::pair< std::shared_ptr< Localization >, std::shared_ptr< Localization > > m_localizations
Definition: Constraint.h:117
SurgSim::Physics::Constraint::getLocalizations
const std::pair< std::shared_ptr< Localization >, std::shared_ptr< Localization > > & getLocalizations() const
Gets both sides Localization as a pair.
Definition: Constraint.cpp:57
SurgSim::Physics::Constraint::doBuild
virtual void doBuild(double dt, const ConstraintData &data, MlcpPhysicsProblem *mlcpPhysicsProblem, size_t indexOfRepresentation0, size_t indexOfRepresentation1, size_t indexOfConstraint)
Builds subset of an Mlcp physics problem associated to this constraint user-defined call for extra tr...
Definition: Constraint.cpp:98
SurgSim::Physics::Constraint::setInformation
void setInformation(ConstraintType constraintType, std::shared_ptr< ConstraintData > data, std::shared_ptr< Representation > representation0, const SurgSim::DataStructures::Location &location0, std::shared_ptr< Representation > representation1, const SurgSim::DataStructures::Location &location1)
Sets all the values for this constraints, does validation on the parameters and will throw if somethi...
Definition: Constraint.cpp:127
SurgSim::Physics::Constraint
Base class for all physics constraints. Contains data specific to the constraint and a pair of implem...
Definition: Constraint.h:34
SurgSim::Physics::Constraint::getImplementations
const std::pair< std::shared_ptr< ConstraintImplementation >, std::shared_ptr< ConstraintImplementation > > & getImplementations() const
Gets both sides implementation as a pair.
Definition: Constraint.cpp:52
SurgSim::Physics::Constraint::m_data
std::shared_ptr< ConstraintData > m_data
Specific data associated to this constraint.
Definition: Constraint.h:113
SurgSim::Physics::Constraint::getData
std::shared_ptr< ConstraintData > getData() const
Gets the data associated to this constraint.
Definition: Constraint.cpp:63
ConstraintData.h
SurgSim::Physics::Constraint::Constraint
Constraint(ConstraintType constraintType, std::shared_ptr< ConstraintData > data, std::shared_ptr< Representation > representation0, const SurgSim::DataStructures::Location &location0, std::shared_ptr< Representation > representation1, const SurgSim::DataStructures::Location &location1)
Sets all the values for this constraints, does validation on the parameters and will throw if somethi...
Definition: Constraint.cpp:29
Location.h
SurgSim::Physics::ConstraintType
ConstraintType
Definition: ConstraintType.h:24
SurgSim::Physics::Constraint::m_mlcpMap
std::array< Math::MlcpConstraintType, NUM_CONSTRAINT_TYPES > m_mlcpMap
Constraint-MLCP mapping.
Definition: Constraint.h:110
SurgSim::Physics::Constraint::getNumDof
size_t getNumDof() const
Gets the number of degree of freedom for this constraint.
Definition: Constraint.cpp:68
SurgSim::Physics::Constraint::m_constraintType
ConstraintType m_constraintType
The type of this constraint.
Definition: Constraint.h:123