16 #ifndef SURGSIM_DATASTRUCTURES_TRIANGLEMESHPLYREADERDELEGATE_INL_H
17 #define SURGSIM_DATASTRUCTURES_TRIANGLEMESHPLYREADERDELEGATE_INL_H
25 m_mesh(std::make_shared<M>()),
26 m_hasTextureCoordinates(false),
37 m_hasTextureCoordinates(false),
56 std::bind(&TriangleMeshPlyReaderDelegate::beginVertices,
this,
57 std::placeholders::_1, std::placeholders::_2),
58 std::bind(&TriangleMeshPlyReaderDelegate::processVertex,
this, std::placeholders::_1),
59 std::bind(&TriangleMeshPlyReaderDelegate::endVertices,
this, std::placeholders::_1));
67 if (m_hasTextureCoordinates)
78 std::bind(&TriangleMeshPlyReaderDelegate::beginFaces,
this,
79 std::placeholders::_1, std::placeholders::_2),
80 std::bind(&TriangleMeshPlyReaderDelegate::processFace,
this, std::placeholders::_1),
81 std::bind(&TriangleMeshPlyReaderDelegate::endFaces,
this, std::placeholders::_1));
83 PlyReader::TYPE_UNSIGNED_INT,
84 offsetof(ListData, indices),
85 PlyReader::TYPE_UNSIGNED_INT,
86 offsetof(ListData, count));
94 std::bind(&TriangleMeshPlyReaderDelegate::beginEdges,
this,
95 std::placeholders::_1, std::placeholders::_2),
96 std::bind(&TriangleMeshPlyReaderDelegate::processEdge,
this, std::placeholders::_1),
97 std::bind(&TriangleMeshPlyReaderDelegate::endEdges,
this, std::placeholders::_1));
99 PlyReader::TYPE_UNSIGNED_INT,
100 offsetof(ListData, indices),
101 PlyReader::TYPE_UNSIGNED_INT,
102 offsetof(ListData, count));
115 m_hasFaces = reader.
hasProperty(
"face",
"vertex_indices") &&
116 !reader.
isScalar(
"face",
"vertex_indices");
118 m_hasEdges = reader.
hasProperty(
"1d_element",
"vertex_indices") &&
119 !reader.
isScalar(
"1d_element",
"vertex_indices");
122 result = result && reader.
hasProperty(
"vertex",
"x");
123 result = result && reader.
hasProperty(
"vertex",
"y");
124 result = result && reader.
hasProperty(
"vertex",
"z");
125 result = result && (m_hasFaces || m_hasEdges);
135 m_vertexData.overrun1 = 0l;
136 m_vertexData.overrun2 = 0l;
137 return &m_vertexData;
144 m_mesh->addVertex(vertex);
150 SURGSIM_ASSERT(m_vertexData.overrun1 == 0l && m_vertexData.overrun2 == 0l) <<
151 "There was an overrun while reading the vertex structures, it is likely that data " <<
152 "has become corrupted.";
160 m_listData.overrun = 0l;
167 SURGSIM_ASSERT(m_listData.count == 3) <<
"Can only process triangle meshes.";
168 std::copy(m_listData.indices, m_listData.indices + 3, m_face.begin());
170 typename M::TriangleType triangle(m_face);
171 m_mesh->addTriangle(triangle);
178 <<
"There was an overrun while reading the face structures, it is likely that data "
179 <<
"has become corrupted.";
191 return m_hasTextureCoordinates;
198 m_listData.overrun = 0l;
206 SURGSIM_ASSERT(m_listData.count == 2) <<
"Edges have to have 2 points.";
207 std::copy(m_listData.indices, m_listData.indices + 2, m_edge.begin());
209 typename M::EdgeType edge(m_edge);
210 m_mesh->addEdge(edge);
218 <<
"There was an overrun while reading the face structures, it is likely that data "
219 <<
"has become corrupted.";