From aeba5d604c757977bc0cb98fa8af7d6937987b6e Mon Sep 17 00:00:00 2001 From: Erica Fischer Date: Fri, 23 Feb 2024 09:32:25 -0800 Subject: [PATCH] Intersecting only at endpoints is fine and doesn't require any work --- polygon.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/polygon.cpp b/polygon.cpp index 018c9805..c2c94bc6 100644 --- a/polygon.cpp +++ b/polygon.cpp @@ -265,6 +265,11 @@ bool intersect_collinear(std::vector &segs, size_t s1, size_t s2) { } bool intersect(std::vector &segs, size_t s1, size_t s2) { + if ((segs[s1].first == segs[s2].second && segs[s1].second != segs[s2].first) || + (segs[s1].first != segs[s2].second && segs[s1].second == segs[s2].first)) { + return true; // they intersect only at one endpoint; nothing to do + } + auto intersections = get_line_intersection(segs[s1].first.x, segs[s1].first.y, segs[s1].second.x, segs[s1].second.y, segs[s2].first.x, segs[s2].first.y, @@ -398,7 +403,7 @@ void snap_round(std::vector &segs, long long extent) { std::sort(transitions.begin(), transitions.end()); for (size_t i = 0; i < transitions.size(); i++) { - printf("transition %zu: y %lld, kind %d, seg %zu\n", i, transitions[i].y, transitions[i].kind, transitions[i].segment); + // printf("transition %zu: y %lld, kind %d, seg %zu\n", i, transitions[i].y, transitions[i].kind, transitions[i].segment); } // do the scan