Go to the documentation of this file.
16 #ifndef SURGSIM_DATASTRUCTURES_PLYREADER_H
17 #define SURGSIM_DATASTRUCTURES_PLYREADER_H
22 #include <unordered_map>
27 namespace DataStructures
30 class PlyReaderDelegate;
115 explicit PlyReader(
const std::string& filename);
133 std::function<
void* (
const std::string&,
size_t)> startElementCallback,
134 std::function<
void (
const std::string&)> processElementCallback,
135 std::function<
void (
const std::string&)> endElementCallback);
151 int dataType,
int dataOffset);
168 const std::string& propertyName,
169 int dataType,
int dataOffset,
170 int countType,
int countOffset);
175 bool hasElement(
const std::string& elementName)
const;
181 bool hasProperty(
const std::string& elementName,
const std::string& propertyName)
const;
187 bool isScalar(
const std::string& elementName,
const std::string& propertyName)
const;
203 bool setDelegate(std::shared_ptr<PlyReaderDelegate> delegate);
222 const std::string& propertyName,
223 int dataType,
int dataOffset,
224 int countType,
int countOffset);
254 std::unique_ptr<Data>
m_data;
270 #endif // SURGSIM_DATASTRUCTURES_PLYREADER_H
Information about the element in the .ply file.
Definition: PlyReader.h:240
virtual ~PlyReader()
Destructor.
Definition: PlyReader.cpp:74
Definition: PlyReader.h:100
Definition: PlyReader.h:91
bool parseWithDelegate(std::shared_ptr< PlyReaderDelegate > delegate)
Sets a delegate for parsing and then parse the file.
Definition: PlyReader.cpp:333
StartElementCallbackType startElementCallback
Callback to be used when the element is first encountered.
Definition: PlyReader.h:243
int dataType
Type of the receiving data.
Definition: PlyReader.h:233
bool requestScalarProperty(const std::string &elementName, const std::string &propertyName, int dataType, int dataOffset)
Request a scalar property for parsing.
Definition: PlyReader.cpp:118
Definition: PlyReader.h:95
PlyReader(const std::string &filename)
Constructor.
Definition: PlyReader.cpp:60
std::vector< PropertyInfo > requestedProperties
All the properties that are wanted.
Definition: PlyReader.h:246
std::unique_ptr< Data > m_data
Definition: PlyReader.h:253
std::function< void(void)> m_endParseFileCallback
Callback to be executed at the end of 'parseFile'.
Definition: PlyReader.h:264
bool requestListProperty(const std::string &elementName, const std::string &propertyName, int dataType, int dataOffset, int countType, int countOffset)
Request a list property for parsing.
Definition: PlyReader.cpp:124
Definition: CompoundShapeToGraphics.cpp:29
int dataOffset
Location for the receiving data.
Definition: PlyReader.h:234
Definition: PlyReader.cpp:34
Definition: PlyReader.h:94
std::function< void *(const std::string &, size_t)> StartElementCallbackType
The callback that is being used to indicate the start of an element, the parameters that are passed i...
Definition: PlyReader.h:107
int countOffset
For lists, location of the receiving data for the count.
Definition: PlyReader.h:236
Information about the property on the .ply file.
Definition: PlyReader.h:230
bool requestElement(const std::string &elementName, std::function< void *(const std::string &, size_t)> startElementCallback, std::function< void(const std::string &)> processElementCallback, std::function< void(const std::string &)> endElementCallback)
Request element to be processed during parsing.
Definition: PlyReader.cpp:94
Wrapper for the C .ply file parser This class wraps the main functionality for the original C ....
Definition: PlyReader.h:85
std::string propertyName
Name of the property.
Definition: PlyReader.h:232
std::shared_ptr< PlyReaderDelegate > m_delegate
The delegate.
Definition: PlyReader.h:258
Definition: PlyReader.h:92
Type
Values that represent the data type/size of requested data.
Definition: PlyReader.h:89
StandardCallbackType endElementCallback
Callback to be used after all the elements have been processed.
Definition: PlyReader.h:245
friend class PlyReaderTests
Definition: PlyReader.h:209
void parseFile()
Parse the file.
Definition: PlyReader.cpp:211
Definition: PlyReader.h:99
std::function< void(void)> m_startParseFileCallback
Callback to be executed at the start of 'parseFile'.
Definition: PlyReader.h:261
bool isScalar(const std::string &elementName, const std::string &propertyName) const
Query if the property of the give element is scalar.
Definition: PlyReader.cpp:364
std::unordered_map< std::string, ElementInfo > m_requestedElements
Definition: PlyReader.h:249
std::function< void(const std::string &)> StandardCallbackType
The callback that is used for the processing and the end of processing, the parameter passed is the n...
Definition: PlyReader.h:111
void setStartParseFileCallback(std::function< void(void)> startParseFileCallback)
Register callback to be called at the begining of parseFile.
Definition: PlyReader.cpp:132
bool hasProperty(const std::string &elementName, const std::string &propertyName) const
Query if 'elementName' has the given property.
Definition: PlyReader.cpp:350
bool hasElement(const std::string &elementName) const
Query if this elementName is in the .ply file.
Definition: PlyReader.cpp:343
bool isValid() const
Query if this object is valid.
Definition: PlyReader.cpp:89
bool setDelegate(std::shared_ptr< PlyReaderDelegate > delegate)
Sets a delegate for parsing.
Definition: PlyReader.cpp:196
Definition: PlyReader.h:97
std::string name
Name of the element.
Definition: PlyReader.h:242
void setEndParseFileCallback(std::function< void(void)> endParseFileCallback)
Register callback to be called at the end of parseFile.
Definition: PlyReader.cpp:137
std::string m_filename
The name of the .ply file.
Definition: PlyReader.h:227
Definition: PlyReader.h:96
int countType
For lists, type of the receiving data for the count of listelements.
Definition: PlyReader.h:235
Definition: PlyReader.h:98
Definition: PlyReader.h:93
StandardCallbackType processElementCallback
Callback to be used for each processed element.
Definition: PlyReader.h:244
bool requestProperty(const std::string &elementName, const std::string &propertyName, int dataType, int dataOffset, int countType, int countOffset)
Generic Internal function to handle list and scalar properties, see requestScalarProperty() and reque...
Definition: PlyReader.cpp:142