Rewrote and commented the function that given a face pointer it follows the chain of non-faux edges. Now it supports the case of meshes with face with ALL edges faux (isolated faces in a polygon).

This commit is contained in:
Paolo Cignoni 2012-05-28 11:30:37 +00:00
parent 6254246a05
commit 75ebfa9d5a
1 changed files with 35 additions and 29 deletions

View File

@ -142,35 +142,41 @@ namespace vcg
} }
} }
static void ExtractPolygon(typename TriMeshType::FacePointer tfi, std::vector<typename TriMeshType::VertexPointer> &vs){ // Given a facepointer, it build a vector with all the vertex pointer
vs.clear(); // around the polygonal face determined by the current FAUX-EDGE markings
// find a non tagged edge // It assumes that the mesh is 2Manifold and has FF adjacency already computed
int se = -1; // NOTE: All the faces touched are marked as visited. (so for example you can avoid to get twice the same polygon)
for(int i=0; i<3; i++) if (!( tfi->IsF(i))) { se = i; break;} static void ExtractPolygon(typename TriMeshType::FacePointer tfp, std::vector<typename TriMeshType::VertexPointer> &vs)
{
vs.clear();
// find a non tagged edge
int se = -1;
for(int i=0; i<3; i++) if (!( tfp->IsF(i))) { se = i; break;}
assert(se!=-1); // else, all faux edges! // all faux edges return an empty vertex vector!
if(se==-1) return;
// initialize a pos on the first non faux edge // initialize a pos on the first non faux edge
typename TriMeshType::VertexPointer v0 = tfi->V(se); typename TriMeshType::VertexPointer v0 = tfp->V(se);
vcg::face::JumpingPos<typename TriMeshType::FaceType> p; vcg::face::Pos<typename TriMeshType::FaceType> p(tfp,se,v0);
vcg::face::Pos<typename TriMeshType::FaceType> start(p);
p.F() = tfi; do
p.E() = se; {
p.V() = p.F()->V(p.F()->Next(se)); assert(!p.F()->IsF(p.E()));
p.FlipE(); vs.push_back(p.F()->V(p.E()));
p.FlipE();
vs.push_back(p.F()->V(se)); while( p.F()->IsF(p.E()) )
{
int guard = 0; p.F()->SetV();
do{ p.FlipF();
while(p.F()->IsF(p.E())) { p.FlipF(); p.FlipE(); p.F()->SetV(); if (guard++>10) break;} p.FlipE();
if (guard++>10) break; }
vs.push_back(p.F()->V(p.E())); p.FlipV();
p.FlipV(); } while(p!=start);
p.FlipE(); }
} while( p.V() != v0 );
}
}; // end of struct }; // end of struct
}} // end namespace vcg::tri }} // end namespace vcg::tri