Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CPP/Clipper2Lib/src/clipper.engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
26 changes: 25 additions & 1 deletion CPP/Tests/TestPolygons.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <algorithm>
#include <gtest/gtest.h>
#include "clipper2/clipper.h"
#include "ClipFileLoad.h"
Expand Down Expand Up @@ -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;
Expand All @@ -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]));
}
}