- fix crash, if obj file contains degenerated faces

- added unittest for this case

closes #2382

git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@1236 fdac6126-5c0c-442c-9429-916003d36597
This commit is contained in:
Matthias Möller
2015-03-09 09:56:41 +00:00
parent bf21ed8ad0
commit 53371f63e1
3 changed files with 76 additions and 1 deletions

View File

@@ -0,0 +1,29 @@
g cube
v 0.0 0.0 0.0
v 0.0 0.0 1.0
v 0.0 1.0 0.0
v 0.0 1.0 1.0
v 1.0 0.0 0.0
v 1.0 0.0 1.0
v 1.0 1.0 0.0
v 1.0 1.0 1.0
vn 0.0 0.0 1.0
vn 0.0 0.0 -1.0
vn 0.0 1.0 0.0
vn 0.0 -1.0 0.0
vn 1.0 0.0 0.0
vn -1.0 0.0 0.0
f 1//2 7//2 5//2
f 1//2 3//2 7//2
f 1//6 4//6 3//6
f 1//6 2//6 4//6
f 3//3 8//3 7//3
f 3//3 4//3 8//3
f 5//5 7//5 8//5
f 5//5 8//5 6//5
f 1//4 5//4 6//4
f 1//4 6//4 2//4
f 2//1 6//1 8//1 8//1 2//1
f 2//1 8//1 4//1
f 2//1 2//1 2//1
f 2//1 8//1 2//1

View File

@@ -47,6 +47,22 @@ TEST_F(OpenMeshReadWriteOBJ, LoadSimpleOBJ) {
EXPECT_EQ(12u , mesh_.n_faces()) << "The number of loaded faces is not correct!";
}
/*
* Just load a obj file of a cube with degenerated faces
*/
TEST_F(OpenMeshReadWriteOBJ, LoadDegeneratedOBJ) {
mesh_.clear();
bool ok = OpenMesh::IO::read_mesh(mesh_, "cube-minimal.obj");
EXPECT_TRUE(ok) << "Unable to load cube-minimal.obj";
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!";
}
/*
* Just load a obj file of a cube and checks the halfedge and vertex normals
*/