opensurgsim
Fem1DRepresentation.h
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013-2016, 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_FEM1DREPRESENTATION_H
17 #define SURGSIM_PHYSICS_FEM1DREPRESENTATION_H
18 
19 #include <memory>
20 #include <string>
21 
22 #include "SurgSim/Framework/FrameworkConvert.h"
23 #include "SurgSim/Math/Matrix.h"
25 #include "SurgSim/Math/Vector.h"
26 #include "SurgSim/Physics/Fem1D.h"
27 #include "SurgSim/Physics/FemRepresentation.h"
28 
29 namespace SurgSim
30 {
31 namespace DataStructures
32 {
33 struct IndexedLocalCoordinate;
34 struct Location;
35 }
36 namespace Framework
37 {
38 class Asset;
39 }
40 namespace Math
41 {
42 class OdeState;
43 }
44 
45 namespace Physics
46 {
47 class Localization;
48 
49 SURGSIM_STATIC_REGISTRATION(Fem1DRepresentation);
50 
55 {
56 public:
59  explicit Fem1DRepresentation(const std::string& name);
60 
62  virtual ~Fem1DRepresentation();
63 
64  SURGSIM_CLASSNAME(SurgSim::Physics::Fem1DRepresentation);
65 
66  void loadFem(const std::string& fileName) override;
67 
71  void setFem(std::shared_ptr<SurgSim::Framework::Asset> mesh);
72 
74  std::shared_ptr<Fem1D> getFem() const;
75 
76  void addExternalGeneralizedForce(std::shared_ptr<Localization> localization,
77  const SurgSim::Math::Vector& generalizedForce,
79  const SurgSim::Math::Matrix& D = SurgSim::Math::Matrix()) override;
80 
81  std::shared_ptr<Localization> createLocalization(const SurgSim::DataStructures::Location& location) override;
82 
83 protected:
84  void transformState(std::shared_ptr<SurgSim::Math::OdeState> state,
85  const SurgSim::Math::RigidTransform3d& transform) override;
86 
87  bool doInitialize() override;
88 
89 private:
93  std::shared_ptr<Localization> createNodeLocalization(size_t nodeId);
94 
98  std::shared_ptr<Localization> createElementLocalization(
100 
102  std::shared_ptr<Fem1D> m_fem;
103 };
104 
105 } // namespace Physics
106 
107 } // namespace SurgSim
108 
109 #endif // SURGSIM_PHYSICS_FEM1DREPRESENTATION_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
Finite Element Model 1D is a fem built with 1D FemElement.
Definition: Fem1DRepresentation.h:54
Finite Element Model (a.k.a FEM) is a deformable model (a set of nodes connected by FemElement)...
Definition: FemRepresentation.h:46
Eigen::Transform< double, 3, Eigen::Isometry > RigidTransform3d
A 3D rigid (isometric) transform, represented as doubles.
Definition: RigidTransform.h:46
A Location defines a local position w.r.t.
Definition: Location.h:39
Eigen::Matrix< double, Eigen::Dynamic, 1 > Vector
A dynamic size column vector.
Definition: Vector.h:68
Definitions of 2x2 and 3x3 rigid (isometric) transforms.
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