Skip to content

Commit

Permalink
#139 Add a regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-ogre committed Sep 28, 2023
1 parent 556dbf1 commit 2cef8d4
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 0 deletions.
29 changes: 29 additions & 0 deletions CDT/tests/cdt.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -782,3 +782,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<double>("inputs/" + inputFile);
auto cdt = Triangulation<double>(
order, intersectingEdgesStrategy, minDistToConstraintEdge);
cdt.insertVertices(vv);
cdt.insertEdges(ee);
REQUIRE(CDT::verifyTopology(cdt));

if(updateFiles)
topologyToFile(outFile, cdt);
else
{
REQUIRE(topologyString(cdt) == topologyString(outFile));
}
}
42 changes: 42 additions & 0 deletions CDT/tests/expected/HangingIntersection__f64_auto_resolve_all.txt
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions CDT/tests/inputs/HangingIntersection.txt
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions visualizer/data/HangingIntersection.txt
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 2cef8d4

Please sign in to comment.