16 #ifndef SURGSIM_PHYSICS_MASSSPRINGREPRESENTATION_H 17 #define SURGSIM_PHYSICS_MASSSPRINGREPRESENTATION_H 21 #include "SurgSim/DataStructures/IndexedLocalCoordinate.h" 36 class MassSpringModel;
39 SURGSIM_STATIC_REGISTRATION(MassSpringRepresentation);
61 void addMass(
const std::shared_ptr<Mass> mass);
65 void addSpring(
const std::shared_ptr<Spring> spring);
69 size_t getNumMasses()
const;
73 size_t getNumSprings()
const;
76 size_t getNumElements()
const;
83 std::shared_ptr<Mass> getMass(
size_t nodeId);
90 std::shared_ptr<Spring> getSpring(
size_t springId);
94 double getTotalMass()
const;
98 double getRayleighDampingStiffness()
const;
102 double getRayleighDampingMass()
const;
106 void setRayleighDampingStiffness(
double stiffnessCoef);
110 void setRayleighDampingMass(
double massCoef);
112 void addExternalGeneralizedForce(std::shared_ptr<Localization> localization,
119 void beforeUpdate(
double dt)
override;
125 void loadMassSpringModel(
const std::string & filename);
130 void setMassSpringModel(std::shared_ptr<Framework::Asset> mesh);
133 std::shared_ptr<MassSpringModel> getMassSpringModel()
const;
155 const std::vector<size_t>& getNodeIds(
size_t index)
const;
161 bool saveMassSpringModel(
const std::string& fileName,
double physicsLength = 0.0)
const;
175 bool useGlobalStiffnessMatrix =
false,
bool useGlobalMassMatrix =
false,
194 void transformState(std::shared_ptr<SurgSim::Math::OdeState> state,
197 bool doInitialize()
override;
211 std::vector<std::shared_ptr<Mass>> m_masses;
214 std::vector<std::shared_ptr<Spring>> m_springs;
221 double massCoefficient;
222 double stiffnessCoefficient;
226 std::shared_ptr<MassSpringModel> m_mesh;
233 #endif // SURGSIM_PHYSICS_MASSSPRINGREPRESENTATION_H Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
A generic (size_t index, Vector coordinate) pair.
Definition: IndexedLocalCoordinate.h:29
A Location defines a local position w.r.t.
Definition: Location.h:39
Eigen::Matrix< double, 3, 1 > Vector3d
A 3D vector of doubles.
Definition: Vector.h:57
The state of an ode of 2nd order of the form with boundary conditions.
Definition: OdeState.h:38
MassSpring model is a deformable model (a set of masses connected by springs).
Definition: MassSpringRepresentation.h:45
Eigen::Matrix< double, Eigen::Dynamic, 1 > Vector
A dynamic size column vector.
Definition: Vector.h:68
Definitions of small fixed-size square matrix types.
Definitions of small fixed-size vector types.
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > Matrix
A dynamic size matrix.
Definition: Matrix.h:65