OpenMesh
Unittests/unittests_decimater.hh
00001 #ifndef INCLUDE_UNITTESTS_DECIMATER_HH
00002 #define INCLUDE_UNITTESTS_DECIMATER_HH
00003 
00004 #include <gtest/gtest.h>
00005 #include <Unittests/unittests_common.hh>
00006 #include <OpenMesh/Tools/Decimater/DecimaterT.hh>
00007 #include <OpenMesh/Tools/Decimater/ModQuadricT.hh>
00008 #include <OpenMesh/Tools/Decimater/ModNormalFlippingT.hh>
00009 
00010 class OpenMeshDecimater : public OpenMeshBase {
00011 
00012     protected:
00013 
00014         // This function is called before each test is run
00015         virtual void SetUp() {
00016             
00017             // Do some initial stuff with the member data here...
00018         }
00019 
00020         // This function is called after all tests are through
00021         virtual void TearDown() {
00022 
00023             // Do some final stuff with the member data here...
00024         }
00025 
00026     // Member already defined in OpenMeshBase
00027     //Mesh mesh_;  
00028 };
00029 
00030 /*
00031  * ====================================================================
00032  * Define tests below
00033  * ====================================================================
00034  */
00035 
00036 /*
00037  */
00038 TEST_F(OpenMeshDecimater, DecimateMesh) {
00039 
00040   bool ok = OpenMesh::IO::read_mesh(mesh_, "cube1.off");
00041     
00042   ASSERT_TRUE(ok);
00043 
00044   typedef OpenMesh::Decimater::DecimaterT< Mesh >  Decimater;
00045   typedef OpenMesh::Decimater::ModQuadricT< Decimater >::Handle HModQuadric;
00046   typedef OpenMesh::Decimater::ModNormalFlippingT< Decimater >::Handle HModNormal;
00047 
00048   Decimater decimaterDBG(mesh_);
00049   HModQuadric hModQuadricDBG;
00050   decimaterDBG.add( hModQuadricDBG );
00051   decimaterDBG.initialize();
00052   int removedVertices = 0;
00053   removedVertices = decimaterDBG.decimate_to(5000);
00054                     decimaterDBG.mesh().garbage_collection();
00055 
00056   EXPECT_EQ(2526, removedVertices) << "The number of remove vertices is not correct!";
00057   EXPECT_EQ(5000, mesh_.n_vertices()) << "The number of vertices after decimation is not correct!";
00058   EXPECT_EQ(14994, mesh_.n_edges()) << "The number of edges after decimation is not correct!";
00059   EXPECT_EQ(9996, mesh_.n_faces()) << "The number of faces after decimation is not correct!";
00060 }
00061 
00062 #endif // INCLUDE GUARD
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines