Skip to content

Commit

Permalink
Fixed USINGZ option when bevel offsetting (Disc. 766).
Browse files Browse the repository at this point in the history
  • Loading branch information
AngusJohnson committed Jan 13, 2024
1 parent cee24f5 commit 609d873
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 8 deletions.
14 changes: 12 additions & 2 deletions CPP/Clipper2Lib/src/clipper.offset.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*******************************************************************************
* Author : Angus Johnson *
* Date : 21 December 2023 *
* Date : 13 January 2024 *
* Website : http://www.angusj.com *
* Copyright : Angus Johnson 2010-2023 *
* Copyright : Angus Johnson 2010-2024 *
* Purpose : Path Offset (Inflate/Shrink) *
* License : http://www.boost.org/LICENSE_1_0.txt *
*******************************************************************************/
Expand Down Expand Up @@ -222,13 +222,23 @@ void ClipperOffset::DoBevel(const Path64& path, size_t j, size_t k)
if (j == k)
{
double abs_delta = std::abs(group_delta_);
#ifdef USINGZ
pt1 = PointD(path[j].x - abs_delta * norms[j].x, path[j].y - abs_delta * norms[j].y, path[j].z);
pt2 = PointD(path[j].x + abs_delta * norms[j].x, path[j].y + abs_delta * norms[j].y, path[j].z);
#else
pt1 = PointD(path[j].x - abs_delta * norms[j].x, path[j].y - abs_delta * norms[j].y);
pt2 = PointD(path[j].x + abs_delta * norms[j].x, path[j].y + abs_delta * norms[j].y);
#endif
}
else
{
#ifdef USINGZ
pt1 = PointD(path[j].x + group_delta_ * norms[k].x, path[j].y + group_delta_ * norms[k].y, path[j].z);
pt2 = PointD(path[j].x + group_delta_ * norms[j].x, path[j].y + group_delta_ * norms[j].y, path[j].z);
#else
pt1 = PointD(path[j].x + group_delta_ * norms[k].x, path[j].y + group_delta_ * norms[k].y);
pt2 = PointD(path[j].x + group_delta_ * norms[j].x, path[j].y + group_delta_ * norms[j].y);
#endif
}
path_out.push_back(Point64(pt1));
path_out.push_back(Point64(pt2));
Expand Down
26 changes: 22 additions & 4 deletions CSharp/Clipper2Lib/Clipper.Offset.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*******************************************************************************
* Author : Angus Johnson *
* Date : 21 December 2023 *
* Date : 13 January 2024 *
* Website : http://www.angusj.com *
* Copyright : Angus Johnson 2010-2023 *
* Copyright : Angus Johnson 2010-2024 *
* Purpose : Path Offset (Inflate/Shrink) *
* License : http://www.boost.org/LICENSE_1_0.txt *
*******************************************************************************/
Expand Down Expand Up @@ -420,21 +420,39 @@ private void DoBevel(Path64 path, int j, int k)
if (j == k)
{
double absDelta = Math.Abs(_groupDelta);
#if USINGZ
pt1 = new Point64(
path[j].X - absDelta * _normals[j].x,
path[j].Y - absDelta * _normals[j].y);
path[j].Y - absDelta * _normals[j].y, path[j].Z);
pt2 = new Point64(
path[j].X + absDelta * _normals[j].x,
path[j].Y + absDelta * _normals[j].y, path[j].Z);
#else
pt1 = new Point64(
path[j].X - absDelta * _normals[j].x,
path[j].Y - absDelta * _normals[j].y);
pt2 = new Point64(
path[j].X + absDelta * _normals[j].x,
path[j].Y + absDelta * _normals[j].y);
#endif
}
else
{
#if USINGZ
pt1 = new Point64(
path[j].X + _groupDelta * _normals[k].x,
path[j].Y + _groupDelta * _normals[k].y, path[j].Z);
pt2 = new Point64(
path[j].X + _groupDelta * _normals[j].x,
path[j].Y + _groupDelta * _normals[j].y, path[j].Z);
#else
pt1 = new Point64(
path[j].X + _groupDelta * _normals[k].x,
path[j].Y + _groupDelta * _normals[k].y);
pt2 = new Point64(
path[j].X + _groupDelta * _normals[j].x,
path[j].X + _groupDelta * _normals[j].x,
path[j].Y + _groupDelta * _normals[j].y);
#endif
}
pathOut.Add(pt1);
pathOut.Add(pt2);
Expand Down
22 changes: 20 additions & 2 deletions Delphi/Clipper2Lib/Clipper.Offset.pas
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

(*******************************************************************************
* Author : Angus Johnson *
* Date : 21 December 2023 *
* Date : 13 January 2024 *
* Website : http://www.angusj.com *
* Copyright : Angus Johnson 2010-2023 *
* Copyright : Angus Johnson 2010-2024 *
* Purpose : Path Offset (Inflate/Shrink) *
* License : http://www.boost.org/LICENSE_1_0.txt *
*******************************************************************************)
Expand Down Expand Up @@ -850,20 +850,38 @@ procedure TClipperOffset.DoBevel(j, k: Integer);
if k = j then
begin
absDelta := abs(fGroupDelta);
{$IFDEF USINGZ}
AddPoint(
fInPath[j].x - absDelta * fNorms[j].x,
fInPath[j].y - absDelta * fNorms[j].y, fInPath[j].z);
AddPoint(
fInPath[j].x + absDelta * fNorms[j].x,
fInPath[j].y + absDelta * fNorms[j].y, fInPath[j].z);
{$ELSE}
AddPoint(
fInPath[j].x - absDelta * fNorms[j].x,
fInPath[j].y - absDelta * fNorms[j].y);
AddPoint(
fInPath[j].x + absDelta * fNorms[j].x,
fInPath[j].y + absDelta * fNorms[j].y);
{$ENDIF}
end else
begin
{$IFDEF USINGZ}
AddPoint(
fInPath[j].x + fGroupDelta * fNorms[k].x,
fInPath[j].y + fGroupDelta * fNorms[k].y, fInPath[j].z);
AddPoint(
fInPath[j].x + fGroupDelta * fNorms[j].x,
fInPath[j].y + fGroupDelta * fNorms[j].y, fInPath[j].z);
{$ELSE}
AddPoint(
fInPath[j].x + fGroupDelta * fNorms[k].x,
fInPath[j].y + fGroupDelta * fNorms[k].y);
AddPoint(
fInPath[j].x + fGroupDelta * fNorms[j].x,
fInPath[j].y + fGroupDelta * fNorms[j].y);
{$ENDIF}
end;
end;
//------------------------------------------------------------------------------
Expand Down

0 comments on commit 609d873

Please sign in to comment.