All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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
double * m_vertexIterator
Internal iterator to save the "vertex" element.
Definition: FemPlyReaderDelegate.h:115
void processVertex(const std::string &elementName)
Callback function to process one vertex.
Definition: FemPlyReaderDelegate.cpp:155
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
FemPlyReaderDelegate(std::shared_ptr< FemRepresentation > fem)
Constructor.
Definition: FemPlyReaderDelegate.cpp:29
double massDensity
Definition: FemPlyReaderDelegate.h:129
Internal data to receive the fem element.
Definition: FemPlyReaderDelegate.h:136
void * beginMaterials(const std::string &elementName, size_t materialCount)
Callback function, begin the processing of materials.
Definition: FemPlyReaderDelegate.cpp:180
virtual std::string getElementName() const =0
Common part of implementation of PlyReaderDelegate for FemRepresentations.
Definition: FemPlyReaderDelegate.h:39
void endVertices(const std::string &elementName)
Callback function to finalize processing of vertices.
Definition: FemPlyReaderDelegate.cpp:161
unsigned int vertexCount
Definition: FemPlyReaderDelegate.h:141
int64_t overrun
Used to check for buffer overruns.
Definition: FemPlyReaderDelegate.h:142
struct SurgSim::Physics::FemPlyReaderDelegate::ElementData m_femData
struct SurgSim::Physics::FemPlyReaderDelegate::MaterialData m_materialData
Wrapper for the C .ply file parser This class wraps the main functionality for the original C ...
Definition: PlyReader.h:85
unsigned int * indices
Definition: FemPlyReaderDelegate.h:140
void * beginFemElements(const std::string &elementName, size_t elementCount)
Callback function, begin the processing of FemElements.
Definition: FemPlyReaderDelegate.cpp:166
void startParseFile()
Callback for beginning of PlyReader::parseFile.
Definition: FemPlyReaderDelegate.cpp:125
void * beginVertices(const std::string &elementName, size_t vertexCount)
Callback function, begin the processing of vertices.
Definition: FemPlyReaderDelegate.cpp:147
void * beginBoundaryConditions(const std::string &elementName, size_t boundaryConditionCount)
Callback function, begin the processing of boundary conditions.
Definition: FemPlyReaderDelegate.cpp:193
virtual void endParseFile()
Callback for end of PlyReader::parseFile.
Definition: FemPlyReaderDelegate.cpp:135
virtual void processFemElement(const std::string &elementName)=0
Callback function to process one FemElement.
void endFemElements(const std::string &elementName)
Callback function to finalize processing of FemElements.
Definition: FemPlyReaderDelegate.cpp:172
virtual bool registerDelegate(SurgSim::DataStructures::PlyReader *reader) override
Registers the delegate with the reader.
Definition: FemPlyReaderDelegate.cpp:41
size_t m_boundaryConditionData
Internal data to receive the "boundary_condition" element.
Definition: FemPlyReaderDelegate.h:112
void endMaterials(const std::string &elementName)
Callback function, end the processing of materials.
Definition: FemPlyReaderDelegate.cpp:186
ElementData()
Definition: FemPlyReaderDelegate.cpp:37
std::shared_ptr< SurgSim::Math::OdeState > m_state
The state that will be created by loading.
Definition: FemPlyReaderDelegate.h:124
void processBoundaryCondition(const std::string &elementName)
Callback function to process one boundary condition.
Definition: FemPlyReaderDelegate.cpp:199
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
virtual bool fileIsAcceptable(const SurgSim::DataStructures::PlyReader &reader) override
Check whether the file in the reader can be used with this delegate, this gives the delegate a chance...
Definition: FemPlyReaderDelegate.cpp:104
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