From e9a0913eeef34d68e4ccfc4b8331e69870b8f329 Mon Sep 17 00:00:00 2001 From: cignoni Date: Mon, 10 Dec 2012 09:39:44 +0000 Subject: [PATCH] Added edge selection management in edge selection stack --- vcg/complex/algorithms/update/selection.h | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/vcg/complex/algorithms/update/selection.h b/vcg/complex/algorithms/update/selection.h index c9a04102..733632d6 100644 --- a/vcg/complex/algorithms/update/selection.h +++ b/vcg/complex/algorithms/update/selection.h @@ -38,7 +38,8 @@ template class SelectionStack { typedef typename ComputeMeshType::template PerVertexAttributeHandle< bool > vsHandle; - typedef typename ComputeMeshType::template PerFaceAttributeHandle< bool > fsHandle; + typedef typename ComputeMeshType::template PerEdgeAttributeHandle< bool > esHandle; + typedef typename ComputeMeshType::template PerFaceAttributeHandle< bool > fsHandle; public: SelectionStack(ComputeMeshType &m) @@ -49,16 +50,22 @@ public: bool push() { vsHandle vsH = Allocator::template AddPerVertexAttribute< bool >(*_m); + esHandle esH = Allocator::template AddPerEdgeAttribute< bool >(*_m); fsHandle fsH = Allocator::template AddPerFaceAttribute< bool > (*_m); typename ComputeMeshType::VertexIterator vi; for(vi = _m->vert.begin(); vi != _m->vert.end(); ++vi) if( !(*vi).IsD() ) vsH[*vi] = (*vi).IsS() ; + typename ComputeMeshType::EdgeIterator ei; + for(ei = _m->edge.begin(); ei != _m->edge.end(); ++ei) + if( !(*ei).IsD() ) esH[*ei] = (*ei).IsS() ; + typename ComputeMeshType::FaceIterator fi; for(fi = _m->face.begin(); fi != _m->face.end(); ++fi) if( !(*fi).IsD() ) fsH[*fi] = (*fi).IsS() ; vsV.push_back(vsH); + esV.push_back(esH); fsV.push_back(fsH); return true; } @@ -67,6 +74,7 @@ public: { if(vsV.empty()) return false; vsHandle vsH = vsV.back(); + esHandle esH = esV.back(); fsHandle fsH = fsV.back(); if(! (Allocator::template IsValidHandle(*_m, vsH))) return false; @@ -77,6 +85,14 @@ public: if(vsH[*vi]) (*vi).SetS() ; else (*vi).ClearS() ; } + + typename ComputeMeshType::EdgeIterator ei; + for(ei = _m->edge.begin(); ei != _m->edge.end(); ++ei) + if( !(*ei).IsD() ) + { + if(esH[*ei]) (*ei).SetS() ; + else (*ei).ClearS() ; + } typename ComputeMeshType::FaceIterator fi; for(fi = _m->face.begin(); fi != _m->face.end(); ++fi) if( !(*fi).IsD() ) @@ -86,8 +102,10 @@ public: } Allocator::template DeletePerVertexAttribute(*_m,vsH); + Allocator::template DeletePerEdgeAttribute(*_m,esH); Allocator::template DeletePerFaceAttribute(*_m,fsH); vsV.pop_back(); + esV.pop_back(); fsV.pop_back(); return true; } @@ -95,6 +113,7 @@ public: private: ComputeMeshType *_m; std::vector vsV; + std::vector esV; std::vector fsV; };