Commit 00683495 by Daniel Gotzen

unittest for decimater examples

1 parent 00f21ae5
Pipeline #4675 for 00683495 failed in 41 minutes 48 seconds
#include <OpenMesh/Tools/Decimater/DecimaterT.hh>
#include <OpenMesh/../../Doc/Examples/decimaterTestMesh.hh>
#include <OpenMesh/Tools/Decimater/ModHausdorffT.hh>
#include <OpenMesh/Tools/Decimater/ModNormalDeviationT.hh>
#include <OpenMesh/Tools/Decimater/ModAspectRatioT.hh>
using namespace OpenMesh;
typedef Decimater::DecimaterT<ExampleMesh> ExampleDecimater;
typedef Decimater::ModNormalDeviationT<ExampleMesh>::Handle HModNormalDeviation;
typedef Decimater::ModAspectRatioT<ExampleMesh>::Handle HModAspectRatio;
typedef Decimater::ModHausdorffT<ExampleMesh>::Handle HModHausdorff;
void decimate(ExampleMesh& mesh ){
ExampleDecimater decimater(mesh); // a decimater object, connected to a mesh
HModNormalDeviation hModNormalDeviation; // use a normal deviation module primarily
decimater.add(hModNormalDeviation); // register deviation module at the decimater
decimater.module(hModNormalDeviation).set_binary(false); // exact one module must be non-binary
decimater.module(hModNormalDeviation).set_normal_deviation(15.0); // set max angle between normals in degrees
std::cout << decimater.module(hModNormalDeviation).name() << std::endl; // module access
HModAspectRatio hModAspectRatio; // use an aspect ratio module
decimater.add(hModAspectRatio); // register the second module
decimater.module(hModAspectRatio).set_binary(true); // further modules must be binary
decimater.module(hModAspectRatio).set_aspect_ratio(3.0); // prevents collapsses which result in a smaller aspect ratio than the chosen minimum
HModHausdorff hModHausdorff; // use a hausdorff distance module
decimater.add(hModHausdorff); // register the third module
//note that ModHausdorff only supports binary mode
decimater.module(hModHausdorff).set_tolerance(10.0); // set max Hausdorff distance tollerance
decimater.initialize();
decimater.decimate();
// after decimation: remove decimated elements from the mesh
mesh.garbage_collection();
}
......@@ -2,13 +2,14 @@ using namespace OpenMesh;
typedef TriMesh_ArrayKernelT<> Mesh;
typedef Decimater::DecimaterT<Mesh> Decimater;
typedef Decimater::ModIndependentT<Mesh>::Handle HModIndependent;
typedef Decimater::ModIndependentSetsT<Mesh>::Handle HModIndependent;
typedef Decimater::ModNormalDeviationT<Mesh>::Handle HModNormalDeviation;
Mesh mesh; // a mesh object
Decimater decimater(mesh); // a decimater object, connected to a mesh
HModIndependent hModIndependent; // use a independence module
decimater.add(hModIndependent); // register the module at the decimater
//note that ModIndependent only supports binary mode and has to be used in combination with a non-binary module
HModNormalDeviation hModNormalDeviation; // use a non-binary module primarily
......
#pragma once
using namespace OpenMesh;
struct CustomTraitsVec3f : OpenMesh::DefaultTraits
{
typedef OpenMesh::Vec3f Point;
};
typedef TriMesh_ArrayKernelT<CustomTraitsVec3f> ExampleMesh;
#include <OpenMesh/Tools/Decimater/DecimaterT.hh>
#include <OpenMesh/../../Doc/Examples/decimaterTestMesh.hh>
#include <OpenMesh/Tools/Decimater/ModAspectRatioT.hh>
using namespace OpenMesh;
typedef Decimater::DecimaterT<ExampleMesh> ExampleDecimater;
typedef Decimater::ModAspectRatioT<ExampleMesh>::Handle HModAspectRatio;
void decimateAspectRatio(ExampleMesh& mesh ){
ExampleDecimater decimater(mesh); // a decimater object, connected to a mesh
HModAspectRatio hModAspectRatio; // use an aspect ratio module
decimater.add(hModAspectRatio); // register the aspect ratio module
decimater.module(hModAspectRatio).set_binary(false); // if the aspect ratio module is not the primary module set binary to true;
decimater.module(hModAspectRatio).set_aspect_ratio(3.0); // prevents collapsses which result in a smaller aspect ratio than the chosen minimum
decimater.initialize();
decimater.decimate();
// after decimation: remove decimated elements from the mesh
mesh.garbage_collection();
}
#include <OpenMesh/Tools/Decimater/DecimaterT.hh>
#include <OpenMesh/../../Doc/Examples/decimaterTestMesh.hh>
#include <OpenMesh/Tools/Decimater/ModEdgeLengthT.hh>
using namespace OpenMesh;
typedef Decimater::DecimaterT<ExampleMesh> ExampleDecimater;
typedef Decimater::ModEdgeLengthT<ExampleMesh>::Handle HModEdgeLength;
void decimateEdgeLength(ExampleMesh& mesh ){
ExampleDecimater decimater(mesh); // a decimater object, connected to a mesh
HModEdgeLength hModEdgeLength; // use an edge length module
decimater.add(hModEdgeLength); // register the edge length module
decimater.module(hModEdgeLength).set_binary(false); // if the edge length module is not the primary module set binary to true;
decimater.module(hModEdgeLength).set_edge_length (4.0); // choose the maximum length of edges to be collapsed
decimater.initialize();
decimater.decimate();
// after decimation: remove decimated elements from the mesh
mesh.garbage_collection();
}
#include <OpenMesh/Tools/Decimater/DecimaterT.hh>
#include <OpenMesh/../../Doc/Examples/decimaterTestMesh.hh>
#include <OpenMesh/Tools/Decimater/ModHausdorffT.hh>
#include <OpenMesh/Tools/Decimater/ModNormalDeviationT.hh>
using namespace OpenMesh;
typedef Decimater::DecimaterT<ExampleMesh> ExampleDecimater;
typedef Decimater::ModHausdorffT<ExampleMesh>::Handle HModHausdorff;
typedef Decimater::ModNormalDeviationT<ExampleMesh>::Handle HModNormalDeviation;
void decimateHausdorff(ExampleMesh& mesh ){
ExampleDecimater decimater(mesh); // a decimater object, connected to a mesh
HModHausdorff hModHausdorff; // use a hausdorff distance module
decimater.add(hModHausdorff); // register the hausdorff distance module
decimater.module(hModHausdorff).set_tolerance(10.0); // set max Hausdorff distance tollerance
//note that ModHausdorff only supports binary mode and has to be used in combination with a non-binary module
HModNormalDeviation hModNormalDeviation; // use a non-binary module primarily
decimater.add(hModNormalDeviation); // register the module at the decimater
decimater.module(hModNormalDeviation).set_binary(false); // choose non-binary mode
decimater.initialize();
decimater.decimate();
// after decimation: remove decimated elements from the mesh
mesh.garbage_collection();
}
#include <OpenMesh/Tools/Decimater/DecimaterT.hh>
#include <OpenMesh/../../Doc/Examples/decimaterTestMesh.hh>
#include <OpenMesh/Tools/Decimater/ModNormalDeviationT.hh>
#include <OpenMesh/Tools/Decimater/ModIndependentSetsT.hh>
using namespace OpenMesh;
typedef Decimater::DecimaterT<ExampleMesh> ExampleDecimater;
typedef Decimater::ModIndependentSetsT<ExampleMesh>::Handle HModIndependent;
typedef Decimater::ModNormalDeviationT<ExampleMesh>::Handle HModNormalDeviation;
void decimateIndependent(ExampleMesh& mesh ){
ExampleDecimater decimater(mesh); // a decimater object, connected to a mesh
HModIndependent hModIndependent; // use a independence module
decimater.add(hModIndependent); // register the module at the decimater
//note that ModIndependent only supports binary mode and has to be used in combination with a non-binary module
HModNormalDeviation hModNormalDeviation; // use a non-binary module primarily
decimater.add(hModNormalDeviation); // register the module at the decimater
decimater.module(hModNormalDeviation).set_binary(false); // choose non-binary mode
decimater.initialize();
decimater.decimate();
// after decimation: remove decimated elements from the mesh
mesh.garbage_collection();
}
#include <OpenMesh/Tools/Decimater/DecimaterT.hh>
#include <OpenMesh/../../Doc/Examples/decimaterTestMesh.hh>
#include <OpenMesh/Tools/Decimater/ModNormalDeviationT.hh>
using namespace OpenMesh;
typedef Decimater::DecimaterT<ExampleMesh> ExampleDecimater;
typedef Decimater::ModNormalDeviationT<ExampleMesh>::Handle HModNormalDeviation;
void decimateNormalDeviation(ExampleMesh& mesh ){
ExampleDecimater decimater(mesh); // a decimater object, connected to a mesh
HModNormalDeviation hModNormalDeviation; // use a normal deviation module
decimater.add(hModNormalDeviation); // register deviation module at the decimater
decimater.module(hModNormalDeviation).set_binary(false); // if the normal deviation module is not the primary module set binary to true;
decimater.module(hModNormalDeviation).set_normal_deviation(15.0); // set max angle between normals in degrees
decimater.initialize();
decimater.decimate();
// after decimation: remove decimated elements from the mesh
mesh.garbage_collection();
}
#include <OpenMesh/Tools/Decimater/DecimaterT.hh>
#include <OpenMesh/../../Doc/Examples/decimaterTestMesh.hh>
#include <OpenMesh/Tools/Decimater/ModNormalFlippingT.hh>
#include <OpenMesh/Tools/Decimater/ModNormalDeviationT.hh>
using namespace OpenMesh;
typedef Decimater::DecimaterT<ExampleMesh> ExampleDecimater;
typedef Decimater::ModNormalFlippingT<ExampleMesh>::Handle HModNormalFlipping;
typedef Decimater::ModNormalDeviationT<ExampleMesh>::Handle HModNormalDeviation;
void decimateNormalFlipping(ExampleMesh& mesh ){
ExampleDecimater decimater(mesh); // a decimater object, connected to a mesh
HModNormalFlipping hModNormalFlipping; // use a normal flipping module
decimater.add(hModNormalFlipping); // register the normal flipping module
decimater.module(hModNormalFlipping).set_max_normal_deviation(45.0); // set the maximum normal deviation after collapse
//note that ModNormalFlipping only supports binary mode and has to be used in combination with a non-binary module
HModNormalDeviation hModNormalDeviation; // use a non-binary module primarily
decimater.add(hModNormalDeviation); // register the module at the decimater
decimater.module(hModNormalDeviation).set_binary(false); // choose non-binary mode
decimater.initialize();
decimater.decimate();
// after decimation: remove decimated elements from the mesh
mesh.garbage_collection();
}
#include <OpenMesh/Tools/Decimater/DecimaterT.hh>
#include <OpenMesh/../../Doc/Examples/decimaterTestMesh.hh>
#include <OpenMesh/Tools/Decimater/ModQuadricT.hh>
using namespace OpenMesh;
typedef Decimater::DecimaterT<ExampleMesh> ExampleDecimater;
typedef Decimater::ModQuadricT<ExampleMesh>::Handle HModQuadric;
void decimateQuadric(ExampleMesh& mesh ){
ExampleDecimater decimater(mesh); // a decimater object, connected to a mesh
HModQuadric hModQuadric; // use a quadric module
decimater.add(hModQuadric); // register module at the decimater
std::cout << decimater.module(hModQuadric).name() << std::endl; // module access
/*
* since we need exactly one priority module (non-binary)
* we have to call set_binary(false) for our priority module
* in the case of HModQuadric, unset_max_err() calls set_binary(false) internally
*/
decimater.module(hModQuadric).unset_max_err();
decimater.initialize();
decimater.decimate();
// after decimation: remove decimated elements from the mesh
mesh.garbage_collection();
}
#include <OpenMesh/Tools/Decimater/DecimaterT.hh>
#include <OpenMesh/../../Doc/Examples/decimaterTestMesh.hh>
#include <OpenMesh/Tools/Decimater/ModRoundnessT.hh>
using namespace OpenMesh;
typedef Decimater::DecimaterT<ExampleMesh> ExampleDecimater;
typedef Decimater::ModRoundnessT<ExampleMesh>::Handle HModRoundness;
void decimateRoundness(ExampleMesh& mesh ){
ExampleDecimater decimater(mesh); // a decimater object, connected to a mesh
HModRoundness hModRoundness; // use a roundness module
decimater.add(hModRoundness); // register the roundness module
//in non-binary mode set OR unset minimal roundness
decimater.module(hModRoundness).set_min_roundness(0.5, false); // choose a minimal roundness value between 0 and 1.0 and set binary mode to false
decimater.module(hModRoundness).unset_min_roundness(); // or unset minimal roundness
//in binary mode choose a minimal roundness OR angle
decimater.module(hModRoundness).set_min_roundness(0.5, true); // choose a minimal roundness value between 0 and 1.0 and set binary mode to true
decimater.module(hModRoundness).set_min_angle(15.0, true); // or choose a minimal angle in degrees. second argument gets ignored
decimater.initialize();
decimater.decimate();
// after decimation: remove decimated elements from the mesh
mesh.garbage_collection();
}
#include <gtest/gtest.h>
#include <Unittests/unittests_common.hh>
#include <iostream>
#include "OpenMesh/../../Doc/Examples/decimater.hh"
#include "OpenMesh/../../Doc/Examples/decimater_ModAspectRatioT.hh"
#include "OpenMesh/../../Doc/Examples/decimater_ModEdgeLengthT.hh"
#include "OpenMesh/../../Doc/Examples/decimater_ModHausdorffT.hh"
#include "OpenMesh/../../Doc/Examples/decimater_ModIndependentT.hh"
#include "OpenMesh/../../Doc/Examples/decimater_ModNormalDeviationT.hh"
#include "OpenMesh/../../Doc/Examples/decimater_ModNormalFlippingT.hh"
#include "OpenMesh/../../Doc/Examples/decimater_ModQuadricT.hh"
#include "OpenMesh/../../Doc/Examples/decimater_ModRoundnessT.hh"
typedef OpenMesh::TriMesh_ArrayKernelT<CustomTraitsVec3f> TriMeshVec3f;
class OpenMeshDocDecimater : public testing::Test {
protected:
// This function is called before each test is run
virtual void SetUp() {
}
// 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
TriMeshVec3f mesh_;
};
namespace {
/*
* ====================================================================
* Define tests below
* ====================================================================
*/
/*
* Checking decimater_ModAspectRatioT.hh
*/
TEST_F(OpenMeshDocDecimater, Instance_Doc_Decimater) {
mesh_.clear();
// Add some vertices
TriMeshVec3f::VertexHandle vhandle[4];
vhandle[0] = mesh_.add_vertex(TriMeshVec3f::Point(0.0, 0.0, 0.0));
vhandle[1] = mesh_.add_vertex(TriMeshVec3f::Point(0.0, 1.0, 0.0));
vhandle[2] = mesh_.add_vertex(TriMeshVec3f::Point(1.0, 1.0, 0.0));
vhandle[3] = mesh_.add_vertex(TriMeshVec3f::Point(0.5, 0.5, 0.0));
// Add faces
std::vector<TriMeshVec3f::VertexHandle> face_vhandles1;
std::vector<TriMeshVec3f::VertexHandle> face_vhandles2;
face_vhandles1.push_back(vhandle[0]);
face_vhandles1.push_back(vhandle[1]);
face_vhandles1.push_back(vhandle[3]);
mesh_.add_face(face_vhandles1);
face_vhandles2.push_back(vhandle[3]);
face_vhandles2.push_back(vhandle[1]);
face_vhandles2.push_back(vhandle[2]);
mesh_.add_face(face_vhandles2);
decimateAspectRatio(mesh_);
//TODO check if faces collapsed
//TODO:
decimate(mesh_);
decimateAspectRatio(mesh_);
decimateEdgeLength(mesh_);
decimateHausdorff(mesh_);
decimateIndependent(mesh_);
decimateNormalDeviation(mesh_);
decimateNormalFlipping(mesh_);
decimateQuadric(mesh_);
decimateRoundness(mesh_);
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!