Fem3DRepresentation.h
Go to the documentation of this file.
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013, 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_FEM3DREPRESENTATION_H
17 #define SURGSIM_PHYSICS_FEM3DREPRESENTATION_H
18 
19 #include <memory>
20 #include <string>
21 #include <unordered_map>
22 
25 #include "SurgSim/Math/Matrix.h"
27 
28 namespace SurgSim
29 {
30 
31 namespace DataStructures
32 {
33 class TriangleMesh;
34 }
35 
36 namespace Physics
37 {
38 SURGSIM_STATIC_REGISTRATION(Fem3DRepresentation);
39 
40 class FemPlyReaderDelegate;
41 
44 {
45 public:
48  explicit Fem3DRepresentation(const std::string& name);
49 
51  virtual ~Fem3DRepresentation();
52 
54 
57  virtual RepresentationType getType() const override;
58 
59  virtual void addExternalGeneralizedForce(std::shared_ptr<Localization> localization,
60  SurgSim::Math::Vector& generalizedForce,
62  const SurgSim::Math::Matrix& D = SurgSim::Math::Matrix()) override;
63 
64  virtual std::shared_ptr<Localization> createLocalization(const SurgSim::DataStructures::Location&) override;
65 
66 protected:
67  virtual bool doWakeUp() override;
68 
72  virtual void transformState(std::shared_ptr<SurgSim::Math::OdeState> state,
73  const SurgSim::Math::RigidTransform3d& transform) override;
74 
75 private:
76  virtual std::shared_ptr<FemPlyReaderDelegate> getDelegate() override;
77 
82  std::unordered_map<size_t, size_t> createTriangleIdToElementIdMap(
84 
86  std::unordered_map<size_t, size_t> m_triangleIdToElementIdMap;
87 };
88 
89 } // namespace Physics
90 } // namespace SurgSim
91 
92 #endif // SURGSIM_PHYSICS_FEM3DREPRESENTATION_H
Definition: DriveElementFromInputBehavior.cpp:27
Finite Element Model 3D is a fem built with 3D FemElement.
Definition: Fem3DRepresentation.h:43
RepresentationType
Definition: Representation.h:42
Finite Element Model (a.k.a.
Definition: FemRepresentation.h:38
Definition: Location.h:31
virtual bool doWakeUp() override
Interface to be implemented by derived classes.
Definition: Fem3DRepresentation.cpp:211
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > Matrix
A dynamic size matrix.
Definition: Matrix.h:65
virtual RepresentationType getType() const override
Query the representation type.
Definition: Fem3DRepresentation.cpp:78
SURGSIM_CLASSNAME(SurgSim::Physics::Fem3DRepresentation)
virtual std::shared_ptr< FemPlyReaderDelegate > getDelegate() override
To be implemented by derived classes.
Definition: Fem3DRepresentation.cpp:146
std::unordered_map< size_t, size_t > m_triangleIdToElementIdMap
Mapping from collision triangle's id to fem element id.
Definition: Fem3DRepresentation.h:86
Eigen::Matrix< double, Eigen::Dynamic, 1 > Vector
A dynamic size column vector.
Definition: Vector.h:67
Fem3DRepresentation(const std::string &name)
Constructor.
Definition: Fem3DRepresentation.cpp:66
virtual void transformState(std::shared_ptr< SurgSim::Math::OdeState > state, const SurgSim::Math::RigidTransform3d &transform) override
Transform a state using a given transformation.
Definition: Fem3DRepresentation.cpp:293
Definitions of small fixed-size square matrix types.
Eigen::Transform< double, 3, Eigen::Isometry > RigidTransform3d
A 3D rigid (isometric) transform, represented as doubles.
Definition: RigidTransform.h:46
virtual std::shared_ptr< Localization > createLocalization(const SurgSim::DataStructures::Location &) override
Computes a localized coordinate w.r.t this representation, given a Location object.
Definition: Fem3DRepresentation.cpp:229
A TriangleMesh stores normal information for the triangles.
Definition: TriangleMesh.h:62
virtual ~Fem3DRepresentation()
Destructor.
Definition: Fem3DRepresentation.cpp:74
virtual void addExternalGeneralizedForce(std::shared_ptr< Localization > localization, 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: Fem3DRepresentation.cpp:83
SURGSIM_STATIC_REGISTRATION(DeformableCollisionRepresentation)
std::unordered_map< size_t, size_t > createTriangleIdToElementIdMap(const SurgSim::DataStructures::TriangleMesh &mesh)
Produces a mapping from the provided mesh's triangle ids to this object's fem element ids...
Definition: Fem3DRepresentation.cpp:154