Refactored a bit CountConnectedComponents (added requiremens)

This commit is contained in:
Paolo Cignoni 2013-03-25 10:33:22 +00:00
parent 6913bc81a7
commit 668bf05a1d
1 changed files with 31 additions and 38 deletions

View File

@ -1066,17 +1066,12 @@ private:
static int ConnectedComponents(MeshType &m, std::vector< std::pair<int,FacePointer> > &CCV)
{
FaceIterator fi;
FacePointer l;
tri::RequireFFAdjacency(m);
CCV.clear();
for(fi=m.face.begin();fi!=m.face.end();++fi)
(*fi).ClearS();
int Compindex=0;
tri::UpdateSelection<MeshType>::FaceClear(m);
std::stack<FacePointer> sf;
FacePointer fpt=&*(m.face.begin());
for(fi=m.face.begin();fi!=m.face.end();++fi)
for(FaceIterator fi=m.face.begin();fi!=m.face.end();++fi)
{
if(!((*fi).IsD()) && !(*fi).IsS())
{
@ -1092,7 +1087,7 @@ private:
{
if( !face::IsBorder(*fpt,j) )
{
l=fpt->FFp(j);
FacePointer l = fpt->FFp(j);
if( !(*l).IsS() )
{
(*l).SetS();
@ -1101,11 +1096,9 @@ private:
}
}
}
Compindex++;
}
}
assert(int(CCV.size())==Compindex);
return Compindex;
return int(CCV.size());
}