|
2 | 2 |
|
3 | 3 | (*******************************************************************************
|
4 | 4 | * Author : Angus Johnson *
|
5 |
| -* Date : 10 May 2025 * |
| 5 | +* Date : 30 May 2025 * |
6 | 6 | * Website : https://www.angusj.com *
|
7 | 7 | * Copyright : Angus Johnson 2010-2025 *
|
8 | 8 | * Purpose : This is the main polygon clipping module *
|
@@ -942,8 +942,6 @@ function PointInOpPolygon(const pt: TPoint64; op: POutPt): TPointInPolygonResult
|
942 | 942 | function Path1InsidePath2(const op1, op2: POutPt): Boolean;
|
943 | 943 | var
|
944 | 944 | op: POutPt;
|
945 |
| - mp: TPoint64; |
946 |
| - path: TPath64; |
947 | 945 | pip: TPointInPolygonResult;
|
948 | 946 | begin
|
949 | 947 | // accommodate rounding errors
|
@@ -2390,6 +2388,8 @@ procedure TClipperBase.CheckJoinLeft(e: PActive;
|
2390 | 2388 | not IsHotEdge(e) or not IsHotEdge(prev) or
|
2391 | 2389 | IsHorizontal(e) or IsHorizontal(prev) or
|
2392 | 2390 | IsOpen(e) or IsOpen(prev) then Exit;
|
| 2391 | + // Also exit if pt is within a unit of the top of either edge |
| 2392 | + // unless one of the edges is almost horizontal ... |
2393 | 2393 | if ((pt.Y < e.top.Y +2) or (pt.Y < prev.top.Y +2)) and
|
2394 | 2394 | ((e.bot.Y > pt.Y) or (prev.bot.Y > pt.Y)) then Exit; // (#490)
|
2395 | 2395 |
|
@@ -2421,6 +2421,9 @@ procedure TClipperBase.CheckJoinRight(e: PActive;
|
2421 | 2421 | not IsHotEdge(e) or not IsHotEdge(next) or
|
2422 | 2422 | IsHorizontal(e) or IsHorizontal(next) or
|
2423 | 2423 | IsOpen(e) or IsOpen(next) then Exit;
|
| 2424 | + |
| 2425 | + // Also exit if pt is within a unit of the top of either edge |
| 2426 | + // unless one of the edges is almost horizontal ... |
2424 | 2427 | if ((pt.Y < e.top.Y +2) or (pt.Y < next.top.Y +2)) and
|
2425 | 2428 | ((e.bot.Y > pt.Y) or (next.bot.Y > pt.Y)) then Exit; // (#490)
|
2426 | 2429 |
|
@@ -2633,6 +2636,7 @@ procedure TClipperBase.IntersectEdges(e1, e2: PActive; pt: TPoint64);
|
2633 | 2636 | end;
|
2634 | 2637 |
|
2635 | 2638 | // MANAGING CLOSED PATHS FROM HERE ON
|
| 2639 | + |
2636 | 2640 | if IsJoined(e1) then UndoJoin(e1, pt);
|
2637 | 2641 | if IsJoined(e2) then UndoJoin(e2, pt);
|
2638 | 2642 |
|
@@ -2839,10 +2843,9 @@ procedure TClipperBase.AdjustCurrXAndCopyToSEL(topY: Int64);
|
2839 | 2843 | e.prevInSEL := e.prevInAEL;
|
2840 | 2844 | e.nextInSEL := e.nextInAEL;
|
2841 | 2845 | e.jump := e.nextInSEL;
|
2842 |
| - if (e.joinedWith = jwLeft) then |
2843 |
| - e.currX := e.prevInAEL.currX // this also avoids complications |
2844 |
| - else |
2845 |
| - e.currX := TopX(e, topY); |
| 2846 | + // it is safe to ignore 'joined' edges here because |
| 2847 | + // if necessary they will be split in IntersectEdges() |
| 2848 | + e.currX := TopX(e, topY); |
2846 | 2849 | e := e.nextInAEL;
|
2847 | 2850 | end;
|
2848 | 2851 | end;
|
@@ -3402,7 +3405,7 @@ procedure TClipperBase.DoHorizontal(horzEdge: PActive);
|
3402 | 3405 | Result := assigned(e);
|
3403 | 3406 | // nb: this block isn't yet redundant
|
3404 | 3407 | end
|
3405 |
| - else if horzEdge.currX < horzEdge.top.X then |
| 3408 | + else if (horzEdge.currX < horzEdge.top.X) then |
3406 | 3409 | begin
|
3407 | 3410 | horzLeft := horzEdge.currX;
|
3408 | 3411 | horzRight := horzEdge.top.X;
|
@@ -3442,6 +3445,7 @@ procedure TClipperBase.DoHorizontal(horzEdge: PActive);
|
3442 | 3445 | Y := horzEdge.bot.Y;
|
3443 | 3446 | maxVertex := nil;
|
3444 | 3447 |
|
| 3448 | + // maxVertex - manages consecutive horizontal edges |
3445 | 3449 | if horzIsOpen then
|
3446 | 3450 | maxVertex := GetCurrYMaximaVertexOpen(horzEdge) else
|
3447 | 3451 | maxVertex := GetCurrYMaximaVertex(horzEdge);
|
|
0 commit comments