16 #ifndef SURGSIM_DATASTRUCTURES_TRIANGLEMESHPLYREADERDELEGATE_INL_H
17 #define SURGSIM_DATASTRUCTURES_TRIANGLEMESHPLYREADERDELEGATE_INL_H
21 m_mesh(
std::make_shared<M>())
46 std::placeholders::_1, std::placeholders::_2),
56 if (m_hasTextureCoordinates)
65 std::placeholders::_1, std::placeholders::_2),
85 result = result && reader.
hasProperty(
"vertex",
"x");
86 result = result && reader.
hasProperty(
"vertex",
"y");
87 result = result && reader.
hasProperty(
"vertex",
"z");
88 result = result && reader.
hasProperty(
"face",
"vertex_indices");
89 result = result && !reader.
isScalar(
"face",
"vertex_indices");
96 const std::string& elementName,
99 m_vertexData.overrun1 = 0l;
100 m_vertexData.overrun2 = 0l;
101 return &m_vertexData;
108 m_mesh->addVertex(vertex);
114 SURGSIM_ASSERT(m_vertexData.overrun1 == 0l && m_vertexData.overrun2 == 0l) <<
115 "There was an overrun while reading the vertex structures, it is likely that data " <<
116 "has become corrupted.";
121 const std::string& elementName,
124 m_faceData.overrun = 0l;
131 SURGSIM_ASSERT(m_faceData.edgeCount == 3) <<
"Can only process triangle meshes.";
132 std::copy(m_faceData.indices, m_faceData.indices + 3, m_indices.begin());
134 typename M::TriangleType triangle(m_indices);
135 m_mesh->addTriangle(triangle);
142 <<
"There was an overrun while reading the face structures, it is likely that data "
143 <<
"has become corrupted.";
155 return m_hasTextureCoordinates;
std::shared_ptr< MeshType > getMesh()
Gets the mesh.
Definition: TriangleMeshPlyReaderDelegate-inl.h:35
bool hasTextureCoordinates()
Definition: TriangleMeshPlyReaderDelegate-inl.h:153
virtual void processVertex(const std::string &elementName)
Callback function to process one vertex.
Definition: TriangleMeshPlyReaderDelegate-inl.h:105
void endFaces(const std::string &elementName)
Callback function to finalize processing of faces.
Definition: TriangleMeshPlyReaderDelegate-inl.h:139
Internal structure, the receiver for data from the "vertex" element Provide space for standard ply ve...
Definition: TriangleMeshPlyReaderDelegate.h:99
virtual bool registerDelegate(PlyReader *reader) override
Registers the delegate with the reader, overridden from.
Definition: TriangleMeshPlyReaderDelegate-inl.h:41
#define SURGSIM_ASSERT(condition)
Assert that condition is true.
Definition: Assert.h:77
Definition: PlyReader.h:97
Definition: PlyReader.h:99
void endVertices(const std::string &elementName)
Callback function to finalize processing of vertices.
Definition: TriangleMeshPlyReaderDelegate-inl.h:112
Wrapper for the C .ply file parser This class wraps the main functionality for the original C ...
Definition: PlyReader.h:85
TriangleMeshPlyReaderDelegate()
Default constructor.
Definition: TriangleMeshPlyReaderDelegate-inl.h:20
void endFile()
Callback function to finalize processing of the mesh.
Definition: TriangleMeshPlyReaderDelegate-inl.h:147
bool hasProperty(std::string elementName, std::string propertyName) const
Query if 'elementName' has the given property.
Definition: PlyReader.cpp:331
bool requestScalarProperty(std::string elementName, std::string propertyName, int dataType, int dataOffset)
Request a scalar property for parsing.
Definition: PlyReader.cpp:118
Internal structure, the received for data from the "face" element.
Definition: TriangleMeshPlyReaderDelegate.h:111
void processFace(const std::string &elementName)
Callback function to process one face.
Definition: TriangleMeshPlyReaderDelegate-inl.h:129
bool requestElement(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
bool requestListProperty(std::string elementName, std::string propertyName, int dataType, int dataOffset, int countType, int countOffset)
Request a list property for parsing.
Definition: PlyReader.cpp:123
bool isScalar(std::string elementName, std::string propertyName) const
Query if the property of the give element is scalar.
Definition: PlyReader.cpp:345
void * beginVertices(const std::string &elementName, size_t vertexCount)
Callback function, begin the processing of vertices.
Definition: TriangleMeshPlyReaderDelegate-inl.h:95
void setEndParseFileCallback(std::function< void(void)> endParseFileCallback)
Register callback to be called at the end of parseFile.
Definition: PlyReader.cpp:136
Eigen::Matrix< double, 3, 1 > Vector3d
A 3D vector of doubles.
Definition: Vector.h:56
virtual bool fileIsAcceptable(const PlyReader &reader) override
Check whether this file is acceptable to the delegate, overridden from.
Definition: TriangleMeshPlyReaderDelegate-inl.h:80
void * beginFaces(const std::string &elementName, size_t faceCount)
Callback function, begin the processing of faces.
Definition: TriangleMeshPlyReaderDelegate-inl.h:120