From d1567ba44ce85ba11eaf715e9cfd00dbf8e04ac8 Mon Sep 17 00:00:00 2001 From: artem-ogre Date: Thu, 28 Sep 2023 09:20:17 +0200 Subject: [PATCH] #139 Add a regression test --- CDT/tests/cdt.test.cpp | 30 +++++++++++++ ...gingIntersection__f64_auto_resolve_all.txt | 42 +++++++++++++++++++ CDT/tests/inputs/HangingIntersection.txt | 10 +++++ visualizer/data/HangingIntersection.txt | 10 +++++ 4 files changed, 92 insertions(+) create mode 100644 CDT/tests/expected/HangingIntersection__f64_auto_resolve_all.txt create mode 100644 CDT/tests/inputs/HangingIntersection.txt create mode 100644 visualizer/data/HangingIntersection.txt diff --git a/CDT/tests/cdt.test.cpp b/CDT/tests/cdt.test.cpp index 6d1391bc..a2d83805 100644 --- a/CDT/tests/cdt.test.cpp +++ b/CDT/tests/cdt.test.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include using namespace CDT; @@ -782,3 +783,32 @@ TEST_CASE("Don't flip constraint edge when resolving intersection", "") REQUIRE(topologyString(cdt) == topologyString(outFile)); } } + +TEST_CASE( + "Regression: resolving edges intersection with a hanging edge in a " + "pseudo-polygon", + "") +{ + const auto inputFile = std::string("HangingIntersection.txt"); + const auto order = VertexInsertionOrder::Auto; + const auto intersectingEdgesStrategy = IntersectingConstraintEdges::Resolve; + const auto minDistToConstraintEdge = 1e-6; + const auto outFile = "expected/" + + inputFile.substr(0, inputFile.size() - 4) + "__f64_" + + to_string(order) + "_" + + to_string(intersectingEdgesStrategy) + "_all.txt"; + + const auto [vv, ee] = readInputFromFile("inputs/" + inputFile); + auto cdt = Triangulation( + order, intersectingEdgesStrategy, minDistToConstraintEdge); + cdt.insertVertices(vv); + cdt.insertEdges(ee); + REQUIRE(CDT::verifyTopology(cdt)); + + if(updateFiles) + topologyToFile(outFile, cdt); + else + { + REQUIRE(topologyString(cdt) == topologyString(outFile)); + } +} diff --git a/CDT/tests/expected/HangingIntersection__f64_auto_resolve_all.txt b/CDT/tests/expected/HangingIntersection__f64_auto_resolve_all.txt new file mode 100644 index 00000000..094c66bf --- /dev/null +++ b/CDT/tests/expected/HangingIntersection__f64_auto_resolve_all.txt @@ -0,0 +1,42 @@ +17 +0 1 6 4294967295 5 3 +0 3 2 2 7 4294967295 +0 4 3 3 9 1 +0 6 4 0 12 2 +1 2 8 4294967295 8 6 +1 7 6 6 14 0 +1 8 7 4 15 5 +2 3 9 1 10 8 +2 9 8 7 16 4 +3 4 10 2 12 11 +3 5 9 11 13 7 +3 10 5 9 13 10 +4 6 10 3 14 9 +5 10 9 11 16 10 +6 7 10 5 15 12 +7 8 10 6 16 14 +8 9 10 8 13 15 + +4 +3 10 +6 10 +7 10 +8 10 + +2 +6 10 0 +8 10 0 + +4 +3 10 + 1 + 3 7 +6 10 + 1 + 6 8 +7 10 + 1 + 3 7 +8 10 + 1 + 6 8 diff --git a/CDT/tests/inputs/HangingIntersection.txt b/CDT/tests/inputs/HangingIntersection.txt new file mode 100644 index 00000000..a006e505 --- /dev/null +++ b/CDT/tests/inputs/HangingIntersection.txt @@ -0,0 +1,10 @@ +7 2 +725.0 415.0 +855.0 390.0 +945.0 455.0 +1100.0 373.0 +1215.0 410.0 +1250.0 510.0 +943.0 540.0 +3 5 +0 4 \ No newline at end of file diff --git a/visualizer/data/HangingIntersection.txt b/visualizer/data/HangingIntersection.txt new file mode 100644 index 00000000..a006e505 --- /dev/null +++ b/visualizer/data/HangingIntersection.txt @@ -0,0 +1,10 @@ +7 2 +725.0 415.0 +855.0 390.0 +945.0 455.0 +1100.0 373.0 +1215.0 410.0 +1250.0 510.0 +943.0 540.0 +3 5 +0 4 \ No newline at end of file