Skip to content

Commit

Permalink
Fixed a very minor bug merging touching polygons (Dis.#690)
Browse files Browse the repository at this point in the history
  • Loading branch information
AngusJohnson committed Oct 19, 2023
1 parent 6a7a401 commit 0b5bf2f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 18 deletions.
7 changes: 5 additions & 2 deletions CPP/Clipper2Lib/src/clipper.engine.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
* Author : Angus Johnson *
* Date : 27 August 2023 *
* Date : 19 October 2023 *
* Website : http://www.angusj.com *
* Copyright : Angus Johnson 2010-2023 *
* Purpose : This is the main polygon clipping module *
Expand Down Expand Up @@ -1469,13 +1469,14 @@ namespace Clipper2Lib {
e2.outrec->front_edge = nullptr;
e2.outrec->back_edge = nullptr;
e2.outrec->pts = nullptr;
SetOwner(e2.outrec, e1.outrec);

if (IsOpenEnd(e1))
{
e2.outrec->pts = e1.outrec->pts;
e1.outrec->pts = nullptr;
}
else
SetOwner(e2.outrec, e1.outrec);

//and e1 and e2 are maxima and are about to be dropped from the Actives list.
e1.outrec = nullptr;
Expand Down Expand Up @@ -2591,13 +2592,15 @@ namespace Clipper2Lib {
{
IntersectEdges(horz, *e, pt);
SwapPositionsInAEL(horz, *e);
CheckJoinLeft(*e, pt);
horz.curr_x = e->curr_x;
e = horz.next_in_ael;
}
else
{
IntersectEdges(*e, horz, pt);
SwapPositionsInAEL(*e, horz);
CheckJoinRight(*e, pt);
horz.curr_x = e->curr_x;
e = horz.prev_in_ael;
}
Expand Down
4 changes: 3 additions & 1 deletion CSharp/Clipper2Lib/Clipper.Engine.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
* Author : Angus Johnson *
* Date : 1 October 2023 *
* Date : 19 October 2023 *
* Website : http://www.angusj.com *
* Copyright : Angus Johnson 2010-2023 *
* Purpose : This is the main polygon clipping module *
Expand Down Expand Up @@ -2228,13 +2228,15 @@ private void DoHorizontal(Active horz)
{
IntersectEdges(horz, ae, pt);
SwapPositionsInAEL(horz, ae);
CheckJoinLeft(ae, pt);
horz.curX = ae.curX;
ae = horz.nextInAEL;
}
else
{
IntersectEdges(ae, horz, pt);
SwapPositionsInAEL(ae, horz);
CheckJoinRight(ae, pt);
horz.curX = ae.curX;
ae = horz.prevInAEL;
}
Expand Down
20 changes: 5 additions & 15 deletions Delphi/Clipper2Lib/Clipper.Engine.pas
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

(*******************************************************************************
* Author : Angus Johnson *
* Date : 16 October 2023 *
* Date : 19 October 2023 *
* Website : http://www.angusj.com *
* Copyright : Angus Johnson 2010-2023 *
* Purpose : This is the main polygon clipping module *
Expand Down Expand Up @@ -2342,22 +2342,10 @@ procedure TClipperBase.JoinOutrecPaths(e1, e2: PActive);
begin
e2.outrec.pts := e1.outrec.pts;
e1.outrec.pts := nil;
end else
begin
end
else
SetOwner(e2.outrec, e1.outrec);

// if FUsingPolytree then
// begin
// e := GetPrevHotEdge(e1);
// if not Assigned(e) then
// outRec.owner := nil else
// SetOwner(outRec, e.outrec);
// // nb: outRec.owner here is likely NOT the real
// // owner but this will be checked in DeepCheckOwner()
// end;

end;

// and e1 and e2 are maxima and are about to be dropped from the Actives list.
e1.outrec := nil;
e2.outrec := nil;
Expand Down Expand Up @@ -3539,12 +3527,14 @@ procedure TClipperBase.DoHorizontal(horzEdge: PActive);
begin
IntersectEdges(horzEdge, e, pt);
SwapPositionsInAEL(horzEdge, e);
CheckJoinLeft(e, pt);
horzEdge.currX := e.currX;
e := horzEdge.nextInAEL;
end else
begin
IntersectEdges(e, horzEdge, pt);
SwapPositionsInAEL(e, horzEdge);
CheckJoinRight(e, pt);
horzEdge.currX := e.currX;
e := horzEdge.prevInAEL;
end;
Expand Down

0 comments on commit 0b5bf2f

Please sign in to comment.