Clipper2: Offset produces incorrect output
Hi, could you please check the attached test, something is wrong with offset:
TEST(Clipper2Tests, TestOffsets5)
{
Paths64 subjects = {
{{-616909947, 520339465}, {-616770911, 519140059}, {-616088223, 516235000},
{-615738591, 515224142}, {-615429468, 514559225}, {-615167287, 514065887},
{-614776478, 513416556}, {-614154420, 512583051}, {-612274666, 510526392},
{-611683294, 509972214}, {-611013578, 509515799}, {-608052680, 507817208},
{-607126678, 507399448}, {-607024767, 507364908}, {-606830072, 507303124},
{-606775561, 507286987}, {-605927010, 507110504}, {-603051565, 506757050},
{-602411915, 506717884}, {-601545978, 506789889}, {-598819464, 507246481},
{-597870106, 507498768}, {-596984472, 507923716}, {-593828452, 509820654},
{-593086024, 510360673}, {-592449173, 511021916}, {-590386749, 513577845},
{-589821895, 514438911}, {-589686472, 514697638}, {-589528201, 515027551},
{-589419699, 515275559}, {-589119787, 516174960}, {-588427237, 519115244},
{-588287588, 520317255}, {-588295425, 520603824}, {-588442347, 523287799},
{-588627877, 524411982}, {-588949515, 525563228}, {-589236024, 526343731},
{-589777630, 527520992}, {-590494229, 528663568}, {-592787049, 531446465},
{-593848637, 532422937}, {-595217903, 533371136}, {-596131953, 533877449},
{-597630255, 534521605}, {-598832795, 534875490}, {-601546079, 535331109},
{-602414318, 535403500}, {-603057709, 535363873}, {-605709063, 535036029},
{-606968467, 534718181}, {-608674076, 534053872}, {-609696343, 533519540},
{-611401961, 532372920}, {-612380337, 531521992}, {-614083835, 529622220},
{-614805493, 528591155}, {-615692287, 526930012}, {-616089432, 525965919},
{-616542803, 524453004}, {-616755206, 523241979}, {-616901699, 520633437}} };
const double scaledTol = 41943.139999999999;
const double scale = 4194314.0000000000;
const double offset = -10.000000000000000;
Clipper2Lib::ClipperOffset offseter(2, scaledTol);
Clipper2Lib::Paths64 tmpSubject;
offseter.AddPaths(subjects, Clipper2Lib::JoinType::Round, Clipper2Lib::EndType::Polygon);
Clipper2Lib::Paths64 paths;
offseter.Execute(offset * scale, paths);
EXPECT_EQ(paths.size(), 0);
}
The input is red circle, and I dont see any obvious self-intersection there, the output are these two green things
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 33 (15 by maintainers)
Commits related to this issue
- Minor bugfix in polygon offsetting (#593) — committed to AngusJohnson/Clipper2 by AngusJohnson a year ago
- Fixed a minor bug in ClipperOffset (#593) — committed to AngusJohnson/Clipper2 by AngusJohnson 9 months ago
- When testing if a group is smaller than the offset (and thus will vanish in the output), not only test the bounding box width but also the height. If either dimension is smaller than 2 times offset, t... — committed to SebastianDirks/Clipper2 by SebastianDirks 9 months ago
- Fixed bug in 180deg rounding (C++ & c#) //#593 — committed to AngusJohnson/Clipper2 by AngusJohnson 9 months ago
- When testing if a group is smaller than the offset (and thus will vanish in the output), not only test the bounding box width but also the height. (#651) If either dimension is smaller than 2 times o... — committed to AngusJohnson/Clipper2 by SebastianDirks 9 months ago
@AngusJohnson Thanks for fixing all this. Now I don’t see regressions compared to Clipper1 (In terms of offsetting).
I will investigate further.
Yep, give it another go.
One important algorithm for removing small details is:
this depends crucially on negative offset removing all small pieces.
In our testing Clipper1 handles this case well. Please reconsider additional checking.