From 7460c8ac82a008f06c4ed4fcdfe0aafcad2c4c2b Mon Sep 17 00:00:00 2001 From: Isaak Lim Date: Wed, 27 Feb 2013 12:02:40 +0000 Subject: [PATCH] added a unittest that writes and reads a binary PLY file with vertex colors git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@814 fdac6126-5c0c-442c-9429-916003d36597 --- src/Unittests/unittests_read_write_PLY.hh | 52 +++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/src/Unittests/unittests_read_write_PLY.hh b/src/Unittests/unittests_read_write_PLY.hh index 4398fb82..1a68233b 100644 --- a/src/Unittests/unittests_read_write_PLY.hh +++ b/src/Unittests/unittests_read_write_PLY.hh @@ -196,6 +196,58 @@ TEST_F(OpenMeshReadWritePLY, LoadPLYFromMeshLabWithVertexColors) { mesh_.release_vertex_colors(); } +/* + * Just read and write a binary ply file of a cube with vertex colors + */ +TEST_F(OpenMeshReadWritePLY, WriteAndReadBinaryPLYWithVertexColors) { + + mesh_.clear(); + + mesh_.request_vertex_colors(); + + OpenMesh::IO::Options options; + options += OpenMesh::IO::Options::VertexColor; + + bool ok = OpenMesh::IO::read_mesh(mesh_, "meshlab.ply",options); + + EXPECT_TRUE(ok) << "Unable to load meshlab.ply"; + + options += OpenMesh::IO::Options::Binary; + + ok = OpenMesh::IO::write_mesh(mesh_, "meshlab_binary.ply",options); + EXPECT_TRUE(ok) << "Unable to write meshlab_binary.ply"; + + mesh_.clear(); + ok = OpenMesh::IO::read_mesh(mesh_, "meshlab_binary.ply",options); + EXPECT_TRUE(ok) << "Unable to load meshlab_binary.ply"; + + EXPECT_EQ(8u , mesh_.n_vertices()) << "The number of loaded vertices is not correct!"; + EXPECT_EQ(18u , mesh_.n_edges()) << "The number of loaded edges is not correct!"; + EXPECT_EQ(12u , mesh_.n_faces()) << "The number of loaded faces is not correct!"; + + EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(0))[0] ) << "Wrong vertex color at vertex 0 component 0"; + EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(0))[1] ) << "Wrong vertex color at vertex 0 component 1"; + EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(0))[2] ) << "Wrong vertex color at vertex 0 component 2"; + + EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(3))[0] ) << "Wrong vertex color at vertex 3 component 0"; + EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(3))[1] ) << "Wrong vertex color at vertex 3 component 1"; + EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(3))[2] ) << "Wrong vertex color at vertex 3 component 2"; + + EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(4))[0] ) << "Wrong vertex color at vertex 4 component 0"; + EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(4))[1] ) << "Wrong vertex color at vertex 4 component 1"; + EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(4))[2] ) << "Wrong vertex color at vertex 4 component 2"; + + EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(7))[0] ) << "Wrong vertex color at vertex 7 component 0"; + EXPECT_EQ(0, mesh_.color(mesh_.vertex_handle(7))[1] ) << "Wrong vertex color at vertex 7 component 1"; + EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(7))[2] ) << "Wrong vertex color at vertex 7 component 2"; + + EXPECT_FALSE(options.vertex_has_normal()) << "Wrong user options are returned!"; + EXPECT_FALSE(options.vertex_has_texcoord()) << "Wrong user options are returned!"; + EXPECT_TRUE(options.vertex_has_color()) << "Wrong user options are returned!"; + + mesh_.release_vertex_colors(); +} + /* * Just load a ply file of a cube with vertex texCoords */