All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
27 
28 namespace SurgSim
29 {
30 
31 namespace Physics
32 {
33 
38 
41 {
42 public:
46 
48  virtual ~ConstraintImplementation();
49 
52  size_t getNumDof() const
53  {
54  return doGetNumDof();
55  }
56 
60 
63  virtual RepresentationType getRepresentationType() const = 0;
64 
73  void build(double dt,
74  const ConstraintData& data,
75  const std::shared_ptr<Localization>& localization,
76  MlcpPhysicsProblem* mlcp,
77  size_t indexOfRepresentation,
78  size_t indexOfConstraint,
79  ConstraintSideSign sign)
80  {
81  doBuild(dt, data, localization, mlcp, indexOfRepresentation, indexOfConstraint, sign);
82  }
83 
84 protected:
86  Eigen::SparseVector<double, 0, ptrdiff_t> m_newH;
87 
88 private:
89 
92  virtual size_t doGetNumDof() const = 0;
93 
102  virtual void doBuild(double dt,
103  const ConstraintData& data,
104  const std::shared_ptr<Localization>& localization,
105  MlcpPhysicsProblem* mlcp,
106  size_t indexOfRepresentation,
107  size_t indexOfConstraint,
108  ConstraintSideSign sign) = 0;
109 
110 };
111 
112 }; // namespace Physics
113 
114 }; // namespace SurgSim
115 
116 #endif // SURGSIM_PHYSICS_CONSTRAINTIMPLEMENTATION_H
virtual size_t doGetNumDof() const =0
Does get number of degree of freedom.
RepresentationType
Definition: Representation.h:42
A description of a physical mixed LCP system to be solved.
Definition: MlcpPhysicsProblem.h:43
ConstraintImplementation()
Constructor.
Definition: ConstraintImplementation.cpp:26
Base class for all CosntraintData Derived classes should be specific to a given constraint.
Definition: ConstraintData.h:27
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.h:73
Definition: ConstraintImplementation.h:37
virtual SurgSim::Math::MlcpConstraintType getMlcpConstraintType() const =0
Gets the Mixed Linear Complementarity Problem constraint type for this ConstraintImplementation.
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.
Base class for all constraint implementations. A ConstraintImplementation defines 1 side of a constra...
Definition: ConstraintImplementation.h:40
Definition: ConstraintImplementation.h:37
Eigen::SparseVector< double, 0, ptrdiff_t > m_newH
Preallocated variable for derived implementations of doBuild.
Definition: ConstraintImplementation.h:86
ConstraintSideSign
Enum defining on which side of the constraint an implementation is (positive or negative side) ...
Definition: ConstraintImplementation.h:37
virtual ~ConstraintImplementation()
Destructor.
Definition: ConstraintImplementation.cpp:30
size_t getNumDof() const
Gets the number of degree of freedom for this implementation.
Definition: ConstraintImplementation.h:52
MlcpConstraintType
Definition: MlcpConstraintType.h:24
virtual RepresentationType getRepresentationType() const =0
Gets the Type of representation that this implementation is concerned with.