improved MarkFauxEdgeWithPolyLine

This commit is contained in:
Paolo Cignoni 2017-12-21 01:16:03 +01:00
parent 975027bcf6
commit 6c2e91b423
1 changed files with 17 additions and 13 deletions

View File

@ -177,13 +177,12 @@ public:
* *
*/ */
bool MarkFauxEdgeWithPolyLine(MeshType &poly) bool MarkFauxEdgeWithPolyLine(MeshType &poly,bool markFlag=true)
{ {
tri::UpdateFlags<MeshType>::FaceSetF(base); if(markFlag) tri::UpdateFlags<MeshType>::FaceSetF(base);
tri::UpdateTopology<MeshType>::VertexFace(base); tri::UpdateTopology<MeshType>::VertexFace(base);
tri::UpdateTopology<MeshType>::FaceFace(base); tri::UpdateTopology<MeshType>::FaceFace(base);
bool ret = true;
for(EdgeIterator ei=poly.edge.begin(); ei!=poly.edge.end();++ei) for(EdgeIterator ei=poly.edge.begin(); ei!=poly.edge.end();++ei)
{ {
CoordType ip0,ip1; CoordType ip0,ip1;
@ -194,23 +193,28 @@ public:
{ {
VertexPointer v0 = FindVertexSnap(f0,ip0); VertexPointer v0 = FindVertexSnap(f0,ip0);
VertexPointer v1 = FindVertexSnap(f1,ip1); VertexPointer v1 = FindVertexSnap(f1,ip1);
assert(v1>0 && v0>0 && v0!=v1); if(v0==0 || v1==0) return false;
if(v0==v1) return false;
FacePointer ff0,ff1; FacePointer ff0,ff1;
int e0,e1; int e0,e1;
ret &= face::FindSharedFaces<FaceType>(v0,v1,ff0,ff1,e0,e1); bool ret=face::FindSharedFaces<FaceType>(v0,v1,ff0,ff1,e0,e1);
if(ret) { if(ret){
assert(ret);
assert(ff0->V(e0)==v0 || ff0->V(e0)==v1); assert(ff0->V(e0)==v0 || ff0->V(e0)==v1);
ff0->ClearF(e0); ff0->ClearF(e0);
ff1->ClearF(e1); ff1->ClearF(e1);
} }
} else {
else return false;
{
assert(0);
} }
} }
return ret; else {
return false;
} }
}
return true;
}
ScalarType MinDistOnEdge(CoordType samplePnt, EdgeGrid &edgeGrid, MeshType &poly, CoordType &closestPoint) ScalarType MinDistOnEdge(CoordType samplePnt, EdgeGrid &edgeGrid, MeshType &poly, CoordType &closestPoint)
{ {