FemPlyReaderDelegate.h
Go to the documentation of this file.
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2014, 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_FEMPLYREADERDELEGATE_H
17 #define SURGSIM_PHYSICS_FEMPLYREADERDELEGATE_H
18 
19 #include <array>
20 #include <memory>
21 
23 
24 namespace SurgSim
25 {
26 
27 namespace Math
28 {
29 class OdeState;
30 };
31 
32 namespace Physics
33 {
34 class FemRepresentation;
35 
40 {
41 public:
44  explicit FemPlyReaderDelegate(std::shared_ptr<FemRepresentation> fem);
45 
46 protected:
47  // \return Name of the element (1/2/3D), which this delegate processes.
48  virtual std::string getElementName() const = 0;
49 
50  virtual bool registerDelegate(SurgSim::DataStructures::PlyReader* reader) override;
51  virtual bool fileIsAcceptable(const SurgSim::DataStructures::PlyReader& reader) override;
52 
54  void startParseFile();
55 
57  virtual void endParseFile();
58 
63  void* beginVertices(const std::string& elementName, size_t vertexCount);
64 
67  void processVertex(const std::string& elementName);
68 
71  void endVertices(const std::string& elementName);
72 
77  void* beginFemElements(const std::string& elementName, size_t elementCount);
78 
81  virtual void processFemElement(const std::string& elementName) = 0;
82 
85  void endFemElements(const std::string& elementName);
86 
91  void* beginMaterials(const std::string& elementName, size_t materialCount);
92 
95  void endMaterials(const std::string& elementName);
96 
101  void* beginBoundaryConditions(const std::string& elementName, size_t boundaryConditionCount);
102 
105  void processBoundaryCondition(const std::string& elementName);
106 
107 protected:
110 
113 
116 
118  std::array<double, 3> m_vertexData;
119 
121  std::shared_ptr<FemRepresentation> m_fem;
122 
124  std::shared_ptr<SurgSim::Math::OdeState> m_state;
125 
128  {
129  double massDensity;
130  double poissonRatio;
131  double youngModulus;
132  int64_t overrun;
133  } m_materialData;
134 
136  struct ElementData
137  {
138  ElementData();
139 
140  unsigned int* indices;
141  unsigned int vertexCount;
142  int64_t overrun;
143  } m_femData;
144 };
145 
146 } // namespace Physics
147 } // namespace SurgSim
148 
149 #endif // SURGSIM_PHYSICS_FEMPLYREADERDELEGATE_H
Definition: DriveElementFromInputBehavior.cpp:27
double * m_vertexIterator
Internal iterator to save the "vertex" element.
Definition: FemPlyReaderDelegate.h:115
double youngModulus
Definition: FemPlyReaderDelegate.h:131
std::shared_ptr< FemRepresentation > m_fem
The fem that will be created by loading.
Definition: FemPlyReaderDelegate.h:121
Internal data to receive the "material" data.
Definition: FemPlyReaderDelegate.h:127
double massDensity
Definition: FemPlyReaderDelegate.h:129
Internal data to receive the fem element.
Definition: FemPlyReaderDelegate.h:136
Common part of implementation of PlyReaderDelegate for FemRepresentations.
Definition: FemPlyReaderDelegate.h:39
unsigned int vertexCount
Definition: FemPlyReaderDelegate.h:141
int64_t overrun
Used to check for buffer overruns.
Definition: FemPlyReaderDelegate.h:142
Wrapper for the C .ply file parser This class wraps the main functionality for the original C ...
Definition: PlyReader.h:85
unsigned int m_boundaryConditionData
Internal data to receive the "boundary_condition" element.
Definition: FemPlyReaderDelegate.h:112
string(TOUPPER ${DEVICE}DEVICE_UPPER_CASE) option(BUILD_DEVICE_ $
Definition: CMakeLists.txt:35
unsigned int * indices
Definition: FemPlyReaderDelegate.h:140
std::shared_ptr< SurgSim::Math::OdeState > m_state
The state that will be created by loading.
Definition: FemPlyReaderDelegate.h:124
std::array< double, 3 > m_vertexData
Internal data to receive the "vertex" element.
Definition: FemPlyReaderDelegate.h:118
int64_t overrun
Used to check for buffer overruns.
Definition: FemPlyReaderDelegate.h:132
bool m_hasBoundaryConditions
Flag indicating if the associated file has boundary conditions.
Definition: FemPlyReaderDelegate.h:109
double poissonRatio
Definition: FemPlyReaderDelegate.h:130
PlyReaderDelegate abstract class.
Definition: PlyReaderDelegate.h:31