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 circumcircle test as a tie-breaker.

Add two test files for regression testing.
  • Loading branch information
artem-ogre committed Jul 9, 2021
1 parent c1da496 commit 6c36567
Show file tree
Hide file tree
Showing 3 changed files with 54 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
37 changes: 37 additions & 0 deletions visualizer/data/regression_issue_38_wrong_hull.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
36 0
0.15147567518991 -5.144230291488
0.10442 -5.06098
0.1228735248885 -5.12897066233
0.1322969035965 -5.141286788425
0.115882234089 -5.115648852375
0.13262891777369 -5.119598039304
0.11311813200326 -5.138343285364
0.111139345548 -5.09040217055
0.121648346645 -5.09478239621
0.1152696449675 -5.098554719315
0.1303134549875 -5.106097900345
0.10889094329024 -5.1023270424231
0.142052296482 -5.131914165395
0.154751587595 -5.127544895745
0.1484019420385 -5.129729530575
0.1389785633305 -5.117413404475
0.1563895437975 -5.119202197875
0.150039898241 -5.1213868327
0.140515429906 -5.12466378494
0.145328208887 -5.11522876965
0.1516778544435 -5.113044134825
0.1580275 -5.1108595
0.107779672774 -5.075691085275
0.112085873903 -5.07104664934
0.1514750401785 -5.061655309135
0.13440575 -5.08723775
0.110784 -5.063616
0.11338774780615 -5.078477298681
0.1682004187975 -5.131013072875
0.18164925 -5.13448125
0.1921660803575 -5.05969461827
0.1750967901785 -5.085277059135
0.221046245536 -5.045923052405
0.31820357142857 -4.9298217230895
0.2499264107145 -5.032151486545
0.284064991072 -4.980986604815
7 changes: 7 additions & 0 deletions visualizer/data/regression_issue_38_wrong_hull_small.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
6 0
0.15147567518991 -5.144230291488
0.10442 -5.06098
0.1228735248885 -5.12897066233
0.1322969035965 -5.141286788425
0.115882234089 -5.115648852375
0.13262891777369 -5.119598039304

0 comments on commit 6c36567

Please sign in to comment.