2011-09-01 10:33:58 +00:00
|
|
|
#ifndef INCLUDE_UNITTESTS_LOADING_HH
|
|
|
|
|
#define INCLUDE_UNITTESTS_LOADING_HH
|
2011-09-01 09:28:38 +00:00
|
|
|
|
|
|
|
|
#include <gtest/gtest.h>
|
2011-09-01 10:33:58 +00:00
|
|
|
#include <Unittests/unittests_common.hh>
|
2011-09-01 09:28:38 +00:00
|
|
|
|
|
|
|
|
|
2011-09-01 10:33:58 +00:00
|
|
|
class OpenMeshLoader : public OpenMeshBase {
|
2011-09-01 09:28:38 +00:00
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
// This function is called before each test is run
|
|
|
|
|
virtual void SetUp() {
|
|
|
|
|
|
|
|
|
|
// Do some initial stuff with the member data here...
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// This function is called after all tests are through
|
|
|
|
|
virtual void TearDown() {
|
|
|
|
|
|
|
|
|
|
// Do some final stuff with the member data here...
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-01 10:33:58 +00:00
|
|
|
// Member already defined in OpenMeshBase
|
|
|
|
|
//Mesh mesh_;
|
2011-09-01 09:28:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* ====================================================================
|
|
|
|
|
* Define tests below
|
|
|
|
|
* ====================================================================
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Just load a simple mesh file in obj format and count whether
|
|
|
|
|
* the right number of entities has been loaded.
|
|
|
|
|
*/
|
|
|
|
|
TEST_F(OpenMeshLoader, LoadSimpleOFFFile) {
|
|
|
|
|
|
2011-12-01 16:16:29 +00:00
|
|
|
mesh_.clear();
|
|
|
|
|
|
2011-09-01 09:28:38 +00:00
|
|
|
bool ok = OpenMesh::IO::read_mesh(mesh_, "cube1.off");
|
|
|
|
|
|
|
|
|
|
EXPECT_TRUE(ok);
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(7526, mesh_.n_vertices()) << "The number of loaded vertices is not correct!";
|
|
|
|
|
EXPECT_EQ(22572, mesh_.n_edges()) << "The number of loaded edges is not correct!";
|
|
|
|
|
EXPECT_EQ(15048, mesh_.n_faces()) << "The number of loaded faces is not correct!";
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-25 14:49:07 +00:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Just load a point file in ply format and count whether
|
|
|
|
|
* the right number of entities has been loaded.
|
|
|
|
|
*/
|
2011-11-28 08:59:11 +00:00
|
|
|
TEST_F(OpenMeshLoader, LoadSimplePointPLYFileWithBadEncoding) {
|
2011-11-25 14:49:07 +00:00
|
|
|
|
2011-12-01 16:16:29 +00:00
|
|
|
mesh_.clear();
|
|
|
|
|
|
2011-11-25 14:49:07 +00:00
|
|
|
bool ok = OpenMesh::IO::read_mesh(mesh_, "pointCloudBadEncoding.ply");
|
|
|
|
|
|
2011-11-28 08:59:11 +00:00
|
|
|
EXPECT_TRUE(ok) << "Unable to load pointCloudBadEncoding.ply";
|
2011-11-25 14:49:07 +00:00
|
|
|
|
|
|
|
|
EXPECT_EQ(10, mesh_.n_vertices()) << "The number of loaded vertices is not correct!";
|
|
|
|
|
EXPECT_EQ(0, mesh_.n_edges()) << "The number of loaded edges is not correct!";
|
|
|
|
|
EXPECT_EQ(0, mesh_.n_faces()) << "The number of loaded faces is not correct!";
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-28 08:59:11 +00:00
|
|
|
/*
|
|
|
|
|
* Just load a point file in ply format and count whether
|
|
|
|
|
* the right number of entities has been loaded.
|
|
|
|
|
*/
|
|
|
|
|
TEST_F(OpenMeshLoader, LoadSimplePointPLYFileWithGoodEncoding) {
|
|
|
|
|
|
2011-12-01 16:16:29 +00:00
|
|
|
mesh_.clear();
|
|
|
|
|
|
2011-11-28 08:59:11 +00:00
|
|
|
bool ok = OpenMesh::IO::read_mesh(mesh_, "pointCloudGoodEncoding.ply");
|
2011-11-25 14:49:07 +00:00
|
|
|
|
2011-11-28 08:59:11 +00:00
|
|
|
EXPECT_TRUE(ok) << "Unable to load pointCloudGoodEncoding.ply";
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(10, mesh_.n_vertices()) << "The number of loaded vertices is not correct!";
|
|
|
|
|
EXPECT_EQ(0, mesh_.n_edges()) << "The number of loaded edges is not correct!";
|
|
|
|
|
EXPECT_EQ(0, mesh_.n_faces()) << "The number of loaded faces is not correct!";
|
|
|
|
|
}
|
2011-11-25 14:49:07 +00:00
|
|
|
|
2011-12-01 16:16:29 +00:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Just load a obj file of a cube
|
|
|
|
|
*/
|
|
|
|
|
TEST_F(OpenMeshLoader, LoadSimpleOBJ) {
|
|
|
|
|
|
|
|
|
|
mesh_.clear();
|
|
|
|
|
|
|
|
|
|
bool ok = OpenMesh::IO::read_mesh(mesh_, "cube-minimal.obj");
|
|
|
|
|
|
|
|
|
|
EXPECT_TRUE(ok) << "Unable to load cube-minimal.obj";
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(8, mesh_.n_vertices()) << "The number of loaded vertices is not correct!";
|
|
|
|
|
EXPECT_EQ(18, mesh_.n_edges()) << "The number of loaded edges is not correct!";
|
|
|
|
|
EXPECT_EQ(12, mesh_.n_faces()) << "The number of loaded faces is not correct!";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Just load a obj file of a cube with vertex colors defined directly after the vertex definitions
|
|
|
|
|
*/
|
|
|
|
|
TEST_F(OpenMeshLoader, LoadSimpleOBJWithVertexColorsAfterVertices) {
|
|
|
|
|
|
|
|
|
|
mesh_.clear();
|
|
|
|
|
|
|
|
|
|
mesh_.request_vertex_colors();
|
|
|
|
|
|
|
|
|
|
bool ok = OpenMesh::IO::read_mesh(mesh_, "cube-minimal-vertex-colors-after-vertex-definition.obj");
|
|
|
|
|
|
|
|
|
|
EXPECT_TRUE(ok) << "Unable to load cube-minimal-vertex-colors-after-vertex-definition.obj";
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(8, mesh_.n_vertices()) << "The number of loaded vertices is not correct!";
|
|
|
|
|
EXPECT_EQ(18, mesh_.n_edges()) << "The number of loaded edges is not correct!";
|
|
|
|
|
EXPECT_EQ(12, 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(0, 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(255, 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(255, 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(0, mesh_.color(mesh_.vertex_handle(4))[2] ) << "Wrong vertex color at vertex 4 component 2";
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(7))[0] ) << "Wrong vertex color at vertex 7 component 0";
|
|
|
|
|
EXPECT_EQ(255, 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";
|
|
|
|
|
|
|
|
|
|
mesh_.release_vertex_colors();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Just load a obj file of a cube with vertex colors defined as separate lines
|
|
|
|
|
*/
|
|
|
|
|
TEST_F(OpenMeshLoader, LoadSimpleOBJWithVertexColorsAsVCLines) {
|
|
|
|
|
|
|
|
|
|
mesh_.clear();
|
|
|
|
|
|
|
|
|
|
mesh_.request_vertex_colors();
|
|
|
|
|
|
|
|
|
|
bool ok = OpenMesh::IO::read_mesh(mesh_, "cube-minimal-vertex-colors-as-vc-lines.obj");
|
|
|
|
|
|
|
|
|
|
EXPECT_TRUE(ok) << "Unable to load cube-minimal-vertex-colors-as-vc-lines.obj";
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(8, mesh_.n_vertices()) << "The number of loaded vertices is not correct!";
|
|
|
|
|
EXPECT_EQ(18, mesh_.n_edges()) << "The number of loaded edges is not correct!";
|
|
|
|
|
EXPECT_EQ(12, 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(0, 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(255, 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(255, 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(0, mesh_.color(mesh_.vertex_handle(4))[2] ) << "Wrong vertex color at vertex 4 component 2";
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(255, mesh_.color(mesh_.vertex_handle(7))[0] ) << "Wrong vertex color at vertex 7 component 0";
|
|
|
|
|
EXPECT_EQ(255, 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";
|
|
|
|
|
|
|
|
|
|
mesh_.release_vertex_colors();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-09-01 09:28:38 +00:00
|
|
|
#endif // INCLUDE GUARD
|