All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Constraint.h
Go to the documentation of this file.
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_CONSTRAINT_H
17 #define SURGSIM_PHYSICS_CONSTRAINT_H
18 
22 
23 #include <memory>
24 
25 namespace SurgSim
26 {
27 
28 namespace Physics
29 {
30 
33 {
34 public:
40  Constraint(
41  std::shared_ptr<ConstraintData> data,
42  std::shared_ptr<ConstraintImplementation> implementation0,
43  std::shared_ptr<Localization> localization0,
44  std::shared_ptr<ConstraintImplementation> implementation1,
45  std::shared_ptr<Localization> localization1);
46 
48  virtual ~Constraint();
49 
55  void setInformation(
56  std::shared_ptr<ConstraintData> data,
57  std::shared_ptr<ConstraintImplementation> implementation0,
58  std::shared_ptr<Localization> localization0,
59  std::shared_ptr<ConstraintImplementation> implementation1,
60  std::shared_ptr<Localization> localization1);
61 
64  const std::pair<std::shared_ptr<ConstraintImplementation>, std::shared_ptr<ConstraintImplementation>>&
65  getImplementations() const;
66 
69  const std::pair<std::shared_ptr<Localization>, std::shared_ptr<Localization>>&
70  getLocalizations() const;
71 
74  std::shared_ptr<ConstraintData> getData() const;
75 
78  size_t getNumDof() const;
79 
83 
90  void build(double dt,
91  MlcpPhysicsProblem* mlcpPhysicsProblem,
92  size_t indexOfRepresentation0,
93  size_t indexOfRepresentation1,
94  size_t indexOfConstraint);
95 
97  bool isActive();
98 
99 private:
101  std::shared_ptr<ConstraintData> m_data;
102 
104  std::pair<std::shared_ptr<ConstraintImplementation>, std::shared_ptr<ConstraintImplementation>> m_implementations;
105  std::pair<std::shared_ptr<Localization>, std::shared_ptr<Localization>> m_localizations;
106 
108  size_t m_numDof;
109 
112 
120  virtual void doBuild(double dt,
121  const ConstraintData& data,
122  MlcpPhysicsProblem* mlcpPhysicsProblem,
123  size_t indexOfRepresentation0,
124  size_t indexOfRepresentation1,
125  size_t indexOfConstraint);
126 };
127 
128 }; // namespace Physics
129 
130 }; // namespace SurgSim
131 
132 #endif // SURGSIM_PHYSICS_CONSTRAINT_H
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:104
A description of a physical mixed LCP system to be solved.
Definition: MlcpPhysicsProblem.h:43
Constraint(std::shared_ptr< ConstraintData > data, std::shared_ptr< ConstraintImplementation > implementation0, std::shared_ptr< Localization > localization0, std::shared_ptr< ConstraintImplementation > implementation1, std::shared_ptr< Localization > localization1)
Sets all the values for this constraints, does validation on the parameters and will throw it somethi...
Definition: Constraint.cpp:28
size_t m_numDof
The degrees of freedom that this constraint has.
Definition: Constraint.h:108
bool isActive()
Definition: Constraint.cpp:99
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:70
Base class for all CosntraintData Derived classes should be specific to a given constraint.
Definition: ConstraintData.h:27
SurgSim::Math::MlcpConstraintType getType()
Gets the ConstraintType for this constraint.
Definition: Constraint.cpp:65
SurgSim::Math::MlcpConstraintType m_constraintType
The type of this constraint.
Definition: Constraint.h:111
size_t getNumDof() const
Gets the number of degree of freedom for this constraint.
Definition: Constraint.cpp:60
std::shared_ptr< ConstraintData > getData() const
Gets the data associated to this constraint.
Definition: Constraint.cpp:55
virtual ~Constraint()
Destructor.
Definition: Constraint.cpp:38
std::pair< std::shared_ptr< Localization >, std::shared_ptr< Localization > > m_localizations
Definition: Constraint.h:105
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:105
void setInformation(std::shared_ptr< ConstraintData > data, std::shared_ptr< ConstraintImplementation > implementation0, std::shared_ptr< Localization > localization0, std::shared_ptr< ConstraintImplementation > implementation1, std::shared_ptr< Localization > localization1)
Sets all the values for this constraints, does validation on the parameters and will throw it somethi...
Definition: Constraint.cpp:114
Base class for all physics constraints. Contains data specific to the constraint and a pair of implem...
Definition: Constraint.h:32
std::shared_ptr< ConstraintData > m_data
Specific data associated to this constraint.
Definition: Constraint.h:101
const std::pair< std::shared_ptr< Localization >, std::shared_ptr< Localization > > & getLocalizations() const
Gets both sides Localization as a pair.
Definition: Constraint.cpp:49
const std::pair< std::shared_ptr< ConstraintImplementation >, std::shared_ptr< ConstraintImplementation > > & getImplementations() const
Gets both sides implementation as a pair.
Definition: Constraint.cpp:44
MlcpConstraintType
Definition: MlcpConstraintType.h:24