From ae9e82f52459846d9edeba56966a7d03fb35fffb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20M=C3=B6ller?= Date: Wed, 30 Apr 2014 12:29:57 +0000 Subject: [PATCH] add unittest for normal flipping module git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@1031 fdac6126-5c0c-442c-9429-916003d36597 --- src/Unittests/unittests_decimater.cc | 29 +++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/Unittests/unittests_decimater.cc b/src/Unittests/unittests_decimater.cc index 4268fed4..37bb307f 100644 --- a/src/Unittests/unittests_decimater.cc +++ b/src/Unittests/unittests_decimater.cc @@ -3,6 +3,7 @@ #include #include #include +#include namespace { @@ -132,16 +133,38 @@ TEST_F(OpenMeshDecimater, DecimateMeshExampleFromDoc) { } +TEST_F(OpenMeshDecimater, DecimateMeshNormalFlipping) { + bool ok = OpenMesh::IO::read_mesh(mesh_, "cube1.off"); + ASSERT_TRUE(ok); + typedef OpenMesh::Decimater::DecimaterT< Mesh > Decimater; + typedef OpenMesh::Decimater::ModNormalFlippingT < Mesh >::Handle HModNormalFlipping; + typedef OpenMesh::Decimater::ModQuadricT< Mesh >::Handle HModQuadric; + Decimater decimaterDBG(mesh_); + HModNormalFlipping hModNormalFlippingDGB; + decimaterDBG.add( hModNormalFlippingDGB ); + HModQuadric hModQuadricDBG; + decimaterDBG.add( hModQuadricDBG ); + std::cout << decimaterDBG.module( hModQuadricDBG ).name() << std::endl; + decimaterDBG.module( hModQuadricDBG ).unset_max_err(); + std::cout << decimaterDBG.module( hModNormalFlippingDGB ).name() << std::endl; + decimaterDBG.module( hModNormalFlippingDGB ).set_max_normal_deviation(45.0); + EXPECT_TRUE(decimaterDBG.module( hModNormalFlippingDGB ).is_binary()) << "Normal Flipping Module is not binary."; + decimaterDBG.initialize(); + size_t removedVertices = 0; + removedVertices = decimaterDBG.decimate_to_faces(4500, 9996); + decimaterDBG.mesh().garbage_collection(); - - - + EXPECT_EQ(2526u, removedVertices) << "The number of remove vertices is not correct!"; + EXPECT_EQ(5000u, mesh_.n_vertices()) << "The number of vertices after decimation is not correct!"; + EXPECT_EQ(14994u, mesh_.n_edges()) << "The number of edges after decimation is not correct!"; + EXPECT_EQ(9996u, mesh_.n_faces()) << "The number of faces after decimation is not correct!"; +} }