From e4ac38ce965612259a49d66f26158621b803b295 Mon Sep 17 00:00:00 2001 From: Isaak Lim Date: Wed, 26 Sep 2012 12:26:32 +0000 Subject: [PATCH] - removed redundant tests in is_collapse_legal that where already performed in is_collapse_ok - on moneta this reduced the running time (release mode) of the incremental decimater from around 30 s to 27.5 s when decimating 400 000 faces with a distance constraint of 1.0 and a normal dev. constraint of 10 - the McDecimater currently clocks in at around 7 s in average with the same constraints refs #1005 git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@703 fdac6126-5c0c-442c-9429-916003d36597 --- .../Tools/Decimater/BaseDecimaterT.cc | 51 ++++++------------- 1 file changed, 15 insertions(+), 36 deletions(-) diff --git a/src/OpenMesh/Tools/Decimater/BaseDecimaterT.cc b/src/OpenMesh/Tools/Decimater/BaseDecimaterT.cc index 31b6ef48..41ba09be 100644 --- a/src/OpenMesh/Tools/Decimater/BaseDecimaterT.cc +++ b/src/OpenMesh/Tools/Decimater/BaseDecimaterT.cc @@ -101,10 +101,19 @@ template bool BaseDecimaterT::is_collapse_legal(const CollapseInfo& _ci) { // std::clog << "McDecimaterT<>::is_collapse_legal()\n"; - // locked ? deleted ? - if (mesh_.status(_ci.v0).locked() || mesh_.status(_ci.v0).deleted()) + // locked ? + if (mesh_.status(_ci.v0).locked()) return false; + // this test checks: + // is v0v1 deleted? + // is v0 deleted? + // is v1 deleted? + // are both vlv0 and v1vl boundary edges? + // are both v0vr and vrv1 boundary edges? + // are vl and vr equal or both invalid? + // one ring intersection test + // edge between two boundary vertices should be a boundary edge if (!mesh_.is_collapse_ok(_ci.v0v1)) return false; @@ -119,48 +128,18 @@ bool BaseDecimaterT::is_collapse_legal(const CollapseInfo& _ci) { && !mesh_.status(mesh_.edge_handle(_ci.v0v1)).feature()) return false; - //--- test one ring intersection --- - - typename Mesh::VertexVertexIter vv_it; - - for (vv_it = mesh_.vv_iter(_ci.v0); vv_it; ++vv_it) - mesh_.status(vv_it).set_tagged(false); - - for (vv_it = mesh_.vv_iter(_ci.v1); vv_it; ++vv_it) - mesh_.status(vv_it).set_tagged(true); - - for (vv_it = mesh_.vv_iter(_ci.v0); vv_it; ++vv_it) - if (mesh_.status(vv_it).tagged() && vv_it.handle() != _ci.vl - && vv_it.handle() != _ci.vr) - return false; - - // if both are invalid OR equal -> fail - if (_ci.vl == _ci.vr) - return false; - //--- test boundary cases --- if (mesh_.is_boundary(_ci.v0)) { - if (!mesh_.is_boundary(_ci.v1)) { // don't collapse a boundary vertex to an inner one + + // don't collapse a boundary vertex to an inner one + if (!mesh_.is_boundary(_ci.v1)) return false; - } else { // edge between two boundary vertices has to be a boundary edge - if (!(mesh_.is_boundary(_ci.v0v1) || mesh_.is_boundary(_ci.v1v0))) - return false; - } + // only one one ring intersection if (_ci.vl.is_valid() && _ci.vr.is_valid()) return false; } - // v0vl and v1vl must not both be boundary edges - if (_ci.vl.is_valid() && mesh_.is_boundary(_ci.vlv1) - && mesh_.is_boundary(_ci.v0vl)) - return false; - - // v0vr and v1vr must not be both boundary edges - if (_ci.vr.is_valid() && mesh_.is_boundary(_ci.vrv0) - && mesh_.is_boundary(_ci.v1vr)) - return false; - // there have to be at least 2 incident faces at v0 if (mesh_.cw_rotated_halfedge_handle( mesh_.cw_rotated_halfedge_handle(_ci.v0v1)) == _ci.v0v1)