From 1b7adbe035ed199792cbd504a141a0f694d7642b Mon Sep 17 00:00:00 2001 From: cignoni Date: Sat, 12 Sep 2009 05:20:32 +0000 Subject: [PATCH] Hole filling now returns the number of closed holes --- vcg/complex/trimesh/hole.h | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/vcg/complex/trimesh/hole.h b/vcg/complex/trimesh/hole.h index 446877a5..d4542f52 100644 --- a/vcg/complex/trimesh/hole.h +++ b/vcg/complex/trimesh/hole.h @@ -581,24 +581,25 @@ template } template - static void EarCuttingFill(MESH &m, int sizeHole,bool Selected = false, CallBackPos *cb=0) + static int EarCuttingFill(MESH &m, int sizeHole,bool Selected = false, CallBackPos *cb=0) { std::vector< Info > vinfo; int UBIT = GetInfo(m, Selected,vinfo); typename std::vector::iterator ith; //Info app; - int ind=0; - + int indCb=0; + int holeCnt=0; std::vector vfp; for(ith = vinfo.begin(); ith!= vinfo.end(); ++ith) vfp.push_back( &(*ith).p.f ); for(ith = vinfo.begin(); ith!= vinfo.end(); ++ith) { - ind++; - if(cb) (*cb)(ind*100/vinfo.size(),"Closing Holes"); + indCb++; + if(cb) (*cb)(indCb*10/vinfo.size(),"Closing Holes"); if((*ith).size < sizeHole){ + holeCnt++; FillHoleEar< EAR >(m, *ith,UBIT,vfp); } } @@ -609,10 +610,13 @@ template if(!(*fi).IsD()) (*fi).ClearUserBit(UBIT); } + return holeCnt; } +// it returns the number of created holes. + template - static void EarCuttingIntersectionFill(MESH &m, int sizeHole,bool Selected = false) + static int EarCuttingIntersectionFill(MESH &m, int sizeHole, bool Selected = false, CallBackPos *cb=0) { std::vector vinfo; int UBIT = GetInfo(m, Selected,vinfo); @@ -626,12 +630,15 @@ template for(ith = vinfo.begin(); ith!= vinfo.end(); ++ith) vfpOrig.push_back( &(*ith).p.f ); - + int indCb=0; + int holeCnt=0; for(ith = vinfo.begin(); ith!= vinfo.end(); ++ith) { + indCb++; + if(cb) (*cb)(indCb*10/vinfo.size(),"Closing Holes"); if((*ith).size < sizeHole){ std::vector vfp; - + holeCnt++; vfp=vfpOrig; EAR::AdjacencyRing().clear(); //Loops around the hole to collect the races . @@ -662,6 +669,7 @@ template if(!(*fi).IsD()) (*fi).ClearUserBit(UBIT); } + return holeCnt; }