From 58245aecd9d7eca10f75ecbace8544bef44ecf27 Mon Sep 17 00:00:00 2001 From: mikamikasuki <211269698+mikamikasuki@users.noreply.github.com> Date: Fri, 2 Oct 2026 05:54:59 -0700 Subject: [PATCH] Align right join tolerance with left joins --- CPP/Clipper2Lib/src/clipper.engine.cpp | 2 +- CPP/Tests/TestPolygons.cpp | 26 +++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/CPP/Clipper2Lib/src/clipper.engine.cpp b/CPP/Clipper2Lib/src/clipper.engine.cpp index 6442c96ad..9578457a5 100644 --- a/CPP/Clipper2Lib/src/clipper.engine.cpp +++ b/CPP/Clipper2Lib/src/clipper.engine.cpp @@ -2839,7 +2839,7 @@ namespace Clipper2Lib { if (check_curr_x) { - if (PerpendicDistFromLineSqrd(pt, next->bot, next->top) > 0.35) return; + if (PerpendicDistFromLineSqrd(pt, next->bot, next->top) > 0.25) return; } else if (e.curr_x != next->curr_x) return; if (!IsCollinear(e.top, pt, next->top)) return; diff --git a/CPP/Tests/TestPolygons.cpp b/CPP/Tests/TestPolygons.cpp index 4894ff7fb..3d5fee3c9 100644 --- a/CPP/Tests/TestPolygons.cpp +++ b/CPP/Tests/TestPolygons.cpp @@ -1,3 +1,4 @@ +#include #include #include "clipper2/clipper.h" #include "ClipFileLoad.h" @@ -109,6 +110,29 @@ TEST(Clipper2Tests, TestHorzSpikes) //#720 EXPECT_GE(paths.size(), 1); } +TEST(Clipper2Tests, TestIssue1111PreservesNearPancakeVertex) +{ + using namespace Clipper2Lib; + Path64 path = { + Point64(10000000, 3), Point64(0, 2), Point64(1000000, -3229328), + Point64(0, 0), Point64(-20000000, 3), Point64(-20000000, -70000000), + Point64(10000000, -70000000) + }; + + Clipper64 clipper; + clipper.AddSubject({ path }); + Paths64 solution; + ASSERT_TRUE(clipper.Execute(ClipType::Union, FillRule::Positive, solution)); + + const bool contains_moving_vertex = std::any_of(solution.begin(), solution.end(), + [](const Path64& polygon) + { + return std::any_of(polygon.begin(), polygon.end(), [](const Point64& point) + { return point.x == 1000000 && point.y == -3229328; }); + }); + EXPECT_TRUE(contains_moving_vertex); +} + TEST(Clipper2Tests, TestCollinearOnMacOs) //#777 { Clipper2Lib::Paths64 subject; @@ -122,4 +146,4 @@ TEST(Clipper2Tests, TestCollinearOnMacOs) //#777 ASSERT_EQ(solution.size(), 1); EXPECT_EQ(solution[0].size(), 3); EXPECT_EQ(IsPositive(subject[0]), IsPositive(solution[0])); -} \ No newline at end of file +}