2 #include <gtest/gtest.h>
3 #include <Unittests/unittests_common.hh>
10 class OpenMeshMultipleChoiceDecimater :
public OpenMeshBase {
15 virtual void SetUp() {
21 virtual void TearDown() {
38 TEST_F(OpenMeshMultipleChoiceDecimater, DecimateMesh) {
48 Decimater decimaterDBG(mesh_);
49 HModQuadric hModQuadricDBG;
50 decimaterDBG.add( hModQuadricDBG );
51 decimaterDBG.initialize();
52 size_t removedVertices = 0;
53 removedVertices = decimaterDBG.decimate_to(5000);
54 decimaterDBG.mesh().garbage_collection();
56 EXPECT_EQ(2526u, removedVertices) <<
"The number of remove vertices is not correct!";
57 EXPECT_EQ(5000u, mesh_.n_vertices()) <<
"The number of vertices after decimation is not correct!";
58 EXPECT_EQ(14994u, mesh_.n_edges()) <<
"The number of edges after decimation is not correct!";
59 EXPECT_EQ(9996u, mesh_.n_faces()) <<
"The number of faces after decimation is not correct!";
62 TEST_F(OpenMeshMultipleChoiceDecimater, DecimateMeshToFaceVerticesLimit) {
72 Decimater decimaterDBG(mesh_);
73 HModQuadric hModQuadricDBG;
74 decimaterDBG.add( hModQuadricDBG );
75 decimaterDBG.initialize();
76 size_t removedVertices = 0;
77 removedVertices = decimaterDBG.decimate_to_faces(5000, 8000);
78 decimaterDBG.mesh().garbage_collection();
80 EXPECT_EQ(2526u, removedVertices) <<
"The number of remove vertices is not correct!";
81 EXPECT_EQ(5000u, mesh_.n_vertices()) <<
"The number of vertices after decimation is not correct!";
82 EXPECT_EQ(14994u, mesh_.n_edges()) <<
"The number of edges after decimation is not correct!";
83 EXPECT_EQ(9996u, mesh_.n_faces()) <<
"The number of faces after decimation is not correct!";
86 TEST_F(OpenMeshMultipleChoiceDecimater, DecimateMeshToFaceFaceLimit) {
96 Decimater decimaterDBG(mesh_);
97 HModQuadric hModQuadricDBG;
98 decimaterDBG.add( hModQuadricDBG );
99 decimaterDBG.initialize();
100 size_t removedVertices = 0;
101 removedVertices = decimaterDBG.decimate_to_faces(4500, 9996);
102 decimaterDBG.mesh().garbage_collection();
104 EXPECT_EQ(2526u, removedVertices) <<
"The number of remove vertices is not correct!";
105 EXPECT_EQ(5000u, mesh_.n_vertices()) <<
"The number of vertices after decimation is not correct!";
106 EXPECT_EQ(14994u, mesh_.n_edges()) <<
"The number of edges after decimation is not correct!";
107 EXPECT_EQ(9996u, mesh_.n_faces()) <<
"The number of faces after decimation is not correct!";
115 UnittestObserver(
size_t _steps) :Observer(_steps), notifies_(0), all_steps_(0) {}
124 return all_steps_ >= 2526u;
127 size_t countedNotifies()
133 TEST_F(OpenMeshMultipleChoiceDecimater, DecimateMeshStoppedByObserver) {
142 Decimater decimaterDBG(mesh_);
143 HModQuadric hModQuadricDBG;
144 decimaterDBG.add(hModQuadricDBG);
146 decimaterDBG.module(hModQuadricDBG).unset_max_err();
148 decimaterDBG.initialize();
149 UnittestObserver obs(2);
150 decimaterDBG.set_observer(&obs);
151 size_t removedVertices = 0;
152 removedVertices = decimaterDBG.decimate_to_faces(0, 0);
153 decimaterDBG.mesh().garbage_collection();
155 EXPECT_TRUE(obs.abort()) <<
"Observer did not abort the decimater!";
156 EXPECT_EQ(obs.countedNotifies(), 2526u / 2u) <<
"Observer did not get the right amount of notifications!";
158 EXPECT_EQ(2526u, removedVertices) <<
"The number of remove vertices is not correct!";
159 EXPECT_EQ(5000u, mesh_.n_vertices()) <<
"The number of vertices after decimation is not correct!";
160 EXPECT_EQ(14994u, mesh_.n_edges()) <<
"The number of edges after decimation is not correct!";
161 EXPECT_EQ(9996u, mesh_.n_faces()) <<
"The number of faces after decimation is not correct!";
bool read_mesh(Mesh &_mesh, const std::string &_filename)
Read a mesh from file _filename.
Mesh decimation module computing collapse priority based on error quadrics.
virtual void notify(size_t _step)=0
callback
virtual bool abort() const
Abort callback.