added splitinmanifoldComponents
This commit is contained in:
parent
b584642c84
commit
3449199f07
|
@ -33,6 +33,7 @@
|
|||
#include <vcg/space/index/spatial_hashing.h>
|
||||
#include <vcg/complex/algorithms/update/normal.h>
|
||||
#include <vcg/space/triangle3.h>
|
||||
#include <vcg/complex/append.h>
|
||||
|
||||
namespace vcg {
|
||||
namespace tri{
|
||||
|
@ -634,7 +635,8 @@ public:
|
|||
do
|
||||
{
|
||||
faceSet.insert(std::make_pair(curPos.F(),curPos.VInd()));
|
||||
curPos.NextE();
|
||||
curPos.FlipE();
|
||||
curPos.NextF();
|
||||
} while (curPos != startPos);
|
||||
|
||||
ToSplitVec.push_back(make_pair((*fi).V(i),std::vector<FaceInt>()));
|
||||
|
@ -671,6 +673,59 @@ public:
|
|||
return int(ToSplitVec.size());
|
||||
}
|
||||
|
||||
/// \brief This function expand current selection to cover the whole connected component.
|
||||
static size_t SplitManifoldComponents(MeshType &m)
|
||||
{
|
||||
typedef typename MeshType::FacePointer FacePointer;
|
||||
typedef typename MeshType::FaceIterator FaceIterator;
|
||||
// it also assumes that the FF adjacency is well computed.
|
||||
RequireFFAdjacency(m);
|
||||
|
||||
UpdateFlags<MeshType>::FaceClearV(m);
|
||||
UpdateFlags<MeshType>::FaceClearS(m);
|
||||
|
||||
MeshType tmpMesh;
|
||||
|
||||
size_t selCnt=0;
|
||||
|
||||
for(FaceIterator fi = m.face.begin(); fi != m.face.end(); ++fi)
|
||||
if( !(*fi).IsD() && !(*fi).IsV() )
|
||||
{
|
||||
UpdateFlags<MeshType>::FaceClearS(m);
|
||||
|
||||
std::deque<FacePointer> visitStack;
|
||||
visitStack.push_back(&*fi);
|
||||
|
||||
while(!visitStack.empty())
|
||||
{
|
||||
FacePointer fp = visitStack.front();
|
||||
visitStack.pop_front();
|
||||
|
||||
fp->Q() = selCnt;
|
||||
fp->SetS();
|
||||
|
||||
assert(!fp->IsV());
|
||||
fp->SetV();
|
||||
|
||||
for(int i=0;i<fp->VN();++i) {
|
||||
FacePointer ff = fp->FFp(i);
|
||||
|
||||
if(face::IsManifold(*fp, i) && !ff->IsS())
|
||||
{
|
||||
visitStack.push_back(ff);
|
||||
assert(!ff->IsV());
|
||||
}
|
||||
}
|
||||
}
|
||||
Append<MeshType, MeshType>::Mesh(tmpMesh, m, true);
|
||||
++selCnt;
|
||||
}
|
||||
|
||||
UpdateSelection<MeshType>::Clear(tmpMesh);
|
||||
Append<MeshType, MeshType>::MeshCopy(m, tmpMesh);
|
||||
return selCnt;
|
||||
}
|
||||
|
||||
|
||||
// Auxiliary function for sorting the non manifold faces according to their area. Used in RemoveNonManifoldFace
|
||||
struct CompareAreaFP {
|
||||
|
|
Loading…
Reference in New Issue