Skip to content

Commit

Permalink
#37 Fix bug in "is flip needed" test (isFlipNeeded)
Browse files Browse the repository at this point in the history
Previously flip was rejected only if both vertices of flip-candidate belong to the super-tri.
The change rejects the flip if at least one vertex belongs to super-tri and original edge does not touch super-tri.
If both original edge and flipped edge touch super-tri: use normal circumference test as a tie-breaker.
  • Loading branch information
artem-ogre committed Jul 6, 2021
1 parent c1da496 commit 42061fe
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions CDT/include/CDT.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,16 +451,23 @@ bool Triangulation<T>::isFlipNeeded(
const Triangle& tOpo = triangles[iTopo];
const Index i = opposedVertexInd(tOpo, iT);
const VertInd iVopo = tOpo.vertices[i];
if(m_superGeomType == SuperGeometryType::SuperTriangle)
if(iVert < 3 && iVopo < 3) // opposed vertices belong to super-triangle
return false; // no flip is needed
const VertInd iVcw = tOpo.vertices[cw(i)];
const VertInd iVccw = tOpo.vertices[ccw(i)];
const V2d<T>& v1 = vertices[iVcw].pos;
const V2d<T>& v2 = vertices[iVopo].pos;
const V2d<T>& v3 = vertices[iVccw].pos;
if(m_superGeomType == SuperGeometryType::SuperTriangle)
{
if(iVert < 3 || iVopo < 3) // flip-candidate edge touches super-triangle
{
if(iVcw < 3 || iVccw < 3) // but so does original edge
{
// let the normal circumcircle test decide
return isInCircumcircle(pos, v1, v2, v3);
}
return false; // no flip is needed
}

if(iVcw < 3)
return locatePointLine(v1, v2, v3) == locatePointLine(pos, v2, v3);
if(iVccw < 3)
Expand Down

0 comments on commit 42061fe

Please sign in to comment.