Refactored a bit CountConnectedComponents (added requiremens)
This commit is contained in:
parent
6913bc81a7
commit
668bf05a1d
|
@ -1064,49 +1064,42 @@ private:
|
||||||
return ConnectedComponents(m,CCV);
|
return ConnectedComponents(m,CCV);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ConnectedComponents(MeshType &m, std::vector< std::pair<int,FacePointer> > &CCV)
|
static int ConnectedComponents(MeshType &m, std::vector< std::pair<int,FacePointer> > &CCV)
|
||||||
{
|
{
|
||||||
FaceIterator fi;
|
tri::RequireFFAdjacency(m);
|
||||||
FacePointer l;
|
CCV.clear();
|
||||||
CCV.clear();
|
tri::UpdateSelection<MeshType>::FaceClear(m);
|
||||||
|
|
||||||
for(fi=m.face.begin();fi!=m.face.end();++fi)
|
|
||||||
(*fi).ClearS();
|
|
||||||
|
|
||||||
int Compindex=0;
|
|
||||||
std::stack<FacePointer> sf;
|
std::stack<FacePointer> sf;
|
||||||
FacePointer fpt=&*(m.face.begin());
|
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())
|
if(!((*fi).IsD()) && !(*fi).IsS())
|
||||||
{
|
{
|
||||||
(*fi).SetS();
|
(*fi).SetS();
|
||||||
CCV.push_back(std::make_pair(0,&*fi));
|
CCV.push_back(std::make_pair(0,&*fi));
|
||||||
sf.push(&*fi);
|
sf.push(&*fi);
|
||||||
while (!sf.empty())
|
while (!sf.empty())
|
||||||
{
|
{
|
||||||
fpt=sf.top();
|
fpt=sf.top();
|
||||||
++CCV.back().first;
|
++CCV.back().first;
|
||||||
sf.pop();
|
sf.pop();
|
||||||
for(int j=0;j<3;++j)
|
for(int j=0;j<3;++j)
|
||||||
{
|
{
|
||||||
if( !face::IsBorder(*fpt,j) )
|
if( !face::IsBorder(*fpt,j) )
|
||||||
{
|
{
|
||||||
l=fpt->FFp(j);
|
FacePointer l = fpt->FFp(j);
|
||||||
if( !(*l).IsS() )
|
if( !(*l).IsS() )
|
||||||
{
|
{
|
||||||
(*l).SetS();
|
(*l).SetS();
|
||||||
sf.push(l);
|
sf.push(l);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Compindex++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
assert(int(CCV.size())==Compindex);
|
}
|
||||||
return Compindex;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return int(CCV.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue