Skip to content

Commit

Permalink
Fixed bug in 180deg rounding (C++ & c#) //#593
Browse files Browse the repository at this point in the history
  • Loading branch information
AngusJohnson committed Sep 18, 2023
1 parent 388041f commit 83b0ccc
Show file tree
Hide file tree
Showing 3 changed files with 265 additions and 243 deletions.
18 changes: 7 additions & 11 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 : 16 September 2023 *
* Date : 19 September 2023 *
* Website : http://www.angusj.com *
* Copyright : Angus Johnson 2010-2023 *
* Purpose : Path Offset (Inflate/Shrink) *
Expand Down Expand Up @@ -284,20 +284,16 @@ void ClipperOffset::DoRound(Group& group, const Path64& path, size_t j, size_t k
#else
group.path.push_back(Point64(pt.x + offsetVec.x, pt.y + offsetVec.y));
#endif
if (angle > -PI + 0.01) // avoid 180deg concave
int steps = static_cast<int>(std::ceil(steps_per_rad_ * std::abs(angle))); // #448, #456
for (int i = 1; i < steps; ++i) // ie 1 less than steps
{
int steps = static_cast<int>(std::ceil(steps_per_rad_ * std::abs(angle))); // #448, #456
for (int i = 1; i < steps; ++i) // ie 1 less than steps
{
offsetVec = PointD(offsetVec.x * step_cos_ - step_sin_ * offsetVec.y,
offsetVec.x * step_sin_ + offsetVec.y * step_cos_);
offsetVec = PointD(offsetVec.x * step_cos_ - step_sin_ * offsetVec.y,
offsetVec.x * step_sin_ + offsetVec.y * step_cos_);
#ifdef USINGZ
group.path.push_back(Point64(pt.x + offsetVec.x, pt.y + offsetVec.y, pt.z));
group.path.push_back(Point64(pt.x + offsetVec.x, pt.y + offsetVec.y, pt.z));
#else
group.path.push_back(Point64(pt.x + offsetVec.x, pt.y + offsetVec.y));
group.path.push_back(Point64(pt.x + offsetVec.x, pt.y + offsetVec.y));
#endif

}
}
group.path.push_back(GetPerpendic(path[j], norms[j], group_delta_));
}
Expand Down
Loading

0 comments on commit 83b0ccc

Please sign in to comment.