2 #include <gtest/gtest.h> 3 #include <Unittests/unittests_common.hh> 14 virtual void SetUp() {
20 virtual void TearDown() {
38 TEST_F(OpenMeshReadWriteOBJ, LoadSimpleOBJ) {
44 EXPECT_TRUE(ok) <<
"Unable to load cube-minimal.obj";
46 EXPECT_EQ(8u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
47 EXPECT_EQ(18u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
48 EXPECT_EQ(12u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
54 TEST_F(OpenMeshReadWriteOBJ, LoadDegeneratedOBJ) {
60 EXPECT_TRUE(ok) <<
"Unable to load cube-minimal-degenerated.obj";
62 EXPECT_EQ(8u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
63 EXPECT_EQ(18u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
64 EXPECT_EQ(12u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
70 TEST_F(OpenMeshReadWriteOBJ, LoadSimpleOBJCheckHalfEdgeAndVertexNormals) {
74 mesh_.request_halfedge_normals();
75 mesh_.request_vertex_normals();
80 std::string file_name =
"cube-minimal.obj";
84 EXPECT_TRUE(ok) << file_name;
86 EXPECT_EQ(8u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
87 EXPECT_EQ(18u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
88 EXPECT_EQ(12u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
89 EXPECT_EQ(36u , mesh_.n_halfedges()) <<
"The number of loaded halfedges is not correct!";
93 EXPECT_EQ(0, mesh_.normal(mesh_.vertex_handle(0))[0] ) <<
"Wrong vertex normal at vertex 0 component 0";
94 EXPECT_EQ(-1, mesh_.normal(mesh_.vertex_handle(0))[1] ) <<
"Wrong vertex normal at vertex 0 component 1";
95 EXPECT_EQ(0, mesh_.normal(mesh_.vertex_handle(0))[2] ) <<
"Wrong vertex normal at vertex 0 component 2";
97 EXPECT_EQ(0, mesh_.normal(mesh_.vertex_handle(3))[0] ) <<
"Wrong vertex normal at vertex 3 component 0";
98 EXPECT_EQ(0, mesh_.normal(mesh_.vertex_handle(3))[1] ) <<
"Wrong vertex normal at vertex 3 component 1";
99 EXPECT_EQ(1, mesh_.normal(mesh_.vertex_handle(3))[2] ) <<
"Wrong vertex normal at vertex 3 component 2";
101 EXPECT_EQ(0, mesh_.normal(mesh_.vertex_handle(4))[0] ) <<
"Wrong vertex normal at vertex 4 component 0";
102 EXPECT_EQ(-1, mesh_.normal(mesh_.vertex_handle(4))[1] ) <<
"Wrong vertex normal at vertex 4 component 1";
103 EXPECT_EQ(0, mesh_.normal(mesh_.vertex_handle(4))[2] ) <<
"Wrong vertex normal at vertex 4 component 2";
105 EXPECT_EQ(0, mesh_.normal(mesh_.vertex_handle(7))[0] ) <<
"Wrong vertex normal at vertex 7 component 0";
106 EXPECT_EQ(0, mesh_.normal(mesh_.vertex_handle(7))[1] ) <<
"Wrong vertex normal at vertex 7 component 1";
107 EXPECT_EQ(1, mesh_.normal(mesh_.vertex_handle(7))[2] ) <<
"Wrong vertex normal at vertex 7 component 2";
111 EXPECT_EQ(0, mesh_.normal(mesh_.halfedge_handle(0))[0] ) <<
"Wrong halfedge normal at halfedge 0 component 0";
112 EXPECT_EQ(0, mesh_.normal(mesh_.halfedge_handle(0))[1] ) <<
"Wrong halfedge normal at halfedge 0 component 1";
113 EXPECT_EQ(-1, mesh_.normal(mesh_.halfedge_handle(0))[2] ) <<
"Wrong halfedge normal at halfedge 0 component 2";
115 EXPECT_EQ(-1, mesh_.normal(mesh_.halfedge_handle(10))[0] ) <<
"Wrong halfedge normal at halfedge 10 component 0";
116 EXPECT_EQ(0, mesh_.normal(mesh_.halfedge_handle(10))[1] ) <<
"Wrong halfedge normal at halfedge 10 component 1";
117 EXPECT_EQ(0, mesh_.normal(mesh_.halfedge_handle(10))[2] ) <<
"Wrong halfedge normal at halfedge 10 component 2";
119 EXPECT_EQ(0, mesh_.normal(mesh_.halfedge_handle(19))[0] ) <<
"Wrong halfedge normal at halfedge 19 component 0";
120 EXPECT_EQ(1, mesh_.normal(mesh_.halfedge_handle(19))[1] ) <<
"Wrong halfedge normal at halfedge 19 component 1";
121 EXPECT_EQ(0, mesh_.normal(mesh_.halfedge_handle(19))[2] ) <<
"Wrong halfedge normal at halfedge 19 component 2";
123 EXPECT_EQ(1, mesh_.normal(mesh_.halfedge_handle(24))[0] ) <<
"Wrong halfedge normal at halfedge 24 component 0";
124 EXPECT_EQ(0, mesh_.normal(mesh_.halfedge_handle(24))[1] ) <<
"Wrong halfedge normal at halfedge 24 component 1";
125 EXPECT_EQ(0, mesh_.normal(mesh_.halfedge_handle(24))[2] ) <<
"Wrong halfedge normal at halfedge 24 component 2";
127 EXPECT_EQ(0, mesh_.normal(mesh_.halfedge_handle(30))[0] ) <<
"Wrong halfedge normal at halfedge 30 component 0";
128 EXPECT_EQ(-1, mesh_.normal(mesh_.halfedge_handle(30))[1] ) <<
"Wrong halfedge normal at halfedge 30 component 1";
129 EXPECT_EQ(0, mesh_.normal(mesh_.halfedge_handle(30))[2] ) <<
"Wrong halfedge normal at halfedge 30 component 2";
131 EXPECT_EQ(0, mesh_.normal(mesh_.halfedge_handle(35))[0] ) <<
"Wrong halfedge normal at halfedge 35 component 0";
132 EXPECT_EQ(0, mesh_.normal(mesh_.halfedge_handle(35))[1] ) <<
"Wrong halfedge normal at halfedge 35 component 1";
133 EXPECT_EQ(1, mesh_.normal(mesh_.halfedge_handle(35))[2] ) <<
"Wrong halfedge normal at halfedge 35 component 2";
135 mesh_.release_vertex_normals();
136 mesh_.release_halfedge_normals();
143 TEST_F(OpenMeshReadWriteOBJ, LoadSimpleOBJForceVertexColorsAlthoughNotAvailable) {
147 mesh_.request_vertex_colors();
149 std::string file_name =
"cube-minimal.obj";
156 EXPECT_TRUE(ok) << file_name;
158 EXPECT_EQ(8u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
159 EXPECT_EQ(18u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
160 EXPECT_EQ(12u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
161 EXPECT_EQ(36u , mesh_.n_halfedges()) <<
"The number of loaded halfedges is not correct!";
169 TEST_F(OpenMeshReadWriteOBJ, LoadSimpleOBJCheckTexCoords) {
173 mesh_.request_halfedge_texcoords2D();
178 std::string file_name =
"cube-minimal-texCoords.obj";
182 EXPECT_TRUE(ok) << file_name;
184 EXPECT_EQ(1, mesh_.texcoord2D(mesh_.halfedge_handle(0))[0] ) <<
"Wrong texCoord at halfedge 0 component 0";
185 EXPECT_EQ(1, mesh_.texcoord2D(mesh_.halfedge_handle(0))[1] ) <<
"Wrong texCoord at halfedge 0 component 1";
187 EXPECT_EQ(3, mesh_.texcoord2D(mesh_.halfedge_handle(10))[0] ) <<
"Wrong texCoord at halfedge 1 component 0";
188 EXPECT_EQ(3, mesh_.texcoord2D(mesh_.halfedge_handle(10))[1] ) <<
"Wrong texCoord at halfedge 1 component 1";
190 EXPECT_EQ(6, mesh_.texcoord2D(mesh_.halfedge_handle(19))[0] ) <<
"Wrong texCoord at halfedge 4 component 0";
191 EXPECT_EQ(6, mesh_.texcoord2D(mesh_.halfedge_handle(19))[1] ) <<
"Wrong texCoord at halfedge 4 component 1";
193 EXPECT_EQ(7, mesh_.texcoord2D(mesh_.halfedge_handle(24))[0] ) <<
"Wrong texCoord at halfedge 7 component 0";
194 EXPECT_EQ(7, mesh_.texcoord2D(mesh_.halfedge_handle(24))[1] ) <<
"Wrong texCoord at halfedge 7 component 1";
196 EXPECT_EQ(9, mesh_.texcoord2D(mesh_.halfedge_handle(30))[0] ) <<
"Wrong texCoord at halfedge 9 component 0";
197 EXPECT_EQ(9, mesh_.texcoord2D(mesh_.halfedge_handle(30))[1] ) <<
"Wrong texCoord at halfedge 9 component 1";
199 EXPECT_EQ(12, mesh_.texcoord2D(mesh_.halfedge_handle(35))[0] ) <<
"Wrong texCoord at halfedge 11 component 0";
200 EXPECT_EQ(12, mesh_.texcoord2D(mesh_.halfedge_handle(35))[1] ) <<
"Wrong texCoord at halfedge 11 component 1";
202 mesh_.release_halfedge_texcoords2D();
208 TEST_F(OpenMeshReadWriteOBJ, LoadStoreSimpleOBJCheckTexCoords) {
212 mesh_.request_halfedge_texcoords2D();
217 std::string file_name =
"cube-minimal-texCoords.obj";
221 EXPECT_TRUE(ok) << file_name;
228 EXPECT_TRUE(writeOk) <<
"writeTest.obj";
229 mesh_.release_halfedge_texcoords2D();
234 loadedMesh_.request_halfedge_texcoords2D();
239 EXPECT_TRUE(readOk) << file_name;
240 EXPECT_EQ(1, loadedMesh_.texcoord2D(mesh_.halfedge_handle(0))[0] ) <<
"Wrong texCoord at halfedge 0 component 0";
241 EXPECT_EQ(1, loadedMesh_.texcoord2D(mesh_.halfedge_handle(0))[1] ) <<
"Wrong texCoord at halfedge 0 component 1";
243 EXPECT_EQ(3, loadedMesh_.texcoord2D(mesh_.halfedge_handle(10))[0] ) <<
"Wrong texCoord at halfedge 1 component 0";
244 EXPECT_EQ(3, loadedMesh_.texcoord2D(mesh_.halfedge_handle(10))[1] ) <<
"Wrong texCoord at halfedge 1 component 1";
246 EXPECT_EQ(6, loadedMesh_.texcoord2D(mesh_.halfedge_handle(19))[0] ) <<
"Wrong texCoord at halfedge 4 component 0";
247 EXPECT_EQ(6, loadedMesh_.texcoord2D(mesh_.halfedge_handle(19))[1] ) <<
"Wrong texCoord at halfedge 4 component 1";
249 EXPECT_EQ(7, loadedMesh_.texcoord2D(mesh_.halfedge_handle(24))[0] ) <<
"Wrong texCoord at halfedge 7 component 0";
250 EXPECT_EQ(7, loadedMesh_.texcoord2D(mesh_.halfedge_handle(24))[1] ) <<
"Wrong texCoord at halfedge 7 component 1";
252 EXPECT_EQ(9, loadedMesh_.texcoord2D(mesh_.halfedge_handle(30))[0] ) <<
"Wrong texCoord at halfedge 9 component 0";
253 EXPECT_EQ(9, loadedMesh_.texcoord2D(mesh_.halfedge_handle(30))[1] ) <<
"Wrong texCoord at halfedge 9 component 1";
255 EXPECT_EQ(12, loadedMesh_.texcoord2D(mesh_.halfedge_handle(35))[0] ) <<
"Wrong texCoord at halfedge 11 component 0";
256 EXPECT_EQ(12, loadedMesh_.texcoord2D(mesh_.halfedge_handle(35))[1] ) <<
"Wrong texCoord at halfedge 11 component 1";
258 loadedMesh_.release_halfedge_texcoords2D();
264 TEST_F(OpenMeshReadWriteOBJ, LoadSimpleOBJCheckTexCoords3d) {
268 mesh_.request_halfedge_texcoords3D();
273 std::string file_name =
"cube-minimal-texCoords3d.obj";
277 EXPECT_TRUE(ok) << file_name;
279 EXPECT_EQ(1, mesh_.texcoord3D(mesh_.halfedge_handle(0))[0] ) <<
"Wrong texCoord at halfedge 0 component 0";
280 EXPECT_EQ(1, mesh_.texcoord3D(mesh_.halfedge_handle(0))[1] ) <<
"Wrong texCoord at halfedge 0 component 1";
281 EXPECT_EQ(1, mesh_.texcoord3D(mesh_.halfedge_handle(0))[2] ) <<
"Wrong texCoord at halfedge 0 component 2";
283 EXPECT_EQ(3, mesh_.texcoord3D(mesh_.halfedge_handle(10))[0] ) <<
"Wrong texCoord at halfedge 1 component 0";
284 EXPECT_EQ(3, mesh_.texcoord3D(mesh_.halfedge_handle(10))[1] ) <<
"Wrong texCoord at halfedge 1 component 1";
285 EXPECT_EQ(3, mesh_.texcoord3D(mesh_.halfedge_handle(10))[2] ) <<
"Wrong texCoord at halfedge 1 component 2";
287 EXPECT_EQ(6, mesh_.texcoord3D(mesh_.halfedge_handle(19))[0] ) <<
"Wrong texCoord at halfedge 4 component 0";
288 EXPECT_EQ(6, mesh_.texcoord3D(mesh_.halfedge_handle(19))[1] ) <<
"Wrong texCoord at halfedge 4 component 1";
289 EXPECT_EQ(6, mesh_.texcoord3D(mesh_.halfedge_handle(19))[2] ) <<
"Wrong texCoord at halfedge 4 component 2";
291 EXPECT_EQ(7, mesh_.texcoord3D(mesh_.halfedge_handle(24))[0] ) <<
"Wrong texCoord at halfedge 7 component 0";
292 EXPECT_EQ(7, mesh_.texcoord3D(mesh_.halfedge_handle(24))[1] ) <<
"Wrong texCoord at halfedge 7 component 1";
293 EXPECT_EQ(7, mesh_.texcoord3D(mesh_.halfedge_handle(24))[2] ) <<
"Wrong texCoord at halfedge 7 component 2";
295 EXPECT_EQ(9, mesh_.texcoord3D(mesh_.halfedge_handle(30))[0] ) <<
"Wrong texCoord at halfedge 9 component 0";
296 EXPECT_EQ(9, mesh_.texcoord3D(mesh_.halfedge_handle(30))[1] ) <<
"Wrong texCoord at halfedge 9 component 1";
297 EXPECT_EQ(9, mesh_.texcoord3D(mesh_.halfedge_handle(30))[2] ) <<
"Wrong texCoord at halfedge 9 component 2";
299 EXPECT_EQ(12, mesh_.texcoord3D(mesh_.halfedge_handle(35))[0] ) <<
"Wrong texCoord at halfedge 11 component 0";
300 EXPECT_EQ(12, mesh_.texcoord3D(mesh_.halfedge_handle(35))[1] ) <<
"Wrong texCoord at halfedge 11 component 1";
301 EXPECT_EQ(12, mesh_.texcoord3D(mesh_.halfedge_handle(35))[2] ) <<
"Wrong texCoord at halfedge 11 component 2";
303 mesh_.request_halfedge_texcoords3D();
309 TEST_F(OpenMeshReadWriteOBJ, LoadObjWithMaterial) {
313 mesh_.request_face_colors();
318 std::string file_name =
"square_material.obj";
322 EXPECT_TRUE(ok) << file_name;
326 EXPECT_TRUE(fh.
is_valid()) <<
"fh should be valid";
328 #ifdef TEST_DOUBLE_TRAITS 329 EXPECT_FLOAT_EQ(128/255.0, mesh_.color(fh)[0] ) <<
"Wrong vertex color at vertex 0 component 0";
330 EXPECT_FLOAT_EQ(128/255.0, mesh_.color(fh)[1] ) <<
"Wrong vertex color at vertex 0 component 1";
331 EXPECT_FLOAT_EQ(128/255.0, mesh_.color(fh)[2] ) <<
"Wrong vertex color at vertex 0 component 2";
332 EXPECT_FLOAT_EQ(1.0, mesh_.color(fh)[3] ) <<
"Wrong vertex color at vertex 0 component 3";
334 EXPECT_EQ(128, mesh_.color(fh)[0] ) <<
"Wrong vertex color at vertex 0 component 0";
335 EXPECT_EQ(128, mesh_.color(fh)[1] ) <<
"Wrong vertex color at vertex 0 component 1";
336 EXPECT_EQ(128, mesh_.color(fh)[2] ) <<
"Wrong vertex color at vertex 0 component 2";
339 mesh_.release_face_colors();
342 TEST_F(OpenMeshReadWriteOBJ, LoadObjWithTexture) {
346 mesh_.request_face_colors();
347 mesh_.request_face_texture_index();
352 std::string file_name =
"square_material_texture.obj";
356 EXPECT_TRUE(ok) << file_name;
360 mesh_.get_property_handle(property,
"TextureMapping");
361 EXPECT_EQ(mesh_.property(property).size(), 1u) <<
"More than one texture defined";
362 std::map< int, std::string >::iterator tex = mesh_.property(property).find(1);
363 EXPECT_TRUE(tex != mesh_.property(property).end()) <<
"Could not find texture with id 1";
364 EXPECT_TRUE((mesh_.property(property)[1] == std::string(
"square_material_texture.jpg"))) <<
"Wrong texture name";
368 EXPECT_TRUE(fh.
is_valid()) <<
"fh should be valid";
369 EXPECT_EQ(mesh_.property(mesh_.face_texture_index_pph(),fh),1) <<
"Face texture index is not set correctly";
371 mesh_.release_face_colors();
372 mesh_.release_face_texture_index();
378 TEST_F(OpenMeshReadWriteOBJ, LoadSimpleOBJWithVertexColorsAfterVertices) {
382 mesh_.request_vertex_colors();
389 EXPECT_TRUE(ok) <<
"Unable to load cube-minimal-vertex-colors-after-vertex-definition.obj";
391 EXPECT_EQ(8u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
392 EXPECT_EQ(18u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
393 EXPECT_EQ(12u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
396 #ifdef TEST_DOUBLE_TRAITS 397 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(0))[0] ) <<
"Wrong vertex color at vertex 0 component 0";
398 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(0))[1] ) <<
"Wrong vertex color at vertex 0 component 1";
399 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(0))[2] ) <<
"Wrong vertex color at vertex 0 component 2";
401 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(3))[0] ) <<
"Wrong vertex color at vertex 3 component 0";
402 EXPECT_FLOAT_EQ(1.0, mesh_.color(mesh_.vertex_handle(3))[1] ) <<
"Wrong vertex color at vertex 3 component 1";
403 EXPECT_FLOAT_EQ(1.0, mesh_.color(mesh_.vertex_handle(3))[2] ) <<
"Wrong vertex color at vertex 3 component 2";
405 EXPECT_FLOAT_EQ(1.0, mesh_.color(mesh_.vertex_handle(4))[0] ) <<
"Wrong vertex color at vertex 4 component 0";
406 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(4))[1] ) <<
"Wrong vertex color at vertex 4 component 1";
407 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(4))[2] ) <<
"Wrong vertex color at vertex 4 component 2";
409 EXPECT_FLOAT_EQ(1.0, mesh_.color(mesh_.vertex_handle(7))[0] ) <<
"Wrong vertex color at vertex 7 component 0";
410 EXPECT_FLOAT_EQ(1.0, mesh_.color(mesh_.vertex_handle(7))[1] ) <<
"Wrong vertex color at vertex 7 component 1";
411 EXPECT_FLOAT_EQ(1.0, mesh_.color(mesh_.vertex_handle(7))[2] ) <<
"Wrong vertex color at vertex 7 component 2";
413 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(0))[0] ) <<
"Wrong vertex color at vertex 0 component 0";
414 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(0))[1] ) <<
"Wrong vertex color at vertex 0 component 1";
415 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(0))[2] ) <<
"Wrong vertex color at vertex 0 component 2";
417 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(3))[0] ) <<
"Wrong vertex color at vertex 3 component 0";
418 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(3))[1] ) <<
"Wrong vertex color at vertex 3 component 1";
419 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(3))[2] ) <<
"Wrong vertex color at vertex 3 component 2";
421 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(4))[0] ) <<
"Wrong vertex color at vertex 4 component 0";
422 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(4))[1] ) <<
"Wrong vertex color at vertex 4 component 1";
423 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(4))[2] ) <<
"Wrong vertex color at vertex 4 component 2";
425 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(7))[0] ) <<
"Wrong vertex color at vertex 7 component 0";
426 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(7))[1] ) <<
"Wrong vertex color at vertex 7 component 1";
427 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(7))[2] ) <<
"Wrong vertex color at vertex 7 component 2";
430 mesh_.release_vertex_colors();
436 TEST_F(OpenMeshReadWriteOBJ, LoadSimpleOBJWithVertexColorsAsVCLines) {
440 mesh_.request_vertex_colors();
447 EXPECT_TRUE(ok) <<
"Unable to load cube-minimal-vertex-colors-as-vc-lines.obj";
449 EXPECT_EQ(8u , mesh_.n_vertices()) <<
"The number of loaded vertices is not correct!";
450 EXPECT_EQ(18u , mesh_.n_edges()) <<
"The number of loaded edges is not correct!";
451 EXPECT_EQ(12u , mesh_.n_faces()) <<
"The number of loaded faces is not correct!";
453 #ifdef TEST_DOUBLE_TRAITS 454 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(0))[0] ) <<
"Wrong vertex color at vertex 0 component 0";
455 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(0))[1] ) <<
"Wrong vertex color at vertex 0 component 1";
456 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(0))[2] ) <<
"Wrong vertex color at vertex 0 component 2";
458 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(3))[0] ) <<
"Wrong vertex color at vertex 3 component 0";
459 EXPECT_FLOAT_EQ(1.0, mesh_.color(mesh_.vertex_handle(3))[1] ) <<
"Wrong vertex color at vertex 3 component 1";
460 EXPECT_FLOAT_EQ(1.0, mesh_.color(mesh_.vertex_handle(3))[2] ) <<
"Wrong vertex color at vertex 3 component 2";
462 EXPECT_FLOAT_EQ(1.0, mesh_.color(mesh_.vertex_handle(4))[0] ) <<
"Wrong vertex color at vertex 4 component 0";
463 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(4))[1] ) <<
"Wrong vertex color at vertex 4 component 1";
464 EXPECT_FLOAT_EQ(0.0, mesh_.color(mesh_.vertex_handle(4))[2] ) <<
"Wrong vertex color at vertex 4 component 2";
466 EXPECT_FLOAT_EQ(1.0, mesh_.color(mesh_.vertex_handle(7))[0] ) <<
"Wrong vertex color at vertex 7 component 0";
467 EXPECT_FLOAT_EQ(1.0, mesh_.color(mesh_.vertex_handle(7))[1] ) <<
"Wrong vertex color at vertex 7 component 1";
468 EXPECT_FLOAT_EQ(1.0, mesh_.color(mesh_.vertex_handle(7))[2] ) <<
"Wrong vertex color at vertex 7 component 2";
470 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(0))[0] ) <<
"Wrong vertex color at vertex 0 component 0";
471 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(0))[1] ) <<
"Wrong vertex color at vertex 0 component 1";
472 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(0))[2] ) <<
"Wrong vertex color at vertex 0 component 2";
474 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(3))[0] ) <<
"Wrong vertex color at vertex 3 component 0";
475 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(3))[1] ) <<
"Wrong vertex color at vertex 3 component 1";
476 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(3))[2] ) <<
"Wrong vertex color at vertex 3 component 2";
478 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(4))[0] ) <<
"Wrong vertex color at vertex 4 component 0";
479 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(4))[1] ) <<
"Wrong vertex color at vertex 4 component 1";
480 EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(4))[2] ) <<
"Wrong vertex color at vertex 4 component 2";
482 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(7))[0] ) <<
"Wrong vertex color at vertex 7 component 0";
483 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(7))[1] ) <<
"Wrong vertex color at vertex 7 component 1";
484 EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(7))[2] ) <<
"Wrong vertex color at vertex 7 component 2";
487 mesh_.release_vertex_colors();
494 TEST_F(OpenMeshReadWriteOBJ, ReadWriteReadSimpleOBJ) {
497 mesh_.request_vertex_normals();
503 EXPECT_TRUE(ok) <<
"Unable to load cube-minimal.obj";
507 const char* filename =
"cube-minimal_openmeshOutputTestfile.obj";
510 mesh_.release_vertex_normals();
511 ASSERT_TRUE(ok) <<
"Unable to write obj mesh";
514 mesh2.request_vertex_normals();
521 ASSERT_TRUE(ok) <<
"Unable to read written mesh";
523 EXPECT_EQ(8u , mesh2.n_vertices()) <<
"The number of loaded vertices is not correct!";
524 EXPECT_EQ(18u , mesh2.n_edges()) <<
"The number of loaded edges is not correct!";
525 EXPECT_EQ(12u , mesh2.n_faces()) <<
"The number of loaded faces is not correct!";
529 EXPECT_EQ(0, mesh2.normal(mesh2.vertex_handle(0))[0] ) <<
"Wrong vertex normal at vertex 0 component 0";
530 EXPECT_EQ(-1, mesh2.normal(mesh2.vertex_handle(0))[1] ) <<
"Wrong vertex normal at vertex 0 component 1";
531 EXPECT_EQ(0, mesh2.normal(mesh2.vertex_handle(0))[2] ) <<
"Wrong vertex normal at vertex 0 component 2";
533 EXPECT_EQ(0, mesh2.normal(mesh2.vertex_handle(3))[0] ) <<
"Wrong vertex normal at vertex 3 component 0";
534 EXPECT_EQ(0, mesh2.normal(mesh2.vertex_handle(3))[1] ) <<
"Wrong vertex normal at vertex 3 component 1";
535 EXPECT_EQ(1, mesh2.normal(mesh2.vertex_handle(3))[2] ) <<
"Wrong vertex normal at vertex 3 component 2";
537 EXPECT_EQ(0, mesh2.normal(mesh2.vertex_handle(4))[0] ) <<
"Wrong vertex normal at vertex 4 component 0";
538 EXPECT_EQ(-1, mesh2.normal(mesh2.vertex_handle(4))[1] ) <<
"Wrong vertex normal at vertex 4 component 1";
539 EXPECT_EQ(0, mesh2.normal(mesh2.vertex_handle(4))[2] ) <<
"Wrong vertex normal at vertex 4 component 2";
541 EXPECT_EQ(0, mesh2.normal(mesh2.vertex_handle(7))[0] ) <<
"Wrong vertex normal at vertex 7 component 0";
542 EXPECT_EQ(0, mesh2.normal(mesh2.vertex_handle(7))[1] ) <<
"Wrong vertex normal at vertex 7 component 1";
543 EXPECT_EQ(1, mesh2.normal(mesh2.vertex_handle(7))[2] ) <<
"Wrong vertex normal at vertex 7 component 2";
548 TEST_F(OpenMeshReadWriteOBJ, FaceTexCoordTest) {
551 mesh_.request_vertex_normals();
552 mesh_.request_halfedge_texcoords2D();
562 std::vector<Mesh::VertexHandle> face_vhandles;
564 face_vhandles.push_back(vhandle[2]);
565 face_vhandles.push_back(vhandle[1]);
566 face_vhandles.push_back(vhandle[0]);
568 Mesh::FaceHandle fh = mesh_.add_face(face_vhandles);
582 for (
auto he : mesh_.halfedges() ) {
591 for (
auto he : mesh_.fh_range(fh) )
606 EXPECT_TRUE(ok) <<
"Unable to write OpenMeshReadWriteOBJ_FaceTexCoordTest.obj";
615 mesh_.request_vertex_normals();
616 mesh_.request_face_normals();
617 mesh_.request_halfedge_texcoords2D();
621 EXPECT_TRUE(ok) <<
"Unable to read back OpenMeshReadWriteOBJ_FaceTexCoordTest.obj";
Handle for a face entity.
Kernel::Normal Normal
Normal type.
Has (r) / store (w) vertex colors.
void clear(void)
Clear all bits.
Has (r) / store (w) face 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.
Kernel::Point Point
Coordinate type.
bool is_valid() const
The handle is valid iff the index is not negative.
Has (r) / store (w) face texture coordinates.
bool read_mesh(Mesh &_mesh, const std::string &_filename)
Read a mesh from file _filename.
Kernel::TexCoord2D TexCoord2D
TexCoord2D type.
SmartVertexHandle add_vertex(const Point &_p)
Alias for new_vertex(const Point&).
Set options for reader/writer modules.
Has (r) / store (w) vertex normals.
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.