From 6c365672aff47e036b717a6dad4e10f67b6c3fed Mon Sep 17 00:00:00 2001 From: artem-ogre Date: Tue, 6 Jul 2021 21:56:42 +0200 Subject: [PATCH] #37 Fix bug in "is flip needed" test (isFlipNeeded) 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. --- CDT/include/CDT.hpp | 13 +++++-- .../data/regression_issue_38_wrong_hull.txt | 37 +++++++++++++++++++ .../regression_issue_38_wrong_hull_small.txt | 7 ++++ 3 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 visualizer/data/regression_issue_38_wrong_hull.txt create mode 100644 visualizer/data/regression_issue_38_wrong_hull_small.txt diff --git a/CDT/include/CDT.hpp b/CDT/include/CDT.hpp index bfce9db1..ddbe08bf 100644 --- a/CDT/include/CDT.hpp +++ b/CDT/include/CDT.hpp @@ -451,9 +451,6 @@ bool Triangulation::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& v1 = vertices[iVcw].pos; @@ -461,6 +458,16 @@ bool Triangulation::isFlipNeeded( const V2d& 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) diff --git a/visualizer/data/regression_issue_38_wrong_hull.txt b/visualizer/data/regression_issue_38_wrong_hull.txt new file mode 100644 index 00000000..f1e4ca03 --- /dev/null +++ b/visualizer/data/regression_issue_38_wrong_hull.txt @@ -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 \ No newline at end of file diff --git a/visualizer/data/regression_issue_38_wrong_hull_small.txt b/visualizer/data/regression_issue_38_wrong_hull_small.txt new file mode 100644 index 00000000..669f636e --- /dev/null +++ b/visualizer/data/regression_issue_38_wrong_hull_small.txt @@ -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 \ No newline at end of file