From b5bb9ff2ba5ff1e1143b10a1a310996044c016d1 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Wed, 23 Mar 2016 15:46:16 +0100 Subject: [PATCH] Factorisation and fix for connected components. --- .../Scene_polyhedron_selection_item.cpp | 61 ++++++++----------- .../Scene_polyhedron_selection_item.h | 7 ++- 2 files changed, 30 insertions(+), 38 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.cpp b/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.cpp index 1384a435aa0..7d40666e6ea 100644 --- a/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.cpp @@ -674,6 +674,23 @@ void Scene_polyhedron_selection_item::set_operation_mode(int mode) } operation_mode = mode; } +template +bool Scene_polyhedron_selection_item::treat_classic_selection(const HandleRange& selection) +{ + typedef typename HandleRange::value_type HandleType; + Selection_traits tr(this); + bool any_change = false; + if(is_insert) { + BOOST_FOREACH(HandleType h, selection) + any_change |= tr.container().insert(h).second; + } + else{ + BOOST_FOREACH(HandleType h, selection) + any_change |= (tr.container().erase(h)!=0); + } + if(any_change) { invalidateOpenGLBuffers(); Q_EMIT itemChanged(); } + return any_change; +} bool Scene_polyhedron_selection_item::treat_selection(const std::set& selection) { @@ -686,18 +703,7 @@ bool Scene_polyhedron_selection_item::treat_selection(const std::set& selection) +{ + return treat_classic_selection(selection); +} + bool Scene_polyhedron_selection_item::treat_selection(const std::set& selection) { if(!is_treated) @@ -1220,18 +1220,7 @@ bool Scene_polyhedron_selection_item::treat_selection(const std::set bool treat_selection(const HandleRange&) { - qDebug()<<"ERROR : unknown range"; + qDebug()<<"ERROR : unknown HandleRange"; return false; } - +template + bool treat_classic_selection(const HandleRange& selection); //Specialization for set bool treat_selection(const std::set& selection); bool treat_selection(const std::set& selection); bool treat_selection(const std::set& selection); + bool treat_selection(const std::vector& selection); + Facet_handle face(Facet_handle fh) { return fh; }