OpenMesh
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
unittests_decimater.hh
1 #ifndef INCLUDE_UNITTESTS_DECIMATER_HH
2 #define INCLUDE_UNITTESTS_DECIMATER_HH
3 
4 #include <gtest/gtest.h>
5 #include <Unittests/unittests_common.hh>
9 
11 
12  protected:
13 
14  // This function is called before each test is run
15  virtual void SetUp() {
16 
17  // Do some initial stuff with the member data here...
18  }
19 
20  // This function is called after all tests are through
21  virtual void TearDown() {
22 
23  // Do some final stuff with the member data here...
24  }
25 
26  // Member already defined in OpenMeshBase
27  //Mesh mesh_;
28 };
29 
30 /*
31  * ====================================================================
32  * Define tests below
33  * ====================================================================
34  */
35 
36 /*
37  */
38 TEST_F(OpenMeshDecimater, DecimateMesh) {
39 
40  bool ok = OpenMesh::IO::read_mesh(mesh_, "cube1.off");
41 
42  ASSERT_TRUE(ok);
43 
44  typedef OpenMesh::Decimater::DecimaterT< Mesh > Decimater;
45  typedef OpenMesh::Decimater::ModQuadricT< Decimater >::Handle HModQuadric;
46  typedef OpenMesh::Decimater::ModNormalFlippingT< Decimater >::Handle HModNormal;
47 
48  Decimater decimaterDBG(mesh_);
49  HModQuadric hModQuadricDBG;
50  decimaterDBG.add( hModQuadricDBG );
51  decimaterDBG.initialize();
52  int removedVertices = 0;
53  removedVertices = decimaterDBG.decimate_to(5000);
54  decimaterDBG.mesh().garbage_collection();
55 
56  EXPECT_EQ(2526, removedVertices) << "The number of remove vertices is not correct!";
57  EXPECT_EQ(5000, mesh_.n_vertices()) << "The number of vertices after decimation is not correct!";
58  EXPECT_EQ(14994, mesh_.n_edges()) << "The number of edges after decimation is not correct!";
59  EXPECT_EQ(9996, mesh_.n_faces()) << "The number of faces after decimation is not correct!";
60 }
61 
62 #endif // INCLUDE GUARD

acg pic Project OpenMesh, ©  Computer Graphics Group, RWTH Aachen. Documentation generated using doxygen .