- the OpenMesh STLReader now also reads face normals if requested

- added corresponding unittests
- removed duplicate code

closes #1719

git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@962 fdac6126-5c0c-442c-9429-916003d36597
This commit is contained in:
Isaak Lim
2013-09-26 10:35:13 +00:00
parent dc5785e812
commit b643b26f2d
3 changed files with 104 additions and 181 deletions

View File

@@ -49,6 +49,36 @@ TEST_F(OpenMeshReadWriteSTL, LoadSimpleSTLFile) {
}
/*
* Just load a simple mesh file in stla format and count whether
* the right number of entities has been loaded. Also check facet normals.
*/
TEST_F(OpenMeshReadWriteSTL, LoadSimpleSTLFileWithNormals) {
mesh_.clear();
mesh_.request_face_normals();
OpenMesh::IO::Options opt;
opt += OpenMesh::IO::Options::FaceNormal;
bool ok = OpenMesh::IO::read_mesh(mesh_, "cube1.stl", opt);
EXPECT_TRUE(ok);
EXPECT_TRUE(opt.face_has_normal());
EXPECT_FALSE(opt.vertex_has_normal());
EXPECT_NEAR(-0.038545f, mesh_.normal(mesh_.face_handle(0))[0], 0.0001 ) << "Wrong face normal at face 0 component 0";
EXPECT_NEAR(-0.004330f, mesh_.normal(mesh_.face_handle(0))[1], 0.0001 ) << "Wrong face normal at face 0 component 1";
EXPECT_NEAR(0.999247f, mesh_.normal(mesh_.face_handle(0))[2], 0.0001 ) << "Wrong face normal at face 0 component 2";
EXPECT_EQ(7526u , mesh_.n_vertices()) << "The number of loaded vertices is not correct!";
EXPECT_EQ(22572u , mesh_.n_edges()) << "The number of loaded edges is not correct!";
EXPECT_EQ(15048u , mesh_.n_faces()) << "The number of loaded faces is not correct!";
mesh_.release_face_normals();
}
/*
* Just load a simple mesh file in stlb format and count whether
@@ -67,4 +97,37 @@ TEST_F(OpenMeshReadWriteSTL, LoadSimpleSTLBinaryFile) {
EXPECT_EQ(15048u , mesh_.n_faces()) << "The number of loaded faces is not correct!";
}
/*
* Just load a simple mesh file in stlb format and count whether
* the right number of entities has been loaded. Also check facet normals.
*/
TEST_F(OpenMeshReadWriteSTL, LoadSimpleSTLBinaryFileWithNormals) {
mesh_.clear();
mesh_.request_face_normals();
OpenMesh::IO::Options opt;
opt += OpenMesh::IO::Options::FaceNormal;
opt += OpenMesh::IO::Options::Binary;
bool ok = OpenMesh::IO::read_mesh(mesh_, "cube1Binary.stl", opt);
EXPECT_TRUE(ok);
EXPECT_TRUE(opt.is_binary());
EXPECT_TRUE(opt.face_has_normal());
EXPECT_FALSE(opt.vertex_has_normal());
EXPECT_NEAR(-0.038545f, mesh_.normal(mesh_.face_handle(0))[0], 0.0001 ) << "Wrong face normal at face 0 component 0";
EXPECT_NEAR(-0.004330f, mesh_.normal(mesh_.face_handle(0))[1], 0.0001 ) << "Wrong face normal at face 0 component 1";
EXPECT_NEAR(0.999247f, mesh_.normal(mesh_.face_handle(0))[2], 0.0001 ) << "Wrong face normal at face 0 component 2";
EXPECT_EQ(7526u , mesh_.n_vertices()) << "The number of loaded vertices is not correct!";
EXPECT_EQ(22572u , mesh_.n_edges()) << "The number of loaded edges is not correct!";
EXPECT_EQ(15048u , mesh_.n_faces()) << "The number of loaded faces is not correct!";
mesh_.release_face_normals();
}
}