opensurgsim
Fem.h
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2015, 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_FEM_H
17 #define SURGSIM_PHYSICS_FEM_H
18 
19 #include "SurgSim/DataStructures/Vertices.h"
20 #include "SurgSim/Framework/Asset.h"
21 #include "SurgSim/Physics/FemElementStructs.h"
22 
23 namespace SurgSim
24 {
25 namespace Physics
26 {
27 
38 template <class VertexData, class Element>
40  public std::enable_shared_from_this<Fem<VertexData, Element>>
41 {
42 public:
44  Fem();
45 
49  size_t addElement(std::shared_ptr<Element> element);
50 
53  size_t getNumElements() const;
54 
57  const std::vector<std::shared_ptr<Element>>& getElements() const;
58 
61  std::vector<std::shared_ptr<Element>>& getElements();
62 
66  std::shared_ptr<Element> getElement(size_t id) const;
67 
71  size_t addBoundaryCondition(size_t boundaryCondition);
72 
75  const std::vector<size_t>& getBoundaryConditions() const;
76 
79  std::vector<size_t>& getBoundaryConditions();
80 
84  size_t getBoundaryCondition(size_t id) const;
85 
86 protected:
89  template <class PlyType, class FemType>
90  bool loadFemFile(const std::string& filename);
91 
93  std::vector<std::shared_ptr<Element>> m_elements;
94 
96  std::vector<size_t> m_boundaryConditions;
97 };
98 
99 } // namespace Physics
100 } // namespace SurgSim
101 
102 #include "SurgSim/Physics/Fem-inl.h"
103 
104 #endif // SURGSIM_PHYSICS_FEM_H
size_t getBoundaryCondition(size_t id) const
Retrieves a specific boundary condition.
Definition: Fem-inl.h:86
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
This class is used to facilitate file loading.
Definition: Asset.h:39
std::vector< std::shared_ptr< Element > > m_elements
Vector of individual elements.
Definition: Fem.h:93
const std::vector< size_t > & getBoundaryConditions() const
Gets entire vector of boundary conditions.
Definition: Fem-inl.h:74
std::shared_ptr< Element > getElement(size_t id) const
Retrieve a specific element from the mesh.
Definition: Fem-inl.h:61
size_t addElement(std::shared_ptr< Element > element)
Adds FEM element to mesh of Element template type.
Definition: Fem-inl.h:35
const std::vector< std::shared_ptr< Element > > & getElements() const
Gets entire FEM element vector.
Definition: Fem-inl.h:49
bool loadFemFile(const std::string &filename)
Shared loading method for all 3 dimensions.
Definition: Fem-inl.h:91
size_t addBoundaryCondition(size_t boundaryCondition)
Add boundary condition to mesh.
Definition: Fem-inl.h:67
std::vector< size_t > m_boundaryConditions
Vector of vertex ids that have boundary conditions.
Definition: Fem.h:96
Fem()
Default constructor.
Definition: Fem-inl.h:30
Base class for a data structure for holding FEM mesh data of different dimensions.
Definition: Fem.h:39
size_t getNumElements() const
Gets number of FEM elements in the mesh.
Definition: Fem-inl.h:42
Base class for mesh structures, handling basic vertex functionality.
Definition: Vertices.h:51