From 412ef1aa65987713c03b353a968d09006671145c Mon Sep 17 00:00:00 2001 From: cignoni Date: Wed, 14 Dec 2011 08:54:54 +0000 Subject: [PATCH] Added UpdateSelection::VertexFromEdgeLoose added parameter for preserving the old selection to the UpdateSelection::VertexFromFaceLoose --- vcg/complex/algorithms/update/selection.h | 39 ++++++++++++++++------- 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/vcg/complex/algorithms/update/selection.h b/vcg/complex/algorithms/update/selection.h index 73d37f20..7ab93406 100644 --- a/vcg/complex/algorithms/update/selection.h +++ b/vcg/complex/algorithms/update/selection.h @@ -229,13 +229,13 @@ static size_t VertexInvert(MeshType &m) } /// \brief Select all the vertices that are touched by at least a single selected faces -static size_t VertexFromFaceLoose(MeshType &m) +static size_t VertexFromFaceLoose(MeshType &m, bool preserveSelection=false) { size_t selCnt=0; - VertexClear(m); - FaceIterator fi; - for(fi = m.face.begin(); fi != m.face.end(); ++fi) - if( !(*fi).IsD() && (*fi).IsS()) + + if(!preserveSelection) VertexClear(m); + for(FaceIterator fi = m.face.begin(); fi != m.face.end(); ++fi) + if( !(*fi).IsD() && (*fi).IsS()) { if( !(*fi).V(0)->IsS()) { (*fi).V(0)->SetS(); ++selCnt; } if( !(*fi).V(1)->IsS()) { (*fi).V(1)->SetS(); ++selCnt; } @@ -244,22 +244,37 @@ static size_t VertexFromFaceLoose(MeshType &m) return selCnt; } +/// \brief Select all the vertices that are touched by at least a single selected edge +static size_t VertexFromEdgeLoose(MeshType &m, bool preserveSelection=false) +{ + size_t selCnt=0; + + if(!preserveSelection) VertexClear(m); + for(EdgeIterator ei = m.edge.begin(); ei != m.edge.end(); ++ei) + if( !(*ei).IsD() && (*ei).IsS()) + { + if( !(*ei).V(0)->IsS()) { (*ei).V(0)->SetS(); ++selCnt; } + if( !(*ei).V(1)->IsS()) { (*ei).V(1)->SetS(); ++selCnt; } + } + return selCnt; +} + /// \brief Select ONLY the vertices that are touched ONLY by selected faces /** In other words all the vertices having all the faces incident on them selected. \warning Isolated vertices will not selected. */ static size_t VertexFromFaceStrict(MeshType &m) { - VertexFromFaceLoose(m); + VertexFromFaceLoose(m); FaceIterator fi; - for(fi = m.face.begin(); fi != m.face.end(); ++fi) - if( !(*fi).IsD() && !(*fi).IsS()) + for(fi = m.face.begin(); fi != m.face.end(); ++fi) + if( !(*fi).IsD() && !(*fi).IsS()) { - (*fi).V(0)->ClearS(); - (*fi).V(1)->ClearS(); - (*fi).V(2)->ClearS(); + (*fi).V(0)->ClearS(); + (*fi).V(1)->ClearS(); + (*fi).V(2)->ClearS(); } - return CountVertex(m); + return VertexCount(m); } /// \brief Select ONLY the faces with ALL the vertices selected