Skip to content

Commit

Permalink
Fixed a minor bug in ClipperOffset (#593)
Browse files Browse the repository at this point in the history
  • Loading branch information
AngusJohnson committed Sep 16, 2023
1 parent e6e2201 commit 388041f
Show file tree
Hide file tree
Showing 4 changed files with 264 additions and 74 deletions.
12 changes: 6 additions & 6 deletions CPP/Clipper2Lib/src/clipper.offset.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
* Author : Angus Johnson *
* Date : 9 September 2023 *
* Date : 16 September 2023 *
* Website : http://www.angusj.com *
* Copyright : Angus Johnson 2010-2023 *
* Purpose : Path Offset (Inflate/Shrink) *
Expand Down Expand Up @@ -327,11 +327,7 @@ void ClipperOffset::OffsetPoint(Group& group, Path64& path, size_t j, size_t k)
return;
}

if (cos_a > 0.999) // almost straight - less than 2.5 degree (#424, #526)
{
DoMiter(group, path, j, k, cos_a);
}
else if (cos_a > -0.99 && (sin_a * group_delta_ < 0))
if (cos_a > -0.99 && (sin_a * group_delta_ < 0)) // test for concavity first (#593)
{
// is concave
group.path.push_back(GetPerpendic(path[j], norms[k], group_delta_));
Expand All @@ -340,6 +336,10 @@ void ClipperOffset::OffsetPoint(Group& group, Path64& path, size_t j, size_t k)
group.path.push_back(path[j]); // (#405)
group.path.push_back(GetPerpendic(path[j], norms[j], group_delta_));
}
else if (cos_a > 0.999) // almost straight - less than 2.5 degree (#424, #526)
{
DoMiter(group, path, j, k, cos_a);
}
else if (join_type_ == JoinType::Miter)
{
// miter unless the angle is so acute the miter would exceeds ML
Expand Down
Loading

0 comments on commit 388041f

Please sign in to comment.