ConstraintImplementation.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_CONSTRAINTIMPLEMENTATION_H
17 #define SURGSIM_PHYSICS_CONSTRAINTIMPLEMENTATION_H
18 
19 #include <memory>
20 
21 #include <Eigen/Core>
22 
29 
30 namespace SurgSim
31 {
32 
33 namespace Physics
34 {
35 
40 
43 {
44 public:
47 
49  virtual ~ConstraintImplementation();
50 
53 
56  size_t getNumDof() const;
57 
61 
70  void build(double dt,
71  const ConstraintData& data,
72  const std::shared_ptr<Localization>& localization,
73  MlcpPhysicsProblem* mlcp,
74  size_t indexOfRepresentation,
75  size_t indexOfConstraint,
76  ConstraintSideSign sign);
77 
78 protected:
80  Eigen::SparseVector<double, Eigen::RowMajor, ptrdiff_t> m_newH;
81 
82 private:
83 
86  virtual size_t doGetNumDof() const = 0;
87 
96  virtual void doBuild(double dt,
97  const ConstraintData& data,
98  const std::shared_ptr<Localization>& localization,
99  MlcpPhysicsProblem* mlcp,
100  size_t indexOfRepresentation,
101  size_t indexOfConstraint,
102  ConstraintSideSign sign) = 0;
103 
104 };
105 
106 }; // namespace Physics
107 
108 }; // namespace SurgSim
109 
110 #endif // SURGSIM_PHYSICS_CONSTRAINTIMPLEMENTATION_H
SurgSim::Physics::ConstraintImplementation::m_newH
Eigen::SparseVector< double, Eigen::RowMajor, ptrdiff_t > m_newH
Preallocated variable for derived implementations of doBuild.
Definition: ConstraintImplementation.h:80
ConstraintType.h
SurgSim::Physics::ConstraintImplementation::doBuild
virtual void doBuild(double dt, const ConstraintData &data, const std::shared_ptr< Localization > &localization, MlcpPhysicsProblem *mlcp, size_t indexOfRepresentation, size_t indexOfConstraint, ConstraintSideSign sign)=0
Builds the subset of an Mlcp physics problem associated to this implementation.
SurgSim::Physics::CONSTRAINT_NEGATIVE_SIDE
Definition: ConstraintImplementation.h:39
SurgSim::Physics::ConstraintImplementation::getNumDof
size_t getNumDof() const
Gets the number of degree of freedom for this implementation.
Definition: ConstraintImplementation.cpp:40
SurgSim::Physics::MlcpPhysicsProblem
A description of a physical mixed LCP system to be solved.
Definition: MlcpPhysicsProblem.h:43
SurgSim::Physics::ConstraintImplementation
Base class for all constraint implementations. A ConstraintImplementation defines 1 side of a constra...
Definition: ConstraintImplementation.h:42
SurgSim::Physics::ConstraintImplementation::~ConstraintImplementation
virtual ~ConstraintImplementation()
Destructor.
Definition: ConstraintImplementation.cpp:30
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Physics::CONSTRAINT_POSITIVE_SIDE
Definition: ConstraintImplementation.h:39
SurgSim::Physics::ConstraintSideSign
ConstraintSideSign
Enum defining on which side of the constraint an implementation is (positive or negative side)
Definition: ConstraintImplementation.h:39
SurgSim::Physics::ConstraintType
ConstraintType
Definition: ConstraintType.h:24
SurgSim::Physics::ConstraintImplementation::doGetNumDof
virtual size_t doGetNumDof() const =0
Does get number of degree of freedom.
SurgSim::Physics::ConstraintData
Base class for all CosntraintData Derived classes should be specific to a given constraint.
Definition: ConstraintData.h:27
ConstraintData.h
Localization.h
SurgSim::Physics::ConstraintImplementation::getFactory
static ConstraintImplementationFactory & getFactory()
Definition: ConstraintImplementation.cpp:34
Representation.h
SurgSim::Physics::ConstraintImplementationFactory
This class manages ConstraintImplementations, and can be used to look up the correct implementation b...
Definition: ConstraintImplementationFactory.h:38
SurgSim::Physics::ConstraintImplementation::ConstraintImplementation
ConstraintImplementation()
Constructor.
Definition: ConstraintImplementation.cpp:26
ConstraintImplementationFactory.h
MlcpPhysicsProblem.h
SurgSim::Physics::ConstraintImplementation::getConstraintType
virtual SurgSim::Physics::ConstraintType getConstraintType() const =0
Gets the constraint type for this ConstraintImplementation.
SurgSim::Physics::ConstraintImplementation::build
void build(double dt, const ConstraintData &data, const std::shared_ptr< Localization > &localization, MlcpPhysicsProblem *mlcp, size_t indexOfRepresentation, size_t indexOfConstraint, ConstraintSideSign sign)
Builds the subset of an Mlcp physics problem associated to this implementation.
Definition: ConstraintImplementation.cpp:45