From cfb9af64f7d19ca9d4ffb1e1198f253a906abe07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Fri, 19 Jun 2020 15:54:39 +0200 Subject: [PATCH] Fixed runaway selection --- .../Tools/Decimater/DecimaterT_impl.hh | 69 ++++++++++--------- 1 file changed, 35 insertions(+), 34 deletions(-) diff --git a/src/OpenMesh/Tools/Decimater/DecimaterT_impl.hh b/src/OpenMesh/Tools/Decimater/DecimaterT_impl.hh index 48033a92..ff5e7f6e 100644 --- a/src/OpenMesh/Tools/Decimater/DecimaterT_impl.hh +++ b/src/OpenMesh/Tools/Decimater/DecimaterT_impl.hh @@ -144,13 +144,13 @@ void DecimaterT::heap_vertex(VertexHandle _vh) { mesh_.property(priority_, _vh) = -1; } } - -//----------------------------------------------------------------------------- -template -size_t DecimaterT::decimate(size_t _n_collapses, bool _only_selected) { - - if (!this->is_initialized()) - return 0; + +//----------------------------------------------------------------------------- +template +size_t DecimaterT::decimate(size_t _n_collapses, bool _only_selected) { + + if (!this->is_initialized()) + return 0; typename Mesh::VertexHandle vp; typename Mesh::HalfedgeHandle v0v1; @@ -234,16 +234,17 @@ size_t DecimaterT::decimate(size_t _n_collapses, bool _only_selected) { // update heap (former one ring of decimated vertex) for (s_it = support.begin(), s_end = support.end(); s_it != s_end; ++s_it) { - assert(!mesh_.status(*s_it).deleted()); - heap_vertex(*s_it); - } - - // notify observer and stop if the observer requests it - if (!this->notify_observer(n_collapses)) - return n_collapses; - } - - // delete heap + assert(!mesh_.status(*s_it).deleted()); + if (!_only_selected || mesh_.status(*s_it).selected() ) + heap_vertex(*s_it); + } + + // notify observer and stop if the observer requests it + if (!this->notify_observer(n_collapses)) + return n_collapses; + } + + // delete heap heap_.reset(); @@ -252,13 +253,13 @@ size_t DecimaterT::decimate(size_t _n_collapses, bool _only_selected) { return n_collapses; } -//----------------------------------------------------------------------------- - -template -size_t DecimaterT::decimate_to_faces(size_t _nv, size_t _nf, bool _only_selected) { - - if (!this->is_initialized()) - return 0; +//----------------------------------------------------------------------------- + +template +size_t DecimaterT::decimate_to_faces(size_t _nv, size_t _nf, bool _only_selected) { + + if (!this->is_initialized()) + return 0; if (_nv >= mesh_.n_vertices() || _nf >= mesh_.n_faces()) return 0; @@ -345,16 +346,16 @@ size_t DecimaterT::decimate_to_faces(size_t _nv, size_t _nf, bool _only_se // update heap (former one ring of decimated vertex) for (s_it = support.begin(), s_end = support.end(); s_it != s_end; ++s_it) { - assert(!mesh_.status(*s_it).deleted()); - heap_vertex(*s_it); - } - - // notify observer and stop if the observer requests it - if (!this->notify_observer(n_collapses)) - return n_collapses; - } - - // delete heap + assert(!mesh_.status(*s_it).deleted()); + heap_vertex(*s_it); + } + + // notify observer and stop if the observer requests it + if (!this->notify_observer(n_collapses)) + return n_collapses; + } + + // delete heap heap_.reset();