From 79783ac1bbccd19ed8175a8a8e08e8e91caa3593 Mon Sep 17 00:00:00 2001 From: cignoni Date: Wed, 16 Jun 2010 11:40:14 +0000 Subject: [PATCH] Moved the removal of faces with edges outside a given range to a selection function into UpdateSelection<>:: --- vcg/complex/trimesh/clean.h | 29 ------------------- vcg/complex/trimesh/update/selection.h | 39 +++++++++++++++++--------- 2 files changed, 25 insertions(+), 43 deletions(-) diff --git a/vcg/complex/trimesh/clean.h b/vcg/complex/trimesh/clean.h index ee178f75..25f3679f 100644 --- a/vcg/complex/trimesh/clean.h +++ b/vcg/complex/trimesh/clean.h @@ -434,30 +434,6 @@ private: } return count_fd; } - template - static int RemoveFaceOutOfRangeEdgeSel( MeshType& m, ScalarType MinEdgeThr=0, ScalarType MaxEdgeThr=(std::numeric_limits::max)()) - { - FaceIterator fi; - int count_fd = 0; - MinEdgeThr=MinEdgeThr*MinEdgeThr; - MaxEdgeThr=MaxEdgeThr*MaxEdgeThr; - for(fi=m.face.begin(); fi!=m.face.end();++fi) - if(!(*fi).IsD()) - if(!Selected || (*fi).IsS()) - { - for(unsigned int i=0;i<3;++i) - { - const ScalarType squaredEdge=SquaredDistance((*fi).V0(i)->cP(),(*fi).V1(i)->cP()); - if((squaredEdge<=MinEdgeThr) || (squaredEdge>=MaxEdgeThr) ) - { - count_fd++; - Allocator::DeleteFace(m,*fi); - break; // skip the rest of the edges of the tri - } - } - } - return count_fd; - } // alias for the old style. Kept for backward compatibility static int RemoveZeroAreaFace(MeshType& m) { return RemoveFaceOutOfRangeArea(m);} @@ -467,11 +443,6 @@ private: { return RemoveFaceOutOfRangeAreaSel(m,MinAreaThr,MaxAreaThr); } - static int RemoveFaceOutOfRangeEdge(MeshType& m, ScalarType MinEdgeThr=0, ScalarType MaxEdgeThr=(std::numeric_limits::max)()) - { - return RemoveFaceOutOfRangeEdgeSel(m,MinEdgeThr,MaxEdgeThr); - } - /** * Is the mesh only composed by quadrilaterals? diff --git a/vcg/complex/trimesh/update/selection.h b/vcg/complex/trimesh/update/selection.h index 9922eb11..fb83c5f2 100644 --- a/vcg/complex/trimesh/update/selection.h +++ b/vcg/complex/trimesh/update/selection.h @@ -19,20 +19,6 @@ * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * * for more details. * * * -****************************************************************************/ -/**************************************************************************** - History - -$Log: not supported by cvs2svn $ -Revision 1.3 2007/04/20 10:11:51 cignoni -Corrected bug in selectionVertexFromFaceStrict - -Revision 1.2 2007/02/01 06:37:05 cignoni -Added FaceFromBorder - -Revision 1.1 2006/10/16 08:50:58 cignoni -First Working Version - ****************************************************************************/ #ifndef __VCG_TRI_UPDATE_SELECTION #define __VCG_TRI_UPDATE_SELECTION @@ -258,6 +244,31 @@ static size_t FaceFromBorderFlag(MeshType &m) } return selCnt; } + +/// \brief This function select the faces that have an edge outside the given range. +static size_t FaceOutOfRangeEdge(MeshType &m, ScalarType MinEdgeThr=0, ScalarType MaxEdgeThr=(std::numeric_limits::max)()) +{ + FaceIterator fi; + size_t count_fd = 0; + MinEdgeThr=MinEdgeThr*MinEdgeThr; + MaxEdgeThr=MaxEdgeThr*MaxEdgeThr; + for(fi=m.face.begin(); fi!=m.face.end();++fi) + if(!(*fi).IsD()) + { + for(unsigned int i=0;i<3;++i) + { + const ScalarType squaredEdge=SquaredDistance((*fi).V0(i)->cP(),(*fi).V1(i)->cP()); + if((squaredEdge<=MinEdgeThr) || (squaredEdge>=MaxEdgeThr) ) + { + count_fd++; + (*fi).SetS(); + break; // skip the rest of the edges of the tri + } + } + } + return count_fd; +} + /// \brief This function expand current selection to cover the whole connected component. static size_t FaceConnectedFF(MeshType &m) {