1 #include <gtest/gtest.h>
2 #include <Unittests/unittests_common.hh>
12 virtual void SetUp() {
18 virtual void TearDown() {
37 TEST_F(OpenMeshReadWritePLY, LoadSimplePointPLYFileWithBadEncoding) {
43 EXPECT_TRUE(ok) <<
"Unable to load pointCloudBadEncoding.ply";
45 EXPECT_EQ(10u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
46 EXPECT_EQ(0u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
47 EXPECT_EQ(0u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
54 TEST_F(OpenMeshReadWritePLY, LoadSimplePointPLYFileWithGoodEncoding) {
60 EXPECT_TRUE(ok) <<
"Unable to load pointCloudGoodEncoding.ply";
62 EXPECT_EQ(10u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
63 EXPECT_EQ(0u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
64 EXPECT_EQ(0u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
70 TEST_F(OpenMeshReadWritePLY, LoadSimplePLY) {
76 EXPECT_TRUE(ok) <<
"Unable to load cube-minimal.ply";
78 EXPECT_EQ(8u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
79 EXPECT_EQ(18u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
80 EXPECT_EQ(12u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
87 TEST_F(OpenMeshReadWritePLY, LoadSimplePLYForceVertexColorsAlthoughNotAvailable) {
91 mesh_.request_vertex_colors();
93 std::string file_name =
"cube-minimal.ply";
100 EXPECT_TRUE(ok) << file_name;
102 EXPECT_EQ(8u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
103 EXPECT_EQ(18u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
104 EXPECT_EQ(12u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
105 EXPECT_EQ(36u , mesh_.n_halfedges()) <<
"The number of loaded halfedges is not correct!";
107 EXPECT_FALSE(options.vertex_has_normal()) <<
"Wrong user options are returned!";
108 EXPECT_FALSE(options.vertex_has_texcoord()) <<
"Wrong user options are returned!";
109 EXPECT_FALSE(options.vertex_has_color()) <<
"Wrong user options are returned!";
115 TEST_F(OpenMeshReadWritePLY, LoadSimplePLYWithVertexColors) {
119 mesh_.request_vertex_colors();
126 EXPECT_TRUE(ok) <<
"Unable to load cube-minimal-vertexColors.ply";
128 EXPECT_EQ(8u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
129 EXPECT_EQ(18u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
130 EXPECT_EQ(12u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
132 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(0))[0] ) <<
"Wrong vertex color at vertex 0 component 0";
133 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(0))[1] ) <<
"Wrong vertex color at vertex 0 component 1";
134 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(0))[2] ) <<
"Wrong vertex color at vertex 0 component 2";
136 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(3))[0] ) <<
"Wrong vertex color at vertex 3 component 0";
137 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(3))[1] ) <<
"Wrong vertex color at vertex 3 component 1";
138 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(3))[2] ) <<
"Wrong vertex color at vertex 3 component 2";
140 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(4))[0] ) <<
"Wrong vertex color at vertex 4 component 0";
141 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(4))[1] ) <<
"Wrong vertex color at vertex 4 component 1";
142 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(4))[2] ) <<
"Wrong vertex color at vertex 4 component 2";
144 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(7))[0] ) <<
"Wrong vertex color at vertex 7 component 0";
145 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(7))[1] ) <<
"Wrong vertex color at vertex 7 component 1";
146 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(7))[2] ) <<
"Wrong vertex color at vertex 7 component 2";
148 EXPECT_FALSE(options.vertex_has_normal()) <<
"Wrong user options are returned!";
149 EXPECT_FALSE(options.vertex_has_texcoord()) <<
"Wrong user options are returned!";
150 EXPECT_TRUE(options.vertex_has_color()) <<
"Wrong user options are returned!";
152 mesh_.release_vertex_colors();
158 TEST_F(OpenMeshReadWritePLY, LoadPLYFromMeshLabWithVertexColors) {
162 mesh_.request_vertex_colors();
169 EXPECT_TRUE(ok) <<
"Unable to load meshlab.ply";
171 EXPECT_EQ(8u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
172 EXPECT_EQ(18u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
173 EXPECT_EQ(12u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
175 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(0))[0] ) <<
"Wrong vertex color at vertex 0 component 0";
176 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(0))[1] ) <<
"Wrong vertex color at vertex 0 component 1";
177 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(0))[2] ) <<
"Wrong vertex color at vertex 0 component 2";
179 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(3))[0] ) <<
"Wrong vertex color at vertex 3 component 0";
180 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(3))[1] ) <<
"Wrong vertex color at vertex 3 component 1";
181 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(3))[2] ) <<
"Wrong vertex color at vertex 3 component 2";
183 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(4))[0] ) <<
"Wrong vertex color at vertex 4 component 0";
184 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(4))[1] ) <<
"Wrong vertex color at vertex 4 component 1";
185 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(4))[2] ) <<
"Wrong vertex color at vertex 4 component 2";
187 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(7))[0] ) <<
"Wrong vertex color at vertex 7 component 0";
188 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(7))[1] ) <<
"Wrong vertex color at vertex 7 component 1";
189 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(7))[2] ) <<
"Wrong vertex color at vertex 7 component 2";
191 EXPECT_FALSE(options.vertex_has_normal()) <<
"Wrong user options are returned!";
192 EXPECT_FALSE(options.vertex_has_texcoord()) <<
"Wrong user options are returned!";
193 EXPECT_TRUE(options.vertex_has_color()) <<
"Wrong user options are returned!";
195 mesh_.release_vertex_colors();
201 TEST_F(OpenMeshReadWritePLY, WriteAndReadBinaryPLYWithVertexColors) {
205 mesh_.request_vertex_colors();
212 EXPECT_TRUE(ok) <<
"Unable to load meshlab.ply";
217 EXPECT_TRUE(ok) <<
"Unable to write meshlab_binary.ply";
221 EXPECT_TRUE(ok) <<
"Unable to load meshlab_binary.ply";
223 EXPECT_EQ(8u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
224 EXPECT_EQ(18u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
225 EXPECT_EQ(12u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
227 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(0))[0] ) <<
"Wrong vertex color at vertex 0 component 0";
228 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(0))[1] ) <<
"Wrong vertex color at vertex 0 component 1";
229 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(0))[2] ) <<
"Wrong vertex color at vertex 0 component 2";
231 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(3))[0] ) <<
"Wrong vertex color at vertex 3 component 0";
232 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(3))[1] ) <<
"Wrong vertex color at vertex 3 component 1";
233 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(3))[2] ) <<
"Wrong vertex color at vertex 3 component 2";
235 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(4))[0] ) <<
"Wrong vertex color at vertex 4 component 0";
236 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(4))[1] ) <<
"Wrong vertex color at vertex 4 component 1";
237 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(4))[2] ) <<
"Wrong vertex color at vertex 4 component 2";
239 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(7))[0] ) <<
"Wrong vertex color at vertex 7 component 0";
240 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(7))[1] ) <<
"Wrong vertex color at vertex 7 component 1";
241 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(7))[2] ) <<
"Wrong vertex color at vertex 7 component 2";
243 EXPECT_FALSE(options.vertex_has_normal()) <<
"Wrong user options are returned!";
244 EXPECT_FALSE(options.vertex_has_texcoord()) <<
"Wrong user options are returned!";
245 EXPECT_TRUE(options.vertex_has_color()) <<
"Wrong user options are returned!";
247 mesh_.release_vertex_colors();
253 TEST_F(OpenMeshReadWritePLY, WriteAndReadPLYWithFloatVertexColors) {
257 mesh_.request_vertex_colors();
264 EXPECT_TRUE(ok) <<
"Unable to load meshlab.ply";
269 EXPECT_TRUE(ok) <<
"Unable to write meshlab_float.ply";
273 EXPECT_TRUE(ok) <<
"Unable to load meshlab_float.ply";
275 EXPECT_EQ(8u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
276 EXPECT_EQ(18u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
277 EXPECT_EQ(12u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
279 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(0))[0] ) <<
"Wrong vertex color at vertex 0 component 0";
280 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(0))[1] ) <<
"Wrong vertex color at vertex 0 component 1";
281 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(0))[2] ) <<
"Wrong vertex color at vertex 0 component 2";
283 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(3))[0] ) <<
"Wrong vertex color at vertex 3 component 0";
284 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(3))[1] ) <<
"Wrong vertex color at vertex 3 component 1";
285 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(3))[2] ) <<
"Wrong vertex color at vertex 3 component 2";
287 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(4))[0] ) <<
"Wrong vertex color at vertex 4 component 0";
288 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(4))[1] ) <<
"Wrong vertex color at vertex 4 component 1";
289 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(4))[2] ) <<
"Wrong vertex color at vertex 4 component 2";
291 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(7))[0] ) <<
"Wrong vertex color at vertex 7 component 0";
292 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(7))[1] ) <<
"Wrong vertex color at vertex 7 component 1";
293 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(7))[2] ) <<
"Wrong vertex color at vertex 7 component 2";
295 EXPECT_FALSE(options.vertex_has_normal()) <<
"Wrong user options are returned!";
296 EXPECT_FALSE(options.vertex_has_texcoord()) <<
"Wrong user options are returned!";
297 EXPECT_TRUE(options.vertex_has_color()) <<
"Wrong user options are returned!";
298 EXPECT_TRUE(options.color_is_float()) <<
"Wrong user options are returned!";
300 mesh_.release_vertex_colors();
306 TEST_F(OpenMeshReadWritePLY, WriteAndReadBinaryPLYWithFloatVertexColors) {
310 mesh_.request_vertex_colors();
317 EXPECT_TRUE(ok) <<
"Unable to load meshlab.ply";
323 EXPECT_TRUE(ok) <<
"Unable to write meshlab_binary_float.ply";
327 EXPECT_TRUE(ok) <<
"Unable to load meshlab_binary_float.ply";
329 EXPECT_EQ(8u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
330 EXPECT_EQ(18u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
331 EXPECT_EQ(12u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
333 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(0))[0] ) <<
"Wrong vertex color at vertex 0 component 0";
334 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(0))[1] ) <<
"Wrong vertex color at vertex 0 component 1";
335 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(0))[2] ) <<
"Wrong vertex color at vertex 0 component 2";
337 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(3))[0] ) <<
"Wrong vertex color at vertex 3 component 0";
338 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(3))[1] ) <<
"Wrong vertex color at vertex 3 component 1";
339 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(3))[2] ) <<
"Wrong vertex color at vertex 3 component 2";
341 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(4))[0] ) <<
"Wrong vertex color at vertex 4 component 0";
342 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(4))[1] ) <<
"Wrong vertex color at vertex 4 component 1";
343 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(4))[2] ) <<
"Wrong vertex color at vertex 4 component 2";
345 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(7))[0] ) <<
"Wrong vertex color at vertex 7 component 0";
346 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(7))[1] ) <<
"Wrong vertex color at vertex 7 component 1";
347 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(7))[2] ) <<
"Wrong vertex color at vertex 7 component 2";
349 EXPECT_FALSE(options.vertex_has_normal()) <<
"Wrong user options are returned!";
350 EXPECT_FALSE(options.vertex_has_texcoord()) <<
"Wrong user options are returned!";
351 EXPECT_TRUE(options.vertex_has_color()) <<
"Wrong user options are returned!";
352 EXPECT_TRUE(options.color_is_float()) <<
"Wrong user options are returned!";
353 EXPECT_TRUE(options.is_binary()) <<
"Wrong user options are returned!";
355 mesh_.release_vertex_colors();
361 TEST_F(OpenMeshReadWritePLY, LoadSimplePLYWithTexCoords) {
365 mesh_.request_vertex_texcoords2D();
372 EXPECT_TRUE(ok) <<
"Unable to load cube-minimal-texCoords.ply";
374 EXPECT_EQ(8u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
375 EXPECT_EQ(18u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
376 EXPECT_EQ(12u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
378 EXPECT_EQ(10, mesh_.texcoord2D(mesh_.vertex_handle(0))[0] ) <<
"Wrong vertex color at vertex 0 component 0";
379 EXPECT_EQ(10, mesh_.texcoord2D(mesh_.vertex_handle(0))[1] ) <<
"Wrong vertex color at vertex 0 component 1";
381 EXPECT_EQ(6, mesh_.texcoord2D(mesh_.vertex_handle(2))[0] ) <<
"Wrong vertex color at vertex 2 component 0";
382 EXPECT_EQ(6, mesh_.texcoord2D(mesh_.vertex_handle(2))[1] ) <<
"Wrong vertex color at vertex 2 component 1";
384 EXPECT_EQ(9, mesh_.texcoord2D(mesh_.vertex_handle(4))[0] ) <<
"Wrong vertex color at vertex 4 component 0";
385 EXPECT_EQ(9, mesh_.texcoord2D(mesh_.vertex_handle(4))[1] ) <<
"Wrong vertex color at vertex 4 component 1";
387 EXPECT_EQ(12, mesh_.texcoord2D(mesh_.vertex_handle(7))[0] ) <<
"Wrong vertex color at vertex 7 component 0";
388 EXPECT_EQ(12, mesh_.texcoord2D(mesh_.vertex_handle(7))[1] ) <<
"Wrong vertex color at vertex 7 component 1";
391 EXPECT_FALSE(options.vertex_has_normal()) <<
"Wrong user options are returned!";
392 EXPECT_TRUE(options.vertex_has_texcoord()) <<
"Wrong user options are returned!";
393 EXPECT_FALSE(options.vertex_has_color()) <<
"Wrong user options are returned!";
395 mesh_.release_vertex_texcoords2D();
401 TEST_F(OpenMeshReadWritePLY, LoadSimplePLYWithNormals) {
405 mesh_.request_vertex_normals();
412 EXPECT_TRUE(ok) <<
"Unable to load cube-minimal-normals.ply";
414 EXPECT_EQ(8u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
415 EXPECT_EQ(18u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
416 EXPECT_EQ(12u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
418 EXPECT_TRUE(options.vertex_has_normal()) <<
"Wrong user options are returned!";
419 EXPECT_FALSE(options.vertex_has_texcoord()) <<
"Wrong user options are returned!";
420 EXPECT_FALSE(options.vertex_has_color()) <<
"Wrong user options are returned!";
423 EXPECT_EQ(0, mesh_.normal(mesh_.vertex_handle(0))[0] ) <<
"Wrong normal at vertex 0 component 0";
424 EXPECT_EQ(0, mesh_.normal(mesh_.vertex_handle(0))[1] ) <<
"Wrong normal at vertex 0 component 1";
425 EXPECT_EQ(1, mesh_.normal(mesh_.vertex_handle(0))[2] ) <<
"Wrong normal at vertex 0 component 2";
427 EXPECT_EQ(1, mesh_.normal(mesh_.vertex_handle(3))[0] ) <<
"Wrong normal at vertex 3 component 0";
428 EXPECT_EQ(0, mesh_.normal(mesh_.vertex_handle(3))[1] ) <<
"Wrong normal at vertex 3 component 1";
429 EXPECT_EQ(0, mesh_.normal(mesh_.vertex_handle(3))[2] ) <<
"Wrong normal at vertex 3 component 2";
431 EXPECT_EQ(1, mesh_.normal(mesh_.vertex_handle(4))[0] ) <<
"Wrong normal at vertex 4 component 0";
432 EXPECT_EQ(0, mesh_.normal(mesh_.vertex_handle(4))[1] ) <<
"Wrong normal at vertex 4 component 1";
433 EXPECT_EQ(1, mesh_.normal(mesh_.vertex_handle(4))[2] ) <<
"Wrong normal at vertex 4 component 2";
435 EXPECT_EQ(1, mesh_.normal(mesh_.vertex_handle(7))[0] ) <<
"Wrong normal at vertex 7 component 0";
436 EXPECT_EQ(1, mesh_.normal(mesh_.vertex_handle(7))[1] ) <<
"Wrong normal at vertex 7 component 1";
437 EXPECT_EQ(2, mesh_.normal(mesh_.vertex_handle(7))[2] ) <<
"Wrong normal at vertex 7 component 2";
439 mesh_.release_vertex_normals();
446 TEST_F(OpenMeshReadWritePLY, LoadSimplePLYWithCustomProps) {
455 EXPECT_TRUE(ok) <<
"Unable to load cube-minimal-custom_props.ply";
457 EXPECT_EQ(8u , mesh.n_vertices()) <<
"The number of loaded vertices is not correct!";
458 EXPECT_EQ(12u , mesh.n_edges()) <<
"The number of loaded edges is not correct!";
459 EXPECT_EQ(6u , mesh.n_faces()) <<
"The number of loaded faces is not correct!";
463 ASSERT_TRUE(mesh.get_property_handle(qualityProp,
"quality")) <<
"Could not access quality property";
464 ASSERT_TRUE(mesh.get_property_handle(indexProp,
"index")) <<
"Could not access index property";
467 for (
unsigned i = 0; i < mesh.n_vertices(); ++i)
468 EXPECT_EQ(i ,mesh.property(indexProp,
OpenMesh::VertexHandle(i))) <<
"Vertex index at vertex " << i <<
" is wrong";
472 EXPECT_EQ(0.5f,mesh.property(qualityProp,
OpenMesh::VertexHandle(1))) <<
"Wrong quality value at Vertex 1";
473 EXPECT_EQ(0.7f,mesh.property(qualityProp,
OpenMesh::VertexHandle(2))) <<
"Wrong quality value at Vertex 2";
475 EXPECT_EQ(0.1f,mesh.property(qualityProp,
OpenMesh::VertexHandle(4))) <<
"Wrong quality value at Vertex 4";
483 ASSERT_TRUE(mesh.get_property_handle(testValues,
"test_values")) <<
"Could not access texcoords per face";
497 ASSERT_TRUE(mesh.get_property_handle(texCoordsPerFace,
"texcoords")) <<
"Could not access texcoords per face";
499 for (Mesh::FaceIter f_iter = mesh.faces_begin(); f_iter != mesh.faces_end(); ++f_iter)
501 EXPECT_EQ(8u, mesh.property(texCoordsPerFace, *f_iter).size()) <<
"Texcoords per face container has wrong size on face: " << f_iter->
idx();
502 if (!mesh.property(texCoordsPerFace, *f_iter).empty())
504 EXPECT_EQ(1.0, mesh.property(texCoordsPerFace, *f_iter)[0]) <<
"Texcoords wrong on index 0 with face: " << f_iter->idx();
505 EXPECT_EQ(1.0, mesh.property(texCoordsPerFace, *f_iter)[1]) <<
"Texcoords wrong on index 1 with face: " << f_iter->idx();
506 EXPECT_EQ(-1.0f, mesh.property(texCoordsPerFace, *f_iter)[2]) <<
"Texcoords wrong on index 2 with face: " << f_iter->idx();
507 EXPECT_EQ(-1.0f, mesh.property(texCoordsPerFace, *f_iter)[3]) <<
"Texcoords wrong on index 3 with face: " << f_iter->idx();
508 EXPECT_EQ(0.0f, mesh.property(texCoordsPerFace, *f_iter)[4]) <<
"Texcoords wrong on index 4 with face: " << f_iter->idx();
509 EXPECT_EQ(0.0f, mesh.property(texCoordsPerFace, *f_iter)[5]) <<
"Texcoords wrong on index 5 with face: " << f_iter->idx();
510 EXPECT_EQ(-0.5f, mesh.property(texCoordsPerFace, *f_iter)[6]) <<
"Texcoords wrong on index 6 with face: " << f_iter->idx();
511 EXPECT_EQ(-0.5f, mesh.property(texCoordsPerFace, *f_iter)[7]) <<
"Texcoords wrong on index 7 with face: " << f_iter->idx();
517 ASSERT_TRUE(mesh.get_property_handle(faceIndex,
"faceIndex")) <<
"Could not access faceIndex per face";
519 EXPECT_EQ(0u,mesh.property(faceIndex,
OpenMesh::FaceHandle(0))) <<
"Wrong index value at FaceHandle 0";
520 EXPECT_EQ(1u,mesh.property(faceIndex,
OpenMesh::FaceHandle(1))) <<
"Wrong index value at FaceHandle 1";
521 EXPECT_EQ(2u,mesh.property(faceIndex,
OpenMesh::FaceHandle(2))) <<
"Wrong index value at FaceHandle 2";
522 EXPECT_EQ(3u,mesh.property(faceIndex,
OpenMesh::FaceHandle(3))) <<
"Wrong index value at FaceHandle 3";
523 EXPECT_EQ(4u,mesh.property(faceIndex,
OpenMesh::FaceHandle(4))) <<
"Wrong index value at FaceHandle 4";
524 EXPECT_EQ(5u,mesh.property(faceIndex,
OpenMesh::FaceHandle(5))) <<
"Wrong index value at FaceHandle 5";
529 TEST_F(OpenMeshReadWritePLY, WriteReadSimplePLYWithCustomProps) {
543 const std::string indexPropName =
"mySuperIndexProperty";
544 const std::string qualityPropName =
"quality";
545 const std::string facePropName =
"anotherPropForFaces";
546 const std::string nonPersistantName =
"nonPersistant";
547 const std::string removedPropName =
"willBeRemoved";
549 mesh.add_property(indexProp,indexPropName);
550 mesh.add_property(qualityProp,qualityPropName);
551 mesh.add_property(removedProp, removedPropName);
552 mesh.add_property(faceProp,facePropName);
553 mesh.add_property(nonPersistant,nonPersistantName);
555 mesh.property(indexProp).set_persistent(
true);
556 mesh.property(qualityProp).set_persistent(
true);
557 mesh.property(faceProp).set_persistent(
true);
558 mesh.remove_property(removedProp);
561 for (Mesh::VertexIter v_iter = mesh.vertices_begin(); v_iter != mesh.vertices_end(); ++v_iter, ++i)
563 mesh.property(indexProp, *v_iter) = i;
564 mesh.property(qualityProp, *v_iter) = 3.5*i;
568 for (Mesh::FaceIter f_iter = mesh.faces_begin(); f_iter != mesh.faces_end(); ++f_iter, ++i)
570 mesh.property(faceProp, *f_iter) = -i;
573 const char* outFilename =
"cube-minimal-customprops_openmeshOutputTestfile.ply";
580 EXPECT_FALSE(loadedMesh.get_property_handle(indexProp,indexPropName)) <<
"Could access to property which was deleted";
588 ASSERT_TRUE(loadedMesh.get_property_handle(indexProp,indexPropName)) <<
"Could not access index property";
589 ASSERT_TRUE(loadedMesh.get_property_handle(qualityProp,qualityPropName)) <<
"Could not access quality property";
590 ASSERT_TRUE(loadedMesh.get_property_handle(faceProp,facePropName)) <<
"Could not access face property";
591 EXPECT_FALSE(loadedMesh.get_property_handle(nonPersistant,nonPersistantName)) <<
"Could access non persistant property";
594 for (Mesh::VertexIter v_iter = loadedMesh.vertices_begin(); v_iter != loadedMesh.vertices_end(); ++v_iter, ++i)
596 EXPECT_EQ(loadedMesh.property(indexProp, *v_iter),
static_cast<unsigned>(i));
597 EXPECT_EQ(loadedMesh.property(qualityProp, *v_iter),3.5*i);
601 for (Mesh::FaceIter f_iter = loadedMesh.faces_begin(); f_iter != loadedMesh.faces_end(); ++f_iter, ++i)
603 EXPECT_EQ(loadedMesh.property(faceProp, *f_iter),-i);
611 TEST_F(OpenMeshReadWritePLY, WriteReadBinaryPLYWithCustomProps) {
625 const std::string indexPropName =
"mySuperIndexProperty";
626 const std::string qualityPropName =
"quality";
627 const std::string facePropName =
"anotherPropForFaces";
628 const std::string nonPersistantName =
"nonPersistant";
629 const std::string removedPropName =
"willBeRemoved";
631 mesh.add_property(indexProp,indexPropName);
632 mesh.add_property(qualityProp,qualityPropName);
633 mesh.add_property(removedProp, removedPropName);
634 mesh.add_property(faceProp,facePropName);
635 mesh.add_property(nonPersistant,nonPersistantName);
637 mesh.property(indexProp).set_persistent(
true);
638 mesh.property(qualityProp).set_persistent(
true);
639 mesh.property(faceProp).set_persistent(
true);
640 mesh.remove_property(removedProp);
643 for (Mesh::VertexIter v_iter = mesh.vertices_begin(); v_iter != mesh.vertices_end(); ++v_iter, ++i)
645 mesh.property(indexProp, *v_iter) = i;
646 mesh.property(qualityProp, *v_iter) = 3.5*i;
650 for (Mesh::FaceIter f_iter = mesh.faces_begin(); f_iter != mesh.faces_end(); ++f_iter, ++i)
652 mesh.property(faceProp, *f_iter) = -i;
655 const char* outFilename =
"cube-minimal-customprops_openmeshOutputTestfileBinary.ply";
663 EXPECT_FALSE(loadedMesh.get_property_handle(indexProp,indexPropName)) <<
"Could access to property which was deleted";
673 ASSERT_TRUE(loadedMesh.get_property_handle(indexProp,indexPropName)) <<
"Could not access index property";
674 ASSERT_TRUE(loadedMesh.get_property_handle(qualityProp,qualityPropName)) <<
"Could not access quality property";
675 ASSERT_TRUE(loadedMesh.get_property_handle(faceProp,facePropName)) <<
"Could not access face property";
676 EXPECT_FALSE(loadedMesh.get_property_handle(nonPersistant,nonPersistantName)) <<
"Could access non persistant property";
679 for (Mesh::VertexIter v_iter = loadedMesh.vertices_begin(); v_iter != loadedMesh.vertices_end(); ++v_iter, ++i)
681 EXPECT_EQ(loadedMesh.property(indexProp, *v_iter),
static_cast<unsigned>(i));
682 EXPECT_EQ(loadedMesh.property(qualityProp, *v_iter),3.5*i);
686 for (Mesh::FaceIter f_iter = loadedMesh.faces_begin(); f_iter != loadedMesh.faces_end(); ++f_iter, ++i)
688 EXPECT_EQ(loadedMesh.property(faceProp, *f_iter),-i);
bool read_mesh(Mesh &_mesh, const std::string &_filename)
Read a mesh from file _filename.
Has (r) / store (w) vertex normals.
int idx() const
Get the underlying index of this handle.
Has (r) / store (w) texture coordinates.
Set options for reader/writer modules.
Handle for a vertex entity.
Has (r) / store (w) float values for colors (currently only implemented for PLY and OFF files) ...
Handle for a face entity.
void clear(void)
Clear all bits.
Has (r) / store (w) vertex colors.
bool write_mesh(const Mesh &_mesh, const std::string &_filename, Options _opt=Options::Default, std::streamsize _precision=6)
Write a mesh to the file _filename.
Has (r) custom properties (currently only implemented in PLY Reader ASCII version) ...