Fem1DRepresentation.h
Go to the documentation of this file.
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 
23 #include "SurgSim/Math/Matrix.h"
25 #include "SurgSim/Math/Vector.h"
26 #include "SurgSim/Physics/Fem1D.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 
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
SurgSim::Physics::Fem1DRepresentation::createElementLocalization
std::shared_ptr< Localization > createElementLocalization(const SurgSim::DataStructures::IndexedLocalCoordinate &location)
Helper method: create a localization for an element-based IndexedLocalCoordinate (beam)
Definition: Fem1DRepresentation.cpp:224
Vector.h
SurgSim::Physics::Fem1DRepresentation::setFem
void setFem(std::shared_ptr< SurgSim::Framework::Asset > mesh)
Sets the fem mesh asset.
Definition: Fem1DRepresentation.cpp:77
SurgSim::Math::RigidTransform3d
Eigen::Transform< double, 3, Eigen::Isometry > RigidTransform3d
A 3D rigid (isometric) transform, represented as doubles.
Definition: RigidTransform.h:46
SurgSim::Physics::Fem1DRepresentation::addExternalGeneralizedForce
void addExternalGeneralizedForce(std::shared_ptr< Localization > localization, const SurgSim::Math::Vector &generalizedForce, const SurgSim::Math::Matrix &K=SurgSim::Math::Matrix(), const SurgSim::Math::Matrix &D=SurgSim::Math::Matrix()) override
Add an external generalized force applied on a specific localization.
Definition: Fem1DRepresentation.cpp:128
Matrix.h
SurgSim::Physics::Fem1DRepresentation::getFem
std::shared_ptr< Fem1D > getFem() const
Definition: Fem1DRepresentation.cpp:123
SurgSim::Physics::FemRepresentation
Finite Element Model (a.k.a FEM) is a deformable model (a set of nodes connected by FemElement).
Definition: FemRepresentation.h:46
SurgSim::Physics::Fem1DRepresentation::m_fem
std::shared_ptr< Fem1D > m_fem
The Fem1DRepresentation's asset as a Fem1D.
Definition: Fem1DRepresentation.h:102
SurgSim::Physics::Fem1DRepresentation::doInitialize
bool doInitialize() override
Interface to be implemented by derived classes.
Definition: Fem1DRepresentation.cpp:254
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
Fem1D.h
FrameworkConvert.h
SurgSim::DataStructures::IndexedLocalCoordinate
A generic (size_t index, Vector coordinate) pair.
Definition: IndexedLocalCoordinate.h:29
SurgSim::Physics::Fem1DRepresentation::createNodeLocalization
std::shared_ptr< Localization > createNodeLocalization(size_t nodeId)
Helper method: create a localization for a node.
Definition: Fem1DRepresentation.cpp:195
SurgSim::Physics::Fem1DRepresentation::Fem1DRepresentation
Fem1DRepresentation(const std::string &name)
Constructor.
Definition: Fem1DRepresentation.cpp:55
SurgSim::Physics::Fem1DRepresentation::~Fem1DRepresentation
virtual ~Fem1DRepresentation()
Destructor.
Definition: Fem1DRepresentation.cpp:66
RigidTransform.h
SurgSim::Physics::Fem1DRepresentation::SURGSIM_CLASSNAME
SURGSIM_CLASSNAME(SurgSim::Physics::Fem1DRepresentation)
SurgSim::Physics::Fem1DRepresentation::transformState
void transformState(std::shared_ptr< SurgSim::Math::OdeState > state, const SurgSim::Math::RigidTransform3d &transform) override
Transform a state using a given transformation.
Definition: Fem1DRepresentation.cpp:247
SurgSim::DataStructures::Location
A Location defines a local position w.r.t.
Definition: Location.h:39
SurgSim::Math::Vector
Eigen::Matrix< double, Eigen::Dynamic, 1 > Vector
A dynamic size column vector.
Definition: Vector.h:68
SurgSim::Physics::Fem1DRepresentation::createLocalization
std::shared_ptr< Localization > createLocalization(const SurgSim::DataStructures::Location &location) override
Computes a localized coordinate w.r.t this representation, given a Location object.
Definition: Fem1DRepresentation.cpp:231
SurgSim::Physics::Fem1DRepresentation
Finite Element Model 1D is a fem built with 1D FemElement.
Definition: Fem1DRepresentation.h:54
FemRepresentation.h
SurgSim::Physics::Fem1DRepresentation::loadFem
void loadFem(const std::string &fileName) override
Loads the FEM file into an Fem class data structure.
Definition: Fem1DRepresentation.cpp:70
SurgSim::Math::Matrix
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > Matrix
A dynamic size matrix.
Definition: Matrix.h:65