Commit 8c411878 authored by Isaak Lim's avatar Isaak Lim
Browse files

added some more unittests for the PLY loader with different user options

git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@742 fdac6126-5c0c-442c-9429-916003d36597
parent b409f830
ply
format ascii 1.0
comment =================================
comment Exported via OpenFlipper 1.4
comment www.openflipper.org
comment =================================
element vertex 8
property float x
property float y
property float z
property int32 u
property int32 v
element face 12
property list uchar int32 vertex_index
end_header
0 0 0 10 10
0 0 1 12 12
0 1 0 6 6
0 1 1 12 12
1 0 0 9 9
1 0 1 11 11
1 1 0 7 7
1 1 1 12 12
3 0 6 4
3 0 2 6
3 0 3 2
3 0 1 3
3 2 7 6
3 2 3 7
3 4 6 7
3 4 7 5
3 0 4 5
3 0 5 1
3 1 5 7
3 1 7 3
ply
format ascii 1.0
comment =================================
comment Exported via OpenFlipper 1.4
comment www.openflipper.org
comment =================================
element vertex 8
property float x
property float y
property float z
property uchar red
property uchar green
property uchar blue
element face 12
property list uchar int32 vertex_index
end_header
0 0 0 255 0 0
0 0 1 255 0 0
0 1 0 255 0 0
0 1 1 255 0 0
1 0 0 0 0 255
1 0 1 0 0 255
1 1 0 0 0 255
1 1 1 0 0 255
3 0 6 4
3 0 2 6
3 0 3 2
3 0 1 3
3 2 7 6
3 2 3 7
3 4 6 7
3 4 7 5
3 0 4 5
3 0 5 1
3 1 5 7
3 1 7 3
......@@ -374,6 +374,116 @@ TEST_F(OpenMeshLoader, LoadSimplePLY) {
}
/*
* Just load a ply file and set vertex color option before loading
*/
TEST_F(OpenMeshLoader, LoadSimplePLYForceVertexColorsAlthoughNotAvailable) {
mesh_.clear();
mesh_.request_vertex_colors();
std::string file_name = "cube-minimal.ply";
OpenMesh::IO::Options options;
options += OpenMesh::IO::Options::VertexColor;
bool ok = OpenMesh::IO::read_mesh(mesh_, file_name,options);
EXPECT_TRUE(ok) << file_name;
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(36u , mesh_.n_halfedges()) << "The number of loaded halfedges is not correct!";
EXPECT_FALSE(options.vertex_has_normal()) << "Wrong user options are returned!";
EXPECT_FALSE(options.vertex_has_texcoord()) << "Wrong user options are returned!";
EXPECT_FALSE(options.vertex_has_color()) << "Wrong user options are returned!";
}
/*
* Just load a ply file of a cube with vertex colors
*/
TEST_F(OpenMeshLoader, LoadSimplePLYWithVertexColors) {
mesh_.clear();
mesh_.request_vertex_colors();
OpenMesh::IO::Options options;
options += OpenMesh::IO::Options::VertexColor;
bool ok = OpenMesh::IO::read_mesh(mesh_, "cube-minimal-vertexColors.ply",options);
EXPECT_TRUE(ok) << "Unable to load cube-minimal-vertexColors.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(255, 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(0, mesh_.color(mesh_.vertex_handle(0))[2] ) << "Wrong vertex color at vertex 0 component 2";
EXPECT_EQ(255, 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(0, 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
*/
TEST_F(OpenMeshLoader, LoadSimplePLYWithTexCoords) {
mesh_.clear();
mesh_.request_vertex_texcoords2D();
OpenMesh::IO::Options options;
options += OpenMesh::IO::Options::VertexTexCoord;
bool ok = OpenMesh::IO::read_mesh(mesh_, "cube-minimal-texCoords.ply",options);
EXPECT_TRUE(ok) << "Unable to load cube-minimal-texCoords.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(10, mesh_.texcoord2D(mesh_.vertex_handle(0))[0] ) << "Wrong vertex color at vertex 0 component 0";
EXPECT_EQ(10, mesh_.texcoord2D(mesh_.vertex_handle(0))[1] ) << "Wrong vertex color at vertex 0 component 1";
EXPECT_EQ(6, mesh_.texcoord2D(mesh_.vertex_handle(2))[0] ) << "Wrong vertex color at vertex 2 component 0";
EXPECT_EQ(6, mesh_.texcoord2D(mesh_.vertex_handle(2))[1] ) << "Wrong vertex color at vertex 2 component 1";
EXPECT_EQ(9, mesh_.texcoord2D(mesh_.vertex_handle(4))[0] ) << "Wrong vertex color at vertex 4 component 0";
EXPECT_EQ(9, mesh_.texcoord2D(mesh_.vertex_handle(4))[1] ) << "Wrong vertex color at vertex 4 component 1";
EXPECT_EQ(12, mesh_.texcoord2D(mesh_.vertex_handle(7))[0] ) << "Wrong vertex color at vertex 7 component 0";
EXPECT_EQ(12, mesh_.texcoord2D(mesh_.vertex_handle(7))[1] ) << "Wrong vertex color at vertex 7 component 1";
EXPECT_FALSE(options.vertex_has_normal()) << "Wrong user options are returned!";
EXPECT_TRUE(options.vertex_has_texcoord()) << "Wrong user options are returned!";
EXPECT_FALSE(options.vertex_has_color()) << "Wrong user options are returned!";
mesh_.release_vertex_texcoords2D();
}
/*
* Just load a ply with normals, ascii mode
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment