ConstraintImplementation.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_CONSTRAINTIMPLEMENTATION_H
#define SURGSIM_PHYSICS_CONSTRAINTIMPLEMENTATION_H
#include <memory>
#include <Eigen/Core>
#include "SurgSim/Physics/Representation.h"
#include "SurgSim/Physics/ConstraintData.h"
#include "SurgSim/Physics/ConstraintImplementationFactory.h"
#include "SurgSim/Physics/ConstraintType.h"
#include "SurgSim/Physics/Localization.h"
#include "SurgSim/Physics/MlcpPhysicsProblem.h"
namespace SurgSim
{
namespace Physics
{
enum ConstraintSideSign {CONSTRAINT_POSITIVE_SIDE, CONSTRAINT_NEGATIVE_SIDE};
class ConstraintImplementation
{
public:
ConstraintImplementation();
virtual ~ConstraintImplementation();
static ConstraintImplementationFactory& getFactory();
size_t getNumDof() const;
virtual SurgSim::Physics::ConstraintType getConstraintType() const = 0;
void build(double dt,
const ConstraintData& data,
const std::shared_ptr<Localization>& localization,
MlcpPhysicsProblem* mlcp,
size_t indexOfRepresentation,
size_t indexOfConstraint,
ConstraintSideSign sign);
protected:
Eigen::SparseVector<double, Eigen::RowMajor, ptrdiff_t> m_newH;
private:
virtual size_t doGetNumDof() const = 0;
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;
};
}; // namespace Physics
}; // namespace SurgSim
#endif // SURGSIM_PHYSICS_CONSTRAINTIMPLEMENTATION_H
ConstraintImplementationFactory.h
Representation.h
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Physics::ConstraintImplementation::doGetNumDof
virtual size_t doGetNumDof() const =0
Does get number of degree of freedom.
SurgSim::Physics::MlcpPhysicsProblem
A description of a physical mixed LCP system to be solved.
Definition: MlcpPhysicsProblem.h:43
Localization.h
ConstraintType.h
SurgSim::Physics::ConstraintImplementation::getFactory
static ConstraintImplementationFactory & getFactory()
Definition: ConstraintImplementation.cpp:34
SurgSim::Physics::ConstraintImplementation::ConstraintImplementation
ConstraintImplementation()
Constructor.
Definition: ConstraintImplementation.cpp:26
SurgSim::Physics::ConstraintData
Base class for all CosntraintData Derived classes should be specific to a given constraint.
Definition: ConstraintData.h:27
MlcpPhysicsProblem.h
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
SurgSim::Physics::CONSTRAINT_POSITIVE_SIDE
Definition: ConstraintImplementation.h:39
SurgSim::Physics::ConstraintImplementation::getConstraintType
virtual SurgSim::Physics::ConstraintType getConstraintType() const =0
Gets the constraint type for this ConstraintImplementation.
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::ConstraintImplementation
Base class for all constraint implementations. A ConstraintImplementation defines 1 side of a constra...
Definition: ConstraintImplementation.h:42
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
SurgSim::Physics::ConstraintImplementation::getNumDof
size_t getNumDof() const
Gets the number of degree of freedom for this implementation.
Definition: ConstraintImplementation.cpp:40
SurgSim::Physics::CONSTRAINT_NEGATIVE_SIDE
Definition: ConstraintImplementation.h:39
ConstraintData.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::ConstraintSideSign
ConstraintSideSign
Enum defining on which side of the constraint an implementation is (positive or negative side) ...
Definition: ConstraintImplementation.h:39
SurgSim::Physics::ConstraintImplementation::~ConstraintImplementation
virtual ~ConstraintImplementation()
Destructor.
Definition: ConstraintImplementation.cpp:30
SurgSim::Physics::ConstraintType
ConstraintType
Definition: ConstraintType.h:24