diff --git a/src/Unittests/unittests_eigen3_type.cc b/src/Unittests/unittests_eigen3_type.cc index 7be54b70e9b35a1b3ad82ef9fb464fc5042f1b5d..32be104682363a6b6e35e17a724ce3f6ca0a0223 100644 --- a/src/Unittests/unittests_eigen3_type.cc +++ b/src/Unittests/unittests_eigen3_type.cc @@ -7,6 +7,9 @@ #include #include +#include +#include +#include #include @@ -232,6 +235,37 @@ TEST_F(OpenMeshEigenTest, LoadSimpleOFFFile) { mesh_.update_normals(); } +// Test decimation with Eigen as vector type +TEST_F(OpenMeshEigenTest, Decimater) { + mesh_.clear(); + + bool ok = OpenMesh::IO::read_mesh(mesh_, "cube1.off"); + + EXPECT_TRUE(ok); + + 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_.update_normals(); + + OpenMesh::Decimater::DecimaterT decimater(mesh_); + OpenMesh::Decimater::ModQuadricT::Handle hModQuadric; // use a quadric module + OpenMesh::Decimater::ModNormalDeviationT::Handle hModNormalDeviation; // also use normal deviation module as binary check + decimater.add(hModQuadric); + decimater.add(hModNormalDeviation); + decimater.module(hModQuadric).unset_max_err(); + decimater.module(hModNormalDeviation).set_normal_deviation(15); + decimater.initialize(); + size_t removedVertices = decimater.decimate_to(8); + mesh_.garbage_collection(); + + EXPECT_EQ(6998u, removedVertices) << "The number of remove vertices is not correct!"; + EXPECT_EQ( 528u, mesh_.n_vertices()) << "The number of vertices after decimation is not correct!"; + EXPECT_EQ(1578u, mesh_.n_edges()) << "The number of edges after decimation is not correct!"; + EXPECT_EQ(1052u, mesh_.n_faces()) << "The number of faces after decimation is not correct!"; +} + } #endif