1 #include <gtest/gtest.h> 2 #include <Unittests/unittests_common.hh> 12 virtual void SetUp() {
18 virtual void TearDown() {
36 TEST_F(OpenMeshReadWriteOM, LoadSimpleOMForceVertexColorsAlthoughNotAvailable) {
40 mesh_.request_vertex_colors();
42 std::string file_name =
"cube-minimal.om";
49 EXPECT_TRUE(ok) << file_name;
51 EXPECT_EQ(8u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
52 EXPECT_EQ(18u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
53 EXPECT_EQ(12u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
54 EXPECT_EQ(36u , mesh_.n_halfedges()) <<
"The number of loaded halfedges is not correct!";
56 EXPECT_FALSE(options.vertex_has_normal()) <<
"Wrong user options are returned!";
57 EXPECT_FALSE(options.vertex_has_texcoord()) <<
"Wrong user options are returned!";
58 EXPECT_FALSE(options.vertex_has_color()) <<
"Wrong user options are returned!";
64 TEST_F(OpenMeshReadWriteOM, LoadSimpleOMWithTexCoords) {
68 mesh_.request_vertex_texcoords2D();
75 ASSERT_TRUE(ok) <<
"Unable to load cube-minimal-texCoords.om";
77 EXPECT_EQ(8u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
78 EXPECT_EQ(18u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
79 EXPECT_EQ(12u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
81 EXPECT_EQ(10, mesh_.texcoord2D(mesh_.vertex_handle(0))[0] ) <<
"Wrong vertex color at vertex 0 component 0";
82 EXPECT_EQ(10, mesh_.texcoord2D(mesh_.vertex_handle(0))[1] ) <<
"Wrong vertex color at vertex 0 component 1";
84 EXPECT_EQ(6, mesh_.texcoord2D(mesh_.vertex_handle(2))[0] ) <<
"Wrong vertex color at vertex 2 component 0";
85 EXPECT_EQ(6, mesh_.texcoord2D(mesh_.vertex_handle(2))[1] ) <<
"Wrong vertex color at vertex 2 component 1";
87 EXPECT_EQ(9, mesh_.texcoord2D(mesh_.vertex_handle(4))[0] ) <<
"Wrong vertex color at vertex 4 component 0";
88 EXPECT_EQ(9, mesh_.texcoord2D(mesh_.vertex_handle(4))[1] ) <<
"Wrong vertex color at vertex 4 component 1";
90 EXPECT_EQ(12, mesh_.texcoord2D(mesh_.vertex_handle(7))[0] ) <<
"Wrong vertex color at vertex 7 component 0";
91 EXPECT_EQ(12, mesh_.texcoord2D(mesh_.vertex_handle(7))[1] ) <<
"Wrong vertex color at vertex 7 component 1";
94 EXPECT_FALSE(options.vertex_has_normal()) <<
"Wrong user options are returned!";
95 EXPECT_TRUE(options.vertex_has_texcoord()) <<
"Wrong user options are returned!";
96 EXPECT_FALSE(options.vertex_has_color()) <<
"Wrong user options are returned!";
98 mesh_.release_vertex_texcoords2D();
104 TEST_F(OpenMeshReadWriteOM, LoadSimpleOMWithVertexColors) {
108 mesh_.request_vertex_colors();
115 EXPECT_TRUE(ok) <<
"Unable to load cube-minimal-vertexColors.om";
117 EXPECT_EQ(8u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
118 EXPECT_EQ(18u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
119 EXPECT_EQ(12u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
121 #ifdef TEST_DOUBLE_TRAITS 122 EXPECT_FLOAT_EQ(1.0, mesh_.color(mesh_.vertex_handle(0))[0] ) <<
"Wrong vertex color at vertex 0 component 0";
123 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(0))[1] ) <<
"Wrong vertex color at vertex 0 component 1";
124 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(0))[2] ) <<
"Wrong vertex color at vertex 0 component 2";
126 EXPECT_FLOAT_EQ(1.0, mesh_.color(mesh_.vertex_handle(3))[0] ) <<
"Wrong vertex color at vertex 3 component 0";
127 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(3))[1] ) <<
"Wrong vertex color at vertex 3 component 1";
128 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(3))[2] ) <<
"Wrong vertex color at vertex 3 component 2";
130 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(4))[0] ) <<
"Wrong vertex color at vertex 4 component 0";
131 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(4))[1] ) <<
"Wrong vertex color at vertex 4 component 1";
132 EXPECT_FLOAT_EQ(1.0, mesh_.color(mesh_.vertex_handle(4))[2] ) <<
"Wrong vertex color at vertex 4 component 2";
134 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(7))[0] ) <<
"Wrong vertex color at vertex 7 component 0";
135 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(7))[1] ) <<
"Wrong vertex color at vertex 7 component 1";
136 EXPECT_FLOAT_EQ(1.0, mesh_.color(mesh_.vertex_handle(7))[2] ) <<
"Wrong vertex color at vertex 7 component 2";
138 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(0))[0] ) <<
"Wrong vertex color at vertex 0 component 0";
139 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(0))[1] ) <<
"Wrong vertex color at vertex 0 component 1";
140 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(0))[2] ) <<
"Wrong vertex color at vertex 0 component 2";
142 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(3))[0] ) <<
"Wrong vertex color at vertex 3 component 0";
143 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(3))[1] ) <<
"Wrong vertex color at vertex 3 component 1";
144 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(3))[2] ) <<
"Wrong vertex color at vertex 3 component 2";
146 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(4))[0] ) <<
"Wrong vertex color at vertex 4 component 0";
147 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(4))[1] ) <<
"Wrong vertex color at vertex 4 component 1";
148 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(4))[2] ) <<
"Wrong vertex color at vertex 4 component 2";
150 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(7))[0] ) <<
"Wrong vertex color at vertex 7 component 0";
151 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(7))[1] ) <<
"Wrong vertex color at vertex 7 component 1";
152 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(7))[2] ) <<
"Wrong vertex color at vertex 7 component 2";
155 EXPECT_FALSE(options.vertex_has_normal()) <<
"Wrong user options are returned!";
156 EXPECT_FALSE(options.vertex_has_texcoord()) <<
"Wrong user options are returned!";
157 EXPECT_TRUE(options.vertex_has_color()) <<
"Wrong user options are returned!";
159 mesh_.release_vertex_colors();
165 TEST_F(OpenMeshReadWriteOM, WriteTriangle) {
170 const std::string filename =
"triangle-minimal.om";
176 mesh.add_face(v1,v2,v3);
180 EXPECT_TRUE(ok) <<
"Unable to write " << filename;
187 EXPECT_TRUE(ok) <<
"Unable to read " << filename;
190 EXPECT_EQ(3u , mesh.n_vertices()) <<
"The number of loaded vertices is not correct!";
191 EXPECT_EQ(3u , mesh.n_edges()) <<
"The number of loaded edges is not correct!";
192 EXPECT_EQ(1u , mesh.n_faces()) <<
"The number of loaded faces is not correct!";
194 EXPECT_EQ(
Mesh::Point(1.0,0.0,0.0) , mesh.point(v1)) <<
"Wrong coordinates at vertex 0";
195 EXPECT_EQ(
Mesh::Point(0.0,1.0,0.0) , mesh.point(v2)) <<
"Wrong coordinates at vertex 1";
196 EXPECT_EQ(
Mesh::Point(0.0,0.0,1.0) , mesh.point(v3)) <<
"Wrong coordinates at vertex 2";
199 remove(filename.c_str());
206 TEST_F(OpenMeshReadWriteOM, WriteTriangleVertexIntegerColor) {
210 mesh.request_vertex_colors();
216 const std::string filename =
"triangle-minimal-ColorsPerVertex.om";
222 mesh.add_face(v1,v2,v3);
224 #ifdef TEST_DOUBLE_TRAITS 234 mesh.set_color(v1,c1);
235 mesh.set_color(v2,c2);
236 mesh.set_color(v3,c3);
240 EXPECT_TRUE(ok) <<
"Unable to write "<<filename;
242 mesh.release_vertex_colors();
246 cmpMesh.request_vertex_colors();
248 EXPECT_TRUE(ok) <<
"Unable to read "<<filename;
250 EXPECT_TRUE(cmpMesh.has_vertex_colors()) <<
"Loaded mesh has no vertex colors.";
253 EXPECT_EQ(3u , cmpMesh.n_vertices()) <<
"The number of loaded vertices is not correct!";
254 EXPECT_EQ(3u , cmpMesh.n_edges()) <<
"The number of loaded edges is not correct!";
255 EXPECT_EQ(1u , cmpMesh.n_faces()) <<
"The number of loaded faces is not correct!";
257 EXPECT_EQ(
Mesh::Point(1.0,0.0,0.0) , cmpMesh.point(v1)) <<
"Wrong coordinates at vertex 0";
258 EXPECT_EQ(
Mesh::Point(0.0,1.0,0.0) , cmpMesh.point(v2)) <<
"Wrong coordinates at vertex 1";
259 EXPECT_EQ(
Mesh::Point(0.0,0.0,1.0) , cmpMesh.point(v3)) <<
"Wrong coordinates at vertex 2";
261 #ifdef TEST_DOUBLE_TRAITS 264 for (
size_t i = 0; i < c1.size(); ++i)
266 EXPECT_FLOAT_EQ(c1[i] , cmpMesh.color(v1)[i]) <<
"Wrong colors at coordinate " << i <<
" of vertex 0";
267 EXPECT_FLOAT_EQ(c2[i] , cmpMesh.color(v2)[i]) <<
"Wrong colors at coordinate " << i <<
" of vertex 1";
268 EXPECT_FLOAT_EQ(c3[i] , cmpMesh.color(v3)[i]) <<
"Wrong colors at coordinate " << i <<
" of vertex 2";
271 EXPECT_EQ(c1 , cmpMesh.color(v1)) <<
"Wrong colors at vertex 0";
272 EXPECT_EQ(c2 , cmpMesh.color(v2)) <<
"Wrong colors at vertex 1";
273 EXPECT_EQ(c3 , cmpMesh.color(v3)) <<
"Wrong colors at vertex 2";
277 cmpMesh.release_vertex_colors();
278 remove(filename.c_str());
285 TEST_F(OpenMeshReadWriteOM, WriteTriangleVertexBoolProperty) {
289 const std::string filename =
"triangle-minimal-VBProp.om";
295 mesh.add_face(v1,v2,v3);
298 mesh.add_property(prop,
"VBProp");
299 mesh.property(prop).set_persistent(
true);
301 mesh.property(prop,v1) =
true;
302 mesh.property(prop,v2) =
false;
303 mesh.property(prop,v3) =
true;
307 EXPECT_TRUE(ok) <<
"Unable to write "<<filename;
313 cmpMesh.add_property(prop,
"VBProp");
314 cmpMesh.property(prop).set_persistent(
true);
317 EXPECT_TRUE(ok) <<
"Unable to read "<<filename;
320 EXPECT_EQ(3u , cmpMesh.n_vertices()) <<
"The number of loaded vertices is not correct!";
321 EXPECT_EQ(3u , cmpMesh.n_edges()) <<
"The number of loaded edges is not correct!";
322 EXPECT_EQ(1u , cmpMesh.n_faces()) <<
"The number of loaded faces is not correct!";
324 EXPECT_EQ(
Mesh::Point(1.0,0.0,0.0) , cmpMesh.point(v1)) <<
"Wrong coordinates at vertex 0";
325 EXPECT_EQ(
Mesh::Point(0.0,1.0,0.0) , cmpMesh.point(v2)) <<
"Wrong coordinates at vertex 1";
326 EXPECT_EQ(
Mesh::Point(0.0,0.0,1.0) , cmpMesh.point(v3)) <<
"Wrong coordinates at vertex 2";
328 EXPECT_TRUE(cmpMesh.property(prop,v1)) <<
"Wrong Property value at vertex 0";
329 EXPECT_FALSE(cmpMesh.property(prop,v2)) <<
"Wrong Property value at vertex 1";
330 EXPECT_TRUE(cmpMesh.property(prop,v3)) <<
"Wrong Property value at vertex 2";
333 remove(filename.c_str());
340 TEST_F(OpenMeshReadWriteOM, WriteTriangleVertexBoolPropertySpaceEquivalent) {
344 const std::string filename =
"triangle-minimal-VBProp-pattern-test.om";
350 mesh.add_face(v1,v2,v3);
355 mesh.add_face(v4,v5,v6);
362 mesh.add_property(prop,
"VBProp");
363 mesh.property(prop).set_persistent(
true);
366 mesh.property(prop,v1) =
false;
367 mesh.property(prop,v2) =
false;
368 mesh.property(prop,v3) =
false;
369 mesh.property(prop,v4) =
false;
370 mesh.property(prop,v5) =
false;
371 mesh.property(prop,v6) =
true;
372 mesh.property(prop,v7) =
false;
373 mesh.property(prop,v8) =
false;
374 mesh.property(prop,v9) =
true;
378 EXPECT_TRUE(ok) <<
"Unable to write "<<filename;
383 cmpMesh.add_property(prop,
"VBProp");
384 cmpMesh.property(prop).set_persistent(
true);
387 EXPECT_TRUE(ok) <<
"Unable to read "<<filename;
390 EXPECT_EQ(9u , cmpMesh.n_vertices()) <<
"The number of loaded vertices is not correct!";
391 EXPECT_EQ(6u , cmpMesh.n_edges()) <<
"The number of loaded edges is not correct!";
392 EXPECT_EQ(2u , cmpMesh.n_faces()) <<
"The number of loaded faces is not correct!";
394 EXPECT_FALSE(cmpMesh.property(prop,v1)) <<
"Wrong Property value at vertex 0";
395 EXPECT_FALSE(cmpMesh.property(prop,v2)) <<
"Wrong Property value at vertex 1";
396 EXPECT_FALSE(cmpMesh.property(prop,v3)) <<
"Wrong Property value at vertex 2";
397 EXPECT_FALSE(cmpMesh.property(prop,v4)) <<
"Wrong Property value at vertex 3";
398 EXPECT_FALSE(cmpMesh.property(prop,v5)) <<
"Wrong Property value at vertex 4";
399 EXPECT_TRUE(cmpMesh.property(prop,v6)) <<
"Wrong Property value at vertex 5";
400 EXPECT_FALSE(cmpMesh.property(prop,v7)) <<
"Wrong Property value at vertex 6";
401 EXPECT_FALSE(cmpMesh.property(prop,v8)) <<
"Wrong Property value at vertex 7";
402 EXPECT_TRUE(cmpMesh.property(prop,v9)) <<
"Wrong Property value at vertex 8";
405 remove(filename.c_str());
412 TEST_F(OpenMeshReadWriteOM, WriteTriangleTwoVertexBoolProperty) {
416 const std::string filename =
"triangle-minimal-VBProp.om";
422 mesh.add_face(v1,v2,v3);
425 mesh.add_property(prop,
"VBProp");
426 mesh.property(prop).set_persistent(
true);
428 mesh.property(prop,v1) =
true;
429 mesh.property(prop,v2) =
false;
430 mesh.property(prop,v3) =
true;
433 mesh.add_property(prop2,
"VBProp2");
434 mesh.property(prop2).set_persistent(
true);
436 mesh.property(prop2,v1) =
false;
437 mesh.property(prop2,v2) =
false;
438 mesh.property(prop2,v3) =
false;
442 EXPECT_TRUE(ok) <<
"Unable to write "<<filename;
447 cmpMesh.add_property(prop,
"VBProp");
448 cmpMesh.property(prop).set_persistent(
true);
450 cmpMesh.add_property(prop2,
"VBProp2");
451 cmpMesh.property(prop2).set_persistent(
true);
454 EXPECT_TRUE(ok) <<
"Unable to read "<<filename;
457 EXPECT_EQ(3u , cmpMesh.n_vertices()) <<
"The number of loaded vertices is not correct!";
458 EXPECT_EQ(3u , cmpMesh.n_edges()) <<
"The number of loaded edges is not correct!";
459 EXPECT_EQ(1u , cmpMesh.n_faces()) <<
"The number of loaded faces is not correct!";
461 EXPECT_EQ(
Mesh::Point(1.0,0.0,0.0) , cmpMesh.point(v1)) <<
"Wrong coordinates at vertex 0";
462 EXPECT_EQ(
Mesh::Point(0.0,1.0,0.0) , cmpMesh.point(v2)) <<
"Wrong coordinates at vertex 1";
463 EXPECT_EQ(
Mesh::Point(0.0,0.0,1.0) , cmpMesh.point(v3)) <<
"Wrong coordinates at vertex 2";
465 EXPECT_TRUE(cmpMesh.property(prop,v1)) <<
"Wrong Property value at vertex 0";
466 EXPECT_FALSE(cmpMesh.property(prop,v2)) <<
"Wrong Property value at vertex 1";
467 EXPECT_TRUE(cmpMesh.property(prop,v3)) <<
"Wrong Property value at vertex 2";
469 EXPECT_FALSE(cmpMesh.property(prop2,v1)) <<
"Wrong second Property value at vertex 0";
470 EXPECT_FALSE(cmpMesh.property(prop2,v2)) <<
"Wrong second Property value at vertex 1";
471 EXPECT_FALSE(cmpMesh.property(prop2,v3)) <<
"Wrong second Property value at vertex 2";
474 remove(filename.c_str());
481 TEST_F(OpenMeshReadWriteOM, WriteTriangleEdgeIntProperty) {
485 const std::string propName =
"EIProp";
486 const std::string filename = std::string(
"triangle-minimal-")+propName+
".om";
492 mesh.add_face(v1,v2,v3);
495 mesh.add_property(prop,propName);
496 mesh.property(prop).set_persistent(
true);
498 Mesh::EdgeHandle e1 = Mesh::EdgeHandle(0);
499 Mesh::EdgeHandle e2 = Mesh::EdgeHandle(1);
500 Mesh::EdgeHandle e3 = Mesh::EdgeHandle(2);
506 mesh.property(prop,e1) = value1;
507 mesh.property(prop,e2) = value2;
508 mesh.property(prop,e3) = value3;
512 EXPECT_TRUE(ok) <<
"Unable to write "<<filename;
517 cmpMesh.add_property(prop,propName);
518 cmpMesh.property(prop).set_persistent(
true);
521 EXPECT_TRUE(ok) <<
"Unable to read "<<filename;
524 EXPECT_EQ(3u , cmpMesh.n_vertices()) <<
"The number of loaded vertices is not correct!";
525 EXPECT_EQ(3u , cmpMesh.n_edges()) <<
"The number of loaded edges is not correct!";
526 EXPECT_EQ(1u , cmpMesh.n_faces()) <<
"The number of loaded faces is not correct!";
528 EXPECT_EQ(
Mesh::Point(1.0,0.0,0.0) , cmpMesh.point(v1)) <<
"Wrong coordinates at vertex 0";
529 EXPECT_EQ(
Mesh::Point(0.0,1.0,0.0) , cmpMesh.point(v2)) <<
"Wrong coordinates at vertex 1";
530 EXPECT_EQ(
Mesh::Point(0.0,0.0,1.0) , cmpMesh.point(v3)) <<
"Wrong coordinates at vertex 2";
532 EXPECT_EQ(value1 , cmpMesh.property(prop,e1)) <<
"Wrong property at edge 0";
533 EXPECT_EQ(value2 , cmpMesh.property(prop,e2)) <<
"Wrong property at edge 1";
534 EXPECT_EQ(value3 , cmpMesh.property(prop,e3)) <<
"Wrong property at edge 2";
537 remove(filename.c_str());
544 TEST_F(OpenMeshReadWriteOM, WriteSplitTriangleEdgeIntProperty) {
548 const std::string propName =
"EIProp";
549 const std::string filename = std::string(
"triangle-minimal-")+propName+
".om";
555 auto fh0 = mesh.add_face(v1,v2,v3);
562 mesh.add_property(prop,propName);
563 mesh.property(prop).set_persistent(
true);
565 Mesh::EdgeHandle e1 = Mesh::EdgeHandle(0);
566 Mesh::EdgeHandle e2 = Mesh::EdgeHandle(1);
567 Mesh::EdgeHandle e3 = Mesh::EdgeHandle(2);
568 Mesh::EdgeHandle e4 = Mesh::EdgeHandle(3);
569 Mesh::EdgeHandle e5 = Mesh::EdgeHandle(4);
570 Mesh::EdgeHandle e6 = Mesh::EdgeHandle(5);
579 mesh.property(prop,e1) = value1;
580 mesh.property(prop,e2) = value2;
581 mesh.property(prop,e3) = value3;
582 mesh.property(prop,e4) = value4;
583 mesh.property(prop,e5) = value5;
584 mesh.property(prop,e6) = value6;
589 EXPECT_TRUE(ok) <<
"Unable to write "<<filename;
594 cmpMesh.add_property(prop,propName);
595 cmpMesh.property(prop).set_persistent(
true);
598 EXPECT_TRUE(ok) <<
"Unable to read "<<filename;
601 EXPECT_EQ(4u , cmpMesh.n_vertices()) <<
"The number of loaded vertices is not correct!";
602 EXPECT_EQ(6u , cmpMesh.n_edges()) <<
"The number of loaded edges is not correct!";
603 EXPECT_EQ(3u , cmpMesh.n_faces()) <<
"The number of loaded faces is not correct!";
605 EXPECT_EQ(
Mesh::Point(1.0,0.0,0.0) , cmpMesh.point(v1)) <<
"Wrong coordinates at vertex 0";
606 EXPECT_EQ(
Mesh::Point(0.0,1.0,0.0) , cmpMesh.point(v2)) <<
"Wrong coordinates at vertex 1";
607 EXPECT_EQ(
Mesh::Point(0.0,0.0,1.0) , cmpMesh.point(v3)) <<
"Wrong coordinates at vertex 2";
609 #ifdef TEST_DOUBLE_TRAITS 611 EXPECT_FLOAT_EQ(c[0] , cmpMesh.point(v4)[0]) <<
"Wrong coordinate 0 at vertex 4";
612 EXPECT_FLOAT_EQ(c[1] , cmpMesh.point(v4)[1]) <<
"Wrong coordinate 1 at vertex 4";
613 EXPECT_FLOAT_EQ(c[2] , cmpMesh.point(v4)[2]) <<
"Wrong coordinate 2 at vertex 4";
615 EXPECT_EQ(c , cmpMesh.point(v4)) <<
"Wrong coordinates at vertex 4";
618 EXPECT_EQ(value1 , cmpMesh.property(prop,e1)) <<
"Wrong property at edge 0";
619 EXPECT_EQ(value2 , cmpMesh.property(prop,e2)) <<
"Wrong property at edge 1";
620 EXPECT_EQ(value3 , cmpMesh.property(prop,e3)) <<
"Wrong property at edge 2";
621 EXPECT_EQ(value4 , cmpMesh.property(prop,e4)) <<
"Wrong property at edge 3";
622 EXPECT_EQ(value5 , cmpMesh.property(prop,e5)) <<
"Wrong property at edge 4";
623 EXPECT_EQ(value6 , cmpMesh.property(prop,e6)) <<
"Wrong property at edge 5";
627 for (
auto eh : mesh.edges())
629 auto heh = mesh.halfedge_handle(eh, 0);
630 auto from_vh = mesh.from_vertex_handle(heh);
631 auto to_vh = mesh.to_vertex_handle(heh);
634 auto cmpHeh = cmpMesh.find_halfedge(from_vh, to_vh);
635 auto cmpEh = cmpMesh.edge_handle(cmpHeh);
637 EXPECT_EQ(mesh.property(prop, eh), cmpMesh.property(prop, cmpEh)) <<
"Wrong property at input edge " << eh.idx()
638 <<
" corresponding to edge " << cmpEh.idx() <<
" in the loaded Mesh";
644 remove(filename.c_str());
651 TEST_F(OpenMeshReadWriteOM, WriteSplitTriangleStatusProperties) {
655 mesh.request_vertex_status();
656 mesh.request_edge_status();
657 mesh.request_halfedge_status();
658 mesh.request_face_status();
660 const std::string filename = std::string(
"triangle-minimal-status.om");
666 auto fh0 = mesh.add_face(v0,v1,v2);
671 mesh.delete_vertex(v0);
672 mesh.status(v1).set_selected(
true);
673 mesh.status(v2).set_feature(
true);
674 mesh.status(v3).set_tagged(
true);
675 mesh.status(v2).set_tagged2(
true);
677 std::vector<bool> vertex_deleted;
678 std::vector<bool> vertex_selected;
679 std::vector<bool> vertex_feature;
680 std::vector<bool> vertex_tagged;
681 std::vector<bool> vertex_tagged2;
683 for (
auto vh : mesh.all_vertices())
685 vertex_deleted.push_back(mesh.status(vh).deleted());
686 vertex_selected.push_back(mesh.status(vh).selected());
687 vertex_feature.push_back(mesh.status(vh).feature());
688 vertex_tagged.push_back(mesh.status(vh).tagged());
689 vertex_tagged2.push_back(mesh.status(vh).tagged2());
692 Mesh::EdgeHandle e1 = Mesh::EdgeHandle(0);
693 Mesh::EdgeHandle e2 = Mesh::EdgeHandle(1);
694 Mesh::EdgeHandle e3 = Mesh::EdgeHandle(2);
695 Mesh::EdgeHandle e4 = Mesh::EdgeHandle(3);
697 mesh.status(e1).set_selected(
true);
698 mesh.status(e2).set_feature(
true);
699 mesh.status(e3).set_tagged(
true);
700 mesh.status(e4).set_tagged2(
true);
702 std::vector<bool> edge_deleted;
703 std::vector<bool> edge_selected;
704 std::vector<bool> edge_feature;
705 std::vector<bool> edge_tagged;
706 std::vector<bool> edge_tagged2;
708 for (
auto eh : mesh.all_edges())
710 edge_deleted.push_back(mesh.status(eh).deleted());
711 edge_selected.push_back(mesh.status(eh).selected());
712 edge_feature.push_back(mesh.status(eh).feature());
713 edge_tagged.push_back(mesh.status(eh).tagged());
714 edge_tagged2.push_back(mesh.status(eh).tagged2());
718 Mesh::HalfedgeHandle he1 = Mesh::HalfedgeHandle(0);
719 Mesh::HalfedgeHandle he2 = Mesh::HalfedgeHandle(3);
720 Mesh::HalfedgeHandle he3 = Mesh::HalfedgeHandle(5);
721 Mesh::HalfedgeHandle he4 = Mesh::HalfedgeHandle(1);
723 mesh.status(he1).set_selected(
true);
724 mesh.status(he2).set_feature(
true);
725 mesh.status(he3).set_tagged(
true);
726 mesh.status(he4).set_tagged2(
true);
728 std::vector<bool> halfedge_deleted;
729 std::vector<bool> halfedge_selected;
730 std::vector<bool> halfedge_feature;
731 std::vector<bool> halfedge_tagged;
732 std::vector<bool> halfedge_tagged2;
734 for (
auto heh : mesh.all_halfedges())
736 halfedge_deleted.push_back(mesh.status(heh).deleted());
737 halfedge_selected.push_back(mesh.status(heh).selected());
738 halfedge_feature.push_back(mesh.status(heh).feature());
739 halfedge_tagged.push_back(mesh.status(heh).tagged());
740 halfedge_tagged2.push_back(mesh.status(heh).tagged2());
743 Mesh::FaceHandle f1 = Mesh::FaceHandle(0);
744 Mesh::FaceHandle f2 = Mesh::FaceHandle(2);
745 Mesh::FaceHandle f3 = Mesh::FaceHandle(1);
746 Mesh::FaceHandle f4 = Mesh::FaceHandle(2);
748 mesh.status(f1).set_selected(
true);
749 mesh.status(f2).set_feature(
true);
750 mesh.status(f3).set_tagged(
true);
751 mesh.status(f4).set_tagged2(
true);
753 std::vector<bool> face_deleted;
754 std::vector<bool> face_selected;
755 std::vector<bool> face_feature;
756 std::vector<bool> face_tagged;
757 std::vector<bool> face_tagged2;
759 for (
auto fh : mesh.all_faces())
761 face_deleted.push_back(mesh.status(fh).deleted());
762 face_selected.push_back(mesh.status(fh).selected());
763 face_feature.push_back(mesh.status(fh).feature());
764 face_tagged.push_back(mesh.status(fh).tagged());
765 face_tagged2.push_back(mesh.status(fh).tagged2());
771 EXPECT_TRUE(ok) <<
"Unable to write "<<filename;
776 cmpMesh.request_vertex_status();
777 cmpMesh.request_edge_status();
778 cmpMesh.request_halfedge_status();
779 cmpMesh.request_face_status();
782 EXPECT_TRUE(ok) <<
"Unable to read "<<filename;
785 EXPECT_EQ(4u , cmpMesh.n_vertices()) <<
"The number of loaded vertices is not correct!";
786 EXPECT_EQ(6u , cmpMesh.n_edges()) <<
"The number of loaded edges is not correct!";
787 EXPECT_EQ(3u , cmpMesh.n_faces()) <<
"The number of loaded faces is not correct!";
789 EXPECT_EQ(
Mesh::Point(1.0,0.0,0.0) , cmpMesh.point(v0)) <<
"Wrong coordinates at vertex 0";
790 EXPECT_EQ(
Mesh::Point(0.0,1.0,0.0) , cmpMesh.point(v1)) <<
"Wrong coordinates at vertex 1";
791 EXPECT_EQ(
Mesh::Point(0.0,0.0,1.0) , cmpMesh.point(v2)) <<
"Wrong coordinates at vertex 2";
793 #ifdef TEST_DOUBLE_TRAITS 795 EXPECT_FLOAT_EQ(c[0] , cmpMesh.point(v3)[0]) <<
"Wrong coordinate 0 at vertex 3";
796 EXPECT_FLOAT_EQ(c[1] , cmpMesh.point(v3)[1]) <<
"Wrong coordinate 1 at vertex 3";
797 EXPECT_FLOAT_EQ(c[2] , cmpMesh.point(v3)[2]) <<
"Wrong coordinate 2 at vertex 3";
799 EXPECT_EQ(c , cmpMesh.point(v3)) <<
"Wrong coordinates at vertex 3";
802 for (
auto vh : cmpMesh.all_vertices())
804 EXPECT_EQ(cmpMesh.status(vh).deleted(), vertex_deleted [vh.idx()]) <<
"Wrong deleted status at vertex " << vh.idx();
805 EXPECT_EQ(cmpMesh.status(vh).selected(), vertex_selected[vh.idx()]) <<
"Wrong selected status at vertex " << vh.idx();
806 EXPECT_EQ(cmpMesh.status(vh).feature(), vertex_feature [vh.idx()]) <<
"Wrong feature status at vertex " << vh.idx();
807 EXPECT_EQ(cmpMesh.status(vh).tagged(), vertex_tagged [vh.idx()]) <<
"Wrong tagged status at vertex " << vh.idx();
808 EXPECT_EQ(cmpMesh.status(vh).tagged2(), vertex_tagged2 [vh.idx()]) <<
"Wrong tagged2 status at vertex " << vh.idx();
811 for (
auto eh : cmpMesh.all_edges())
813 EXPECT_EQ(cmpMesh.status(eh).deleted(), edge_deleted [eh.idx()]) <<
"Wrong deleted status at edge " << eh.idx();
814 EXPECT_EQ(cmpMesh.status(eh).selected(), edge_selected[eh.idx()]) <<
"Wrong selected status at edge " << eh.idx();
815 EXPECT_EQ(cmpMesh.status(eh).feature(), edge_feature [eh.idx()]) <<
"Wrong feature status at edge " << eh.idx();
816 EXPECT_EQ(cmpMesh.status(eh).tagged(), edge_tagged [eh.idx()]) <<
"Wrong tagged status at edge " << eh.idx();
817 EXPECT_EQ(cmpMesh.status(eh).tagged2(), edge_tagged2 [eh.idx()]) <<
"Wrong tagged2 status at edge " << eh.idx();
820 for (
auto heh : cmpMesh.all_halfedges())
822 EXPECT_EQ(cmpMesh.status(heh).deleted(), halfedge_deleted [heh.idx()]) <<
"Wrong deleted status at halfedge " << heh.idx();
823 EXPECT_EQ(cmpMesh.status(heh).selected(), halfedge_selected[heh.idx()]) <<
"Wrong selected status at halfedge " << heh.idx();
824 EXPECT_EQ(cmpMesh.status(heh).feature(), halfedge_feature [heh.idx()]) <<
"Wrong feature status at halfedge " << heh.idx();
825 EXPECT_EQ(cmpMesh.status(heh).tagged(), halfedge_tagged [heh.idx()]) <<
"Wrong tagged status at halfedge " << heh.idx();
826 EXPECT_EQ(cmpMesh.status(heh).tagged2(), halfedge_tagged2 [heh.idx()]) <<
"Wrong tagged2 status at halfedge " << heh.idx();
829 for (
auto fh : cmpMesh.all_faces())
831 EXPECT_EQ(cmpMesh.status(fh).deleted(), face_deleted [fh.idx()]) <<
"Wrong deleted status at face " << fh.idx();
832 EXPECT_EQ(cmpMesh.status(fh).selected(), face_selected[fh.idx()]) <<
"Wrong selected status at face " << fh.idx();
833 EXPECT_EQ(cmpMesh.status(fh).feature(), face_feature [fh.idx()]) <<
"Wrong feature status at face " << fh.idx();
834 EXPECT_EQ(cmpMesh.status(fh).tagged(), face_tagged [fh.idx()]) <<
"Wrong tagged status at face " << fh.idx();
835 EXPECT_EQ(cmpMesh.status(fh).tagged2(), face_tagged2 [fh.idx()]) <<
"Wrong tagged2 status at face " << fh.idx();
840 remove(filename.c_str());
846 TEST_F(OpenMeshReadWriteOM, WriteTriangleFaceDoubleProperty) {
850 const std::string propName =
"FDProp";
851 const std::string filename = std::string(
"triangle-minimal-")+propName+
".om";
857 mesh.add_face(v1,v2,v3);
860 mesh.add_property(prop,propName);
861 mesh.property(prop).set_persistent(
true);
863 Mesh::FaceHandle f1 = Mesh::FaceHandle(0);
867 mesh.property(prop,f1) = va1ue1;
871 EXPECT_TRUE(ok) <<
"Unable to write "<<filename;
876 cmpMesh.add_property(prop,propName);
877 cmpMesh.property(prop).set_persistent(
true);
880 EXPECT_TRUE(ok) <<
"Unable to read "<<filename;
883 EXPECT_EQ(3u , cmpMesh.n_vertices()) <<
"The number of loaded vertices is not correct!";
884 EXPECT_EQ(3u , cmpMesh.n_edges()) <<
"The number of loaded edges is not correct!";
885 EXPECT_EQ(1u , cmpMesh.n_faces()) <<
"The number of loaded faces is not correct!";
887 EXPECT_EQ(
Mesh::Point(1.0,0.0,0.0) , cmpMesh.point(v1)) <<
"Wrong coordinates at vertex 0";
888 EXPECT_EQ(
Mesh::Point(0.0,1.0,0.0) , cmpMesh.point(v2)) <<
"Wrong coordinates at vertex 1";
889 EXPECT_EQ(
Mesh::Point(0.0,0.0,1.0) , cmpMesh.point(v3)) <<
"Wrong coordinates at vertex 2";
891 EXPECT_EQ(va1ue1 , cmpMesh.property(prop,f1)) <<
"Wrong property at edge 0";
894 remove(filename.c_str());
901 TEST_F(OpenMeshReadWriteOM, WriteTriangleFaceFloatProperty) {
903 const std::string propName =
"FFProp";
904 const std::string filename = std::string(
"triangle-minimal-")+propName+
".om";
911 mesh.add_face(v1,v2,v3);
914 mesh.add_property(prop,propName);
915 mesh.property(prop).set_persistent(
true);
917 Mesh::FaceHandle f1 = Mesh::FaceHandle(0);
921 mesh.property(prop,f1) = va1ue1;
925 EXPECT_TRUE(ok) <<
"Unable to write "<<filename;
930 cmpMesh.add_property(prop,propName);
931 cmpMesh.property(prop).set_persistent(
true);
934 EXPECT_TRUE(ok) <<
"Unable to read "<<filename;
937 EXPECT_EQ(3u , cmpMesh.n_vertices()) <<
"The number of loaded vertices is not correct!";
938 EXPECT_EQ(3u , cmpMesh.n_edges()) <<
"The number of loaded edges is not correct!";
939 EXPECT_EQ(1u , cmpMesh.n_faces()) <<
"The number of loaded faces is not correct!";
941 EXPECT_EQ(
Mesh::Point(1.0,0.0,0.0) , cmpMesh.point(v1)) <<
"Wrong coordinates at vertex 0";
942 EXPECT_EQ(
Mesh::Point(0.0,1.0,0.0) , cmpMesh.point(v2)) <<
"Wrong coordinates at vertex 1";
943 EXPECT_EQ(
Mesh::Point(0.0,0.0,1.0) , cmpMesh.point(v3)) <<
"Wrong coordinates at vertex 2";
945 EXPECT_EQ(va1ue1 , cmpMesh.property(prop,f1)) <<
"Wrong property at edge 0";
948 remove(filename.c_str());
955 TEST_F(OpenMeshReadWriteOM, ReadBigMeshWithCustomProperty) {
985 mesh.add_property(faceProp,
"DFProp");
986 mesh.property(faceProp).set_persistent(
true);
988 mesh.add_property(vertexProp,
"IVProp");
989 mesh.property(vertexProp).set_persistent(
true);
992 EXPECT_TRUE(ok) <<
"Unable to read cube1_customProps.om";
995 EXPECT_EQ(7526u , mesh.n_vertices()) <<
"The number of loaded vertices is not correct!";
996 EXPECT_EQ(22572u, mesh.n_edges()) <<
"The number of loaded edges is not correct!";
997 EXPECT_EQ(15048u, mesh.n_faces()) <<
"The number of loaded faces is not correct!";
1000 for (Mesh::FaceIter fIter = mesh.faces_begin(); fIter != mesh.faces_end() && !wrong; ++fIter)
1001 wrong = (0.3 != mesh.property(faceProp,*fIter));
1002 EXPECT_FALSE(wrong) <<
"min one face has wrong face property";
1005 for (Mesh::VertexIter vIter = mesh.vertices_begin(); vIter != mesh.vertices_end() && !wrong; ++vIter)
1006 wrong = (vIter->idx() != mesh.property(vertexProp,*vIter));
1007 EXPECT_FALSE(wrong) <<
"min one vertex has worng vertex property";
1014 TEST_F(OpenMeshReadWriteOM, WriteReadStatusPropertyVertexOnly) {
1021 mesh.add_face(vh0, vh1, vh2);
1023 mesh.request_vertex_status();
1025 mesh.status(vh0).set_selected(
true);
1026 mesh.status(vh1).set_feature(
true);
1027 mesh.status(vh2).set_tagged(
true);
1028 mesh.status(vh0).set_locked(
true);
1029 mesh.status(vh1).set_deleted(
true);
1030 mesh.status(vh2).set_hidden(
true);
1031 mesh.status(vh0).set_fixed_nonmanifold(
true);
1034 std::string filename_without_status =
"no_vertex_status_test.om";
1035 std::string filename_with_status =
"vertex_status_test.om";
1046 EXPECT_FALSE(loaded_mesh.has_vertex_status()) <<
"Mesh has vertex status even though they should not have been loaded";
1047 EXPECT_FALSE(loaded_mesh.has_halfedge_status()) <<
"Mesh has halfedge status even though file should not have a stored status";
1048 EXPECT_FALSE(loaded_mesh.has_edge_status()) <<
"Mesh has edge status even though file should not have a stored status";
1049 EXPECT_FALSE(loaded_mesh.has_face_status()) <<
"Mesh has face status even though file should not have a stored status";
1057 EXPECT_TRUE (loaded_mesh.has_vertex_status()) <<
"Mesh has no vertex status even though they should have been loaded";
1058 EXPECT_FALSE(loaded_mesh.has_halfedge_status()) <<
"Mesh has halfedge status even though file should not have a stored status";
1059 EXPECT_FALSE(loaded_mesh.has_edge_status()) <<
"Mesh has edge status even though file should not have a stored status";
1060 EXPECT_FALSE(loaded_mesh.has_face_status()) <<
"Mesh has face status even though file should not have a stored status";
1062 if (loaded_mesh.has_vertex_status())
1064 for (
auto vh : mesh.vertices())
1066 EXPECT_EQ(mesh.status(vh).bits(), loaded_mesh.status(vh).bits());
1074 loaded_mesh.request_vertex_status();
1077 EXPECT_TRUE (loaded_mesh.has_vertex_status()) <<
"Mesh vertex status was removed by reading";
1078 EXPECT_FALSE(loaded_mesh.has_halfedge_status()) <<
"Mesh has halfedge status even though file should not have a stored status";
1079 EXPECT_FALSE(loaded_mesh.has_edge_status()) <<
"Mesh has edge status even though file should not have a stored status";
1080 EXPECT_FALSE(loaded_mesh.has_face_status()) <<
"Mesh has face status even though file should not have a stored status";
1082 for (
auto vh : loaded_mesh.vertices())
1084 EXPECT_EQ(loaded_mesh.status(vh).bits(), 0u) <<
"Vertex status was modified even though it should not have been loaded";
1093 EXPECT_FALSE(loaded_mesh.has_vertex_status()) <<
"Mesh has vertex status even though file should not have a stored status";
1094 EXPECT_FALSE(loaded_mesh.has_halfedge_status()) <<
"Mesh has halfedge status even though file should not have a stored status";
1095 EXPECT_FALSE(loaded_mesh.has_edge_status()) <<
"Mesh has edge status even though they file should not have a stored status";
1096 EXPECT_FALSE(loaded_mesh.has_face_status()) <<
"Mesh has face status even though they file should not have a stored status";
1104 TEST_F(OpenMeshReadWriteOM, WriteReadStatusPropertyHalfedgeOnly) {
1111 mesh.add_face(vh0, vh1, vh2);
1113 mesh.request_halfedge_status();
1122 mesh.status(heh0).set_selected(
true);
1123 mesh.status(heh1).set_feature(
true);
1124 mesh.status(heh2).set_tagged(
true);
1125 mesh.status(heh3).set_locked(
true);
1126 mesh.status(heh4).set_deleted(
true);
1127 mesh.status(heh5).set_hidden(
true);
1128 mesh.status(heh0).set_fixed_nonmanifold(
true);
1130 std::string filename_without_status =
"no_halfedge_status_test.om";
1131 std::string filename_with_status =
"edge_halfstatus_test.om";
1142 EXPECT_FALSE(loaded_mesh.has_vertex_status()) <<
"Mesh has vertex status even though they should not have been loaded";
1143 EXPECT_FALSE(loaded_mesh.has_halfedge_status()) <<
"Mesh has halfedge status even though file should not have a stored status";
1144 EXPECT_FALSE(loaded_mesh.has_edge_status()) <<
"Mesh has edge status even though file should not have a stored status";
1145 EXPECT_FALSE(loaded_mesh.has_face_status()) <<
"Mesh has face status even though file should not have a stored status";
1153 EXPECT_FALSE(loaded_mesh.has_vertex_status()) <<
"Mesh has vertex status even though they should have been loaded";
1154 EXPECT_TRUE(loaded_mesh.has_halfedge_status()) <<
"Mesh has no halfedge status even though file should not have a stored status";
1155 EXPECT_FALSE(loaded_mesh.has_edge_status()) <<
"Mesh has edge status even though file should not have a stored status";
1156 EXPECT_FALSE(loaded_mesh.has_face_status()) <<
"Mesh has face status even though file should not have a stored status";
1158 if (loaded_mesh.has_halfedge_status())
1160 for (
auto heh : mesh.halfedges())
1162 EXPECT_EQ(mesh.status(heh).bits(), loaded_mesh.status(heh).bits());
1170 loaded_mesh.request_halfedge_status();
1173 EXPECT_FALSE(loaded_mesh.has_vertex_status()) <<
"Mesh has vertex status even though file should not have a stored status";
1174 EXPECT_TRUE (loaded_mesh.has_halfedge_status()) <<
"Mesh halfedge status was removed by reading";
1175 EXPECT_FALSE(loaded_mesh.has_edge_status()) <<
"Mesh has edge status even though file should not have a stored status";
1176 EXPECT_FALSE(loaded_mesh.has_face_status()) <<
"Mesh has face status even though file should not have a stored status";
1178 for (
auto heh : loaded_mesh.halfedges())
1180 EXPECT_EQ(loaded_mesh.status(heh).bits(), 0u) <<
"Edge status was modified even though it should not have been loaded";
1189 EXPECT_FALSE(loaded_mesh.has_vertex_status()) <<
"Mesh has vertex status even though file should not have a stored status";
1190 EXPECT_FALSE(loaded_mesh.has_halfedge_status()) <<
"Mesh has halfedge status even though file should not have a stored status";
1191 EXPECT_FALSE(loaded_mesh.has_edge_status()) <<
"Mesh has edge status even though they file should not have a stored status";
1192 EXPECT_FALSE(loaded_mesh.has_face_status()) <<
"Mesh has face status even though they file should not have a stored status";
1200 TEST_F(OpenMeshReadWriteOM, WriteReadStatusPropertyEdgeOnly) {
1207 mesh.add_face(vh0, vh1, vh2);
1209 mesh.request_edge_status();
1215 mesh.status(eh0).set_selected(
true);
1216 mesh.status(eh1).set_feature(
true);
1217 mesh.status(eh2).set_tagged(
true);
1218 mesh.status(eh0).set_locked(
true);
1219 mesh.status(eh1).set_deleted(
true);
1220 mesh.status(eh2).set_hidden(
true);
1221 mesh.status(eh0).set_fixed_nonmanifold(
true);
1223 std::string filename_without_status =
"no_edge_status_test.om";
1224 std::string filename_with_status =
"edge_status_test.om";
1235 EXPECT_FALSE(loaded_mesh.has_vertex_status()) <<
"Mesh has vertex status even though they should not have been loaded";
1236 EXPECT_FALSE(loaded_mesh.has_halfedge_status()) <<
"Mesh has halfedge status even though file should not have a stored status";
1237 EXPECT_FALSE(loaded_mesh.has_edge_status()) <<
"Mesh has edge status even though file should not have a stored status";
1238 EXPECT_FALSE(loaded_mesh.has_face_status()) <<
"Mesh has face status even though file should not have a stored status";
1246 EXPECT_FALSE(loaded_mesh.has_vertex_status()) <<
"Mesh has vertex status even though they should have been loaded";
1247 EXPECT_FALSE(loaded_mesh.has_halfedge_status()) <<
"Mesh has halfedge status even though file should not have a stored status";
1248 EXPECT_TRUE(loaded_mesh.has_edge_status()) <<
"Mesh has no edge status even though file should not have a stored status";
1249 EXPECT_FALSE(loaded_mesh.has_face_status()) <<
"Mesh has face status even though file should not have a stored status";
1251 if (loaded_mesh.has_edge_status())
1253 for (
auto eh : mesh.edges())
1255 EXPECT_EQ(mesh.status(eh).bits(), loaded_mesh.status(eh).bits());
1263 loaded_mesh.request_edge_status();
1266 EXPECT_FALSE(loaded_mesh.has_vertex_status()) <<
"Mesh has vertex status even though file should not have a stored status";
1267 EXPECT_FALSE(loaded_mesh.has_halfedge_status()) <<
"Mesh has halfedge status even though file should not have a stored status";
1268 EXPECT_TRUE (loaded_mesh.has_edge_status()) <<
"Mesh edge status was removed by reading";
1269 EXPECT_FALSE(loaded_mesh.has_face_status()) <<
"Mesh has face status even though file should not have a stored status";
1271 for (
auto eh : loaded_mesh.edges())
1273 EXPECT_EQ(loaded_mesh.status(eh).bits(), 0u) <<
"Edge status was modified even though it should not have been loaded";
1282 EXPECT_FALSE(loaded_mesh.has_vertex_status()) <<
"Mesh has vertex status even though file should not have a stored status";
1283 EXPECT_FALSE(loaded_mesh.has_halfedge_status()) <<
"Mesh has halfedge status even though file should not have a stored status";
1284 EXPECT_FALSE(loaded_mesh.has_edge_status()) <<
"Mesh has edge status even though they file should not have a stored status";
1285 EXPECT_FALSE(loaded_mesh.has_face_status()) <<
"Mesh has face status even though they file should not have a stored status";
1293 TEST_F(OpenMeshReadWriteOM, WriteReadStatusPropertyFaceOnly) {
1301 auto fh0 = mesh.add_face(vh0, vh1, vh2);
1302 auto fh1 = mesh.add_face(vh2, vh1, vh3);
1304 mesh.request_face_status();
1306 mesh.status(fh0).set_selected(
true);
1307 mesh.status(fh1).set_feature(
true);
1308 mesh.status(fh0).set_tagged(
true);
1309 mesh.status(fh1).set_locked(
true);
1310 mesh.status(fh0).set_deleted(
true);
1311 mesh.status(fh1).set_hidden(
true);
1312 mesh.status(fh0).set_fixed_nonmanifold(
true);
1314 std::string filename_without_status =
"no_face_status_test.om";
1315 std::string filename_with_status =
"face_status_test.om";
1326 EXPECT_FALSE(loaded_mesh.has_vertex_status()) <<
"Mesh has vertex status even though they should not have been loaded";
1327 EXPECT_FALSE(loaded_mesh.has_halfedge_status()) <<
"Mesh has halfedge status even though file should not have a stored status";
1328 EXPECT_FALSE(loaded_mesh.has_edge_status()) <<
"Mesh has edge status even though file should not have a stored status";
1329 EXPECT_FALSE(loaded_mesh.has_face_status()) <<
"Mesh has face status even though file should not have a stored status";
1337 EXPECT_FALSE(loaded_mesh.has_vertex_status()) <<
"Mesh has vertex status even though they should have been loaded";
1338 EXPECT_FALSE(loaded_mesh.has_halfedge_status()) <<
"Mesh has halfedge status even though file should not have a stored status";
1339 EXPECT_FALSE(loaded_mesh.has_edge_status()) <<
"Mesh has edge status even though file should not have a stored status";
1340 EXPECT_TRUE(loaded_mesh.has_face_status()) <<
"Mesh has no face status even though file should not have a stored status";
1342 if (loaded_mesh.has_face_status())
1344 for (
auto fh : mesh.faces())
1346 EXPECT_EQ(mesh.status(fh).bits(), loaded_mesh.status(fh).bits());
1354 loaded_mesh.request_face_status();
1357 EXPECT_FALSE(loaded_mesh.has_vertex_status()) <<
"Mesh has vertex status even though file should not have a stored status";
1358 EXPECT_FALSE(loaded_mesh.has_halfedge_status()) <<
"Mesh has halfedge status even though file should not have a stored status";
1359 EXPECT_FALSE(loaded_mesh.has_edge_status()) <<
"Mesh has edgestatus even though file should not have a stored status";
1360 EXPECT_TRUE (loaded_mesh.has_face_status()) <<
"Mesh face status was removed by reading";
1362 for (
auto fh : loaded_mesh.faces())
1364 EXPECT_EQ(loaded_mesh.status(fh).bits(), 0u) <<
"Edge status was modified even though it should not have been loaded";
1373 EXPECT_FALSE(loaded_mesh.has_vertex_status()) <<
"Mesh has vertex status even though file should not have a stored status";
1374 EXPECT_FALSE(loaded_mesh.has_halfedge_status()) <<
"Mesh has halfedge status even though file should not have a stored status";
1375 EXPECT_FALSE(loaded_mesh.has_edge_status()) <<
"Mesh has edge status even though they file should not have a stored status";
1376 EXPECT_FALSE(loaded_mesh.has_face_status()) <<
"Mesh has face status even though they file should not have a stored status";
1384 TEST_F(OpenMeshReadWriteOM, LoadTriangleMeshVersion_1_2) {
1388 std::string file_name =
"cube_tri_version_1_2.om";
1392 EXPECT_TRUE(ok) << file_name;
1394 EXPECT_EQ(8u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
1395 EXPECT_EQ(18u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
1396 EXPECT_EQ(12u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
1397 EXPECT_EQ(36u , mesh_.n_halfedges()) <<
"The number of loaded halfedges is not correct!";
1404 TEST_F(OpenMeshReadWriteOM, LoadPolyMeshVersion_1_2) {
1408 std::string file_name =
"cube_poly_version_1_2.om";
1412 EXPECT_TRUE(ok) << file_name;
1414 EXPECT_EQ(8u , mesh.n_vertices()) <<
"The number of loaded vertices is not correct!";
1415 EXPECT_EQ(12u , mesh.n_edges()) <<
"The number of loaded edges is not correct!";
1416 EXPECT_EQ(6u , mesh.n_faces()) <<
"The number of loaded faces is not correct!";
1417 EXPECT_EQ(24u , mesh.n_halfedges()) <<
"The number of loaded halfedges is not correct!";
1424 TEST_F(OpenMeshReadWriteOM, LoadTriangleMeshVersion_2_0) {
1428 std::string file_name =
"cube_tri_version_2_0.om";
1432 EXPECT_TRUE(ok) << file_name;
1434 EXPECT_EQ(8u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
1435 EXPECT_EQ(18u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
1436 EXPECT_EQ(12u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
1437 EXPECT_EQ(36u , mesh_.n_halfedges()) <<
"The number of loaded halfedges is not correct!";
1444 TEST_F(OpenMeshReadWriteOM, LoadPolyMeshVersion_2_0) {
1448 std::string file_name =
"cube_poly_version_2_0.om";
1452 EXPECT_TRUE(ok) << file_name;
1454 EXPECT_EQ(8u , mesh.n_vertices()) <<
"The number of loaded vertices is not correct!";
1455 EXPECT_EQ(12u , mesh.n_edges()) <<
"The number of loaded edges is not correct!";
1456 EXPECT_EQ(6u , mesh.n_faces()) <<
"The number of loaded faces is not correct!";
1457 EXPECT_EQ(24u , mesh.n_halfedges()) <<
"The number of loaded halfedges is not correct!";
1464 TEST_F(OpenMeshReadWriteOM, LoadTriMeshVersion_7_5) {
1468 std::string file_name =
"cube_tri_version_7_5.om";
1472 EXPECT_FALSE(ok) << file_name;
Handle for a edge entity.
Kernel::Color Color
Color type.
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) / store (w) float values for colors (currently only implemented for PLY and OFF files) ...
Handle for a halfedge entity.
Kernel::Point Point
Coordinate type.
bool read_mesh(Mesh &_mesh, const std::string &_filename)
Read a mesh from file _filename.
SmartVertexHandle add_vertex(const Point &_p)
Alias for new_vertex(const Point&).
SmartVertexHandle split(EdgeHandle _eh, const Point &_p)
Edge split (= 2-to-4 split)
Set options for reader/writer modules.
Has (r) / store (w) status properties.
void calc_face_centroid(FaceHandle _fh, Point &_pt) const
calculates the average of the vertices defining _fh
Has (r) / store (w) texture coordinates.
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.