Added unittest for decimater

git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@407 fdac6126-5c0c-442c-9429-916003d36597
This commit is contained in:
Jan Möbius
2011-09-01 10:33:58 +00:00
parent d27c282b9b
commit 285cdae318
4 changed files with 108 additions and 16 deletions

View File

@@ -1,6 +1,8 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "unittests_common.hh"
#include "unittests_loading.hh" #include "unittests_loading.hh"
#include "unittests_decimater.hh"
int main(int _argc, char** _argv) { int main(int _argc, char** _argv) {

View File

@@ -0,0 +1,38 @@
#ifndef INCLUDE_UNITTESTS_COMMON_HH
#define INCLUDE_UNITTESTS_COMMON_HH
#include <gtest/gtest.h>
#include <OpenMesh/Core/IO/MeshIO.hh>
#include <OpenMesh/Core/Mesh/TriMesh_ArrayKernelT.hh>
struct CustomTraits : public OpenMesh::DefaultTraits {
};
typedef OpenMesh::TriMesh_ArrayKernelT<CustomTraits> Mesh;
/*
* Simple test setting.
*/
class OpenMeshBase : public testing::Test {
protected:
// This function is called before each test is run
virtual void SetUp() {
// Do some initial stuff with the member data here...
}
// This function is called after all tests are through
virtual void TearDown() {
// Do some final stuff with the member data here...
}
// This member will be accessible in all tests
Mesh mesh_;
};
#endif // INCLUDE GUARD

View File

@@ -0,0 +1,62 @@
#ifndef INCLUDE_UNITTESTS_DECIMATER_HH
#define INCLUDE_UNITTESTS_DECIMATER_HH
#include <gtest/gtest.h>
#include <Unittests/unittests_common.hh>
#include <OpenMesh/Tools/Decimater/DecimaterT.hh>
#include <OpenMesh/Tools/Decimater/ModQuadricT.hh>
#include <OpenMesh/Tools/Decimater/ModNormalFlippingT.hh>
class OpenMeshDecimater : public OpenMeshBase {
protected:
// This function is called before each test is run
virtual void SetUp() {
// Do some initial stuff with the member data here...
}
// This function is called after all tests are through
virtual void TearDown() {
// Do some final stuff with the member data here...
}
// Member already defined in OpenMeshBase
//Mesh mesh_;
};
/*
* ====================================================================
* Define tests below
* ====================================================================
*/
/*
*/
TEST_F(OpenMeshDecimater, DecimateMesh) {
bool ok = OpenMesh::IO::read_mesh(mesh_, "cube1.off");
ASSERT_TRUE(ok);
typedef OpenMesh::Decimater::DecimaterT< Mesh > Decimater;
typedef OpenMesh::Decimater::ModQuadricT< Decimater >::Handle HModQuadric;
typedef OpenMesh::Decimater::ModNormalFlippingT< Decimater >::Handle HModNormal;
Decimater decimaterDBG(mesh_);
HModQuadric hModQuadricDBG;
decimaterDBG.add( hModQuadricDBG );
decimaterDBG.initialize();
int removedVertices = 0;
removedVertices = decimaterDBG.decimate_to(5000);
decimaterDBG.mesh().garbage_collection();
EXPECT_EQ(2526, removedVertices) << "The number of remove vertices is not correct!";
EXPECT_EQ(5000, mesh_.n_vertices()) << "The number of vertices after decimation is not correct!";
EXPECT_EQ(14994, mesh_.n_edges()) << "The number of edges after decimation is not correct!";
EXPECT_EQ(9996, mesh_.n_faces()) << "The number of faces after decimation is not correct!";
}
#endif // INCLUDE GUARD

View File

@@ -1,21 +1,11 @@
#ifndef INCLUDE_UNITTESTS_LOADING_CC #ifndef INCLUDE_UNITTESTS_LOADING_HH
#define INCLUDE_UNITTESTS_LOADING_CC #define INCLUDE_UNITTESTS_LOADING_HH
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <OpenMesh/Core/IO/MeshIO.hh> #include <Unittests/unittests_common.hh>
#include <OpenMesh/Core/Mesh/TriMesh_ArrayKernelT.hh>
struct CustomTraits : public OpenMesh::DefaultTraits { class OpenMeshLoader : public OpenMeshBase {
};
typedef OpenMesh::TriMesh_ArrayKernelT<CustomTraits> Mesh;
/*
* Simple test setting.
*/
class OpenMeshLoader : public testing::Test {
protected: protected:
@@ -31,8 +21,8 @@ class OpenMeshLoader : public testing::Test {
// Do some final stuff with the member data here... // Do some final stuff with the member data here...
} }
// This member will be accessible in all tests // Member already defined in OpenMeshBase
Mesh mesh_; //Mesh mesh_;
}; };
/* /*