opensurgsim
Fem2DRepresentation.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_FEM2DREPRESENTATION_H
17 #define SURGSIM_PHYSICS_FEM2DREPRESENTATION_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/Fem2D.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(Fem2DRepresentation);
50 
53 {
54 public:
57  explicit Fem2DRepresentation(const std::string& name);
58 
60  virtual ~Fem2DRepresentation();
61 
62  SURGSIM_CLASSNAME(SurgSim::Physics::Fem2DRepresentation);
63 
64  void loadFem(const std::string& fileName) override;
65 
69  void setFem(std::shared_ptr<SurgSim::Framework::Asset> mesh);
70 
72  std::shared_ptr<Fem2D> getFem() const;
73 
74  void addExternalGeneralizedForce(std::shared_ptr<Localization> localization,
75  const SurgSim::Math::Vector& generalizedForce,
77  const SurgSim::Math::Matrix& D = SurgSim::Math::Matrix()) override;
78 
79  std::shared_ptr<Localization> createLocalization(const SurgSim::DataStructures::Location& location) override;
80 
81 protected:
82  void transformState(std::shared_ptr<SurgSim::Math::OdeState> state,
83  const SurgSim::Math::RigidTransform3d& transform) override;
84 
85  bool doInitialize() override;
86 
87 private:
91  std::shared_ptr<Localization> createNodeLocalization(size_t nodeId);
92 
96  std::shared_ptr<Localization> createElementLocalization(
98 
100  std::shared_ptr<Fem2D> m_fem;
101 };
102 
103 } // namespace Physics
104 
105 } // namespace SurgSim
106 
107 #endif // SURGSIM_PHYSICS_FEM2DREPRESENTATION_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 2D is a fem built with 2D FemElement.
Definition: Fem2DRepresentation.h:52
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