Skip to content

Commit

Permalink
Merge with 6.4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristian Pallarés committed Apr 18, 2017
1 parent ec7c6ba commit b1f1e16
Show file tree
Hide file tree
Showing 197 changed files with 16,756 additions and 1,015 deletions.
21 changes: 15 additions & 6 deletions C#/clipper_library/clipper.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*******************************************************************************
* *
* Author : Angus Johnson *
* Version : 6.4.0 *
* Date : 2 July 2015 *
* Version : 6.4.2 *
* Date : 27 February 2017 *
* Website : http://www.angusj.com *
* Copyright : Angus Johnson 2010-2015 *
* Copyright : Angus Johnson 2010-2017 *
* *
* License: *
* Use, modification & distribution is subject to Boost Software License Ver 1. *
Expand Down Expand Up @@ -2126,7 +2126,7 @@ private OutPt AddLocalMinPoly(TEdge e1, TEdge e2, IntPoint pt)
prevE = e.PrevInAEL;
}

if (prevE != null && prevE.OutIdx >= 0)
if (prevE != null && prevE.OutIdx >= 0 && prevE.Top.Y < pt.Y && e.Top.Y < pt.Y)
{
cInt xPrev = TopX(prevE, pt.Y);
cInt xE = TopX(e, pt.Y);
Expand Down Expand Up @@ -2788,6 +2788,11 @@ private void ProcessHorizontal(TEdge horzEdge)

if (horzEdge.OutIdx >= 0 && !IsOpen) //note: may be done multiple times
{
#if use_xyz
if (dir == Direction.dLeftToRight) SetZ(ref e.Curr, horzEdge, e);
else SetZ(ref e.Curr, e, horzEdge);
#endif

op1 = AddOutPt(horzEdge, e.Curr);
TEdge eNextHorz = m_SortedEdges;
while (eNextHorz != null)
Expand Down Expand Up @@ -3194,8 +3199,12 @@ private void ProcessEdgesAtTopOfScanbeam(cInt topY)
{
e.Curr.X = TopX( e, topY );
e.Curr.Y = topY;
#if use_xyz
if (e.Top.Y == topY) e.Curr.Z = e.Top.Z;
else if (e.Bot.Y == topY) e.Curr.Z = e.Bot.Z;
else e.Curr.Z = 0;
#endif
}

//When StrictlySimple and 'e' is being touched by another edge, then
//make sure both edges have a vertex here ...
if (StrictlySimple)
Expand Down Expand Up @@ -3904,7 +3913,7 @@ private void FixupFirstLefts3(OutRec OldOutRec, OutRec NewOutRec)
foreach (OutRec outRec in m_PolyOuts)
{
OutRec firstLeft = ParseFirstLeft(outRec.FirstLeft);
if (outRec.Pts != null && outRec.FirstLeft == OldOutRec)
if (outRec.Pts != null && firstLeft == OldOutRec)
outRec.FirstLeft = NewOutRec;
}
}
Expand Down
35 changes: 20 additions & 15 deletions Delphi/clipper.pas
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
(*******************************************************************************
* *
* Author : Angus Johnson *
* Version : 6.4.0 *
* Date : 2 July 2015 *
* Version : 6.4.2 *
* Date : 27 February 2017 *
* Website : http://www.angusj.com *
* Copyright : Angus Johnson 2010-2015 *
* Copyright : Angus Johnson 2010-2017 *
* *
* License: *
* Use, modification & distribution is subject to Boost Software License Ver 1. *
Expand Down Expand Up @@ -1544,7 +1544,7 @@ function FindNextLocMin(E: PEdge): PEdge; {$IFDEF INLINING} inline; {$ENDIF}

function GetUnitNormal(const Pt1, Pt2: TIntPoint): TDoublePoint;
var
Dx, Dy, F: Single;
Dx, Dy, F: Double;
begin
if (Pt2.X = Pt1.X) and (Pt2.Y = Pt1.Y) then
begin
Expand Down Expand Up @@ -2622,7 +2622,8 @@ function TClipper.AddLocalMinPoly(E1, E2: PEdge; const Pt: TIntPoint): POutPt;
prevE := E.PrevInAEL;
end;

if Assigned(prevE) and (prevE.OutIdx >= 0) then
if Assigned(prevE) and (prevE.OutIdx >= 0) and
(prevE.Top.Y < Pt.Y) and (E.Top.Y < Pt.Y) then
begin
X1 := TopX(prevE, Pt.Y);
X2 := TopX(E, Pt.Y);
Expand Down Expand Up @@ -3629,6 +3630,10 @@ procedure TClipper.ProcessHorizontal(HorzEdge: PEdge);

if (HorzEdge.OutIdx >= 0) and not IsOpen then //may be done multiple times
begin
{$IFDEF use_xyz}
if (Direction = dLeftToRight) then SetZ(E.Curr, HorzEdge, E, FZFillCallback)
else SetZ(E.Curr, E, HorzEdge, FZFillCallback);
{$ENDIF}
Op1 := AddOutPt(HorzEdge, E.Curr);
eNextHorz := FSortedEdges;
while Assigned(eNextHorz) do
Expand Down Expand Up @@ -3949,6 +3954,11 @@ procedure TClipper.ProcessEdgesAtTopOfScanbeam(const TopY: cInt);
begin
E.Curr.X := TopX(E, TopY);
E.Curr.Y := TopY;
{$IFDEF use_xyz}
if E.Top.Y = TopY then e.Curr.Z := e.Top.Z
else if (E.Bot.Y = TopY) then e.Curr.Z := E.Bot.Z else
e.Curr.Z := 0;
{$ENDIF}
end;

//When StrictlySimple and 'e' is being touched by another edge, then
Expand Down Expand Up @@ -4153,7 +4163,7 @@ procedure TClipper.FixupOutPolygon(OutRec: POutRec);
begin
if (PP = PP.Prev) or (PP.Next = PP.Prev) then
begin
Dispose(PP);
DisposePolyPts(PP);
OutRec.Pts := nil;
Exit;
end;
Expand Down Expand Up @@ -5185,18 +5195,13 @@ procedure TClipperOffset.AddPoint(const Pt: TIntPoint);
//------------------------------------------------------------------------------

procedure TClipperOffset.DoSquare(J, K: Integer);
var
A, Dx: Double;
begin
//see offset_triginometry.svg in the documentation folder ...
A := ArcTan2(FSinA, FNorms[K].X * FNorms[J].X + FNorms[K].Y * FNorms[J].Y);
Dx := tan(A/4);
AddPoint(IntPoint(
round(FInP[J].X + FDelta * (FNorms[K].X - FNorms[K].Y *Dx)),
round(FInP[J].Y + FDelta * (FNorms[K].Y + FNorms[K].X *Dx))));
round(FInP[J].X + FDelta * (FNorms[K].X - FNorms[K].Y)),
round(FInP[J].Y + FDelta * (FNorms[K].Y + FNorms[K].X))));
AddPoint(IntPoint(
round(FInP[J].X + FDelta * (FNorms[J].X + FNorms[J].Y *Dx)),
round(FInP[J].Y + FDelta * (FNorms[J].Y - FNorms[J].X *Dx))));
round(FInP[J].X + FDelta * (FNorms[J].X + FNorms[J].Y)),
round(FInP[J].Y + FDelta * (FNorms[J].Y - FNorms[J].X))));
end;
//------------------------------------------------------------------------------

Expand Down
Loading

0 comments on commit b1f1e16

Please sign in to comment.