Again refactored and commented the ExtractPolygon
This commit is contained in:
parent
7c93452e94
commit
34fb35c6c7
|
@ -148,45 +148,52 @@ namespace tri {
|
||||||
if(tri::HasPerFaceQuality(tm) && tri::HasPerFaceQuality(pm)) pfi->Q()=tfi->Q();
|
if(tri::HasPerFaceQuality(tm) && tri::HasPerFaceQuality(pm)) pfi->Q()=tfi->Q();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/// \brief Collect tris and verts of a polygonal face marked by FauxEdges
|
||||||
// Given a facepointer, it build a vector with all the vertex pointer
|
///
|
||||||
// around the polygonal face determined by the current FAUX-EDGE markings
|
/// Given a face pointer, it builds a vector with all the face and vertex pointers
|
||||||
// It assumes that the mesh is 2Manifold and has FF adjacency already computed
|
/// around the polygonal face determined by the current FAUX-EDGE markings.
|
||||||
// NOTE: All the faces touched are marked as visited. (so for example you can avoid to get twice the same polygon)
|
/// It assumes that the mesh is 2Manifold and has FF adjacency already computed
|
||||||
|
/// per face visited flag cleared.
|
||||||
|
/// NOTE: All the faces touched are marked as visited and it assumes that you
|
||||||
|
/// do not call this function on a visited face.
|
||||||
static void ExtractPolygon(typename TriMeshType::FacePointer tfp,
|
static void ExtractPolygon(typename TriMeshType::FacePointer tfp,
|
||||||
std::vector<typename TriMeshType::VertexPointer> &vs,
|
std::vector<typename TriMeshType::VertexPointer> &vs,
|
||||||
std::vector<typename TriMeshType::FacePointer> &fs)
|
std::vector<typename TriMeshType::FacePointer> &fs)
|
||||||
{
|
{
|
||||||
vs.clear();
|
vs.clear();
|
||||||
fs.clear();
|
fs.clear();
|
||||||
// find a non tagged edge
|
// find a non faux edge
|
||||||
int se = -1;
|
int se = -1;
|
||||||
for(int i=0; i<3; i++) if (!( tfp->IsF(i))) { se = i; break;}
|
for(int i=0; i<3; i++) if (!( tfp->IsF(i))) { se = i; break;}
|
||||||
|
|
||||||
// all faux edges return an empty vertex vector!
|
// all faux edges return an empty vertex vector!
|
||||||
if(se==-1) return;
|
if(se==-1) return;
|
||||||
|
if(tfp->IsV()) return;
|
||||||
|
|
||||||
// initialize a pos on the first non faux edge
|
// initialize a pos on the first non faux edge
|
||||||
typename TriMeshType::VertexPointer v0 = tfp->V(se);
|
face::Pos<typename TriMeshType::FaceType> start(tfp,se,tfp->V(se));
|
||||||
|
face::Pos<typename TriMeshType::FaceType> p(start);
|
||||||
|
|
||||||
face::Pos<typename TriMeshType::FaceType> p(tfp,se,v0);
|
fs.push_back(p.F());
|
||||||
face::Pos<typename TriMeshType::FaceType> start(p);
|
p.F()->SetV();
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
assert(!p.F()->IsF(p.E()));
|
assert(!p.F()->IsF(p.E()));
|
||||||
vs.push_back(p.F()->V(p.E()));
|
vs.push_back(p.V());
|
||||||
p.FlipE();
|
p.FlipE();
|
||||||
|
|
||||||
while( p.F()->IsF(p.E()) )
|
while( p.F()->IsF(p.E()) )
|
||||||
{
|
{
|
||||||
if(!p.F()->IsV()) fs.push_back(p.F());
|
|
||||||
p.F()->SetV();
|
|
||||||
p.FlipF();
|
p.FlipF();
|
||||||
|
if(!p.F()->IsV()) {
|
||||||
|
fs.push_back(p.F());
|
||||||
|
p.F()->SetV();
|
||||||
|
}
|
||||||
p.FlipE();
|
p.FlipE();
|
||||||
}
|
}
|
||||||
p.FlipV();
|
p.FlipV();
|
||||||
} while(p!=start);
|
} while(p!=start);
|
||||||
|
assert(vs.size() == fs.size()+2);
|
||||||
}
|
}
|
||||||
static void ExtractPolygon(typename TriMeshType::FacePointer tfp, std::vector<typename TriMeshType::VertexPointer> &vs)
|
static void ExtractPolygon(typename TriMeshType::FacePointer tfp, std::vector<typename TriMeshType::VertexPointer> &vs)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue