| 3677 | //---------------------------------------------------------------------- |
| 3678 | |
| 3679 | void Clipper::JoinCommonEdges() |
| 3680 | { |
| 3681 | for (JoinList::size_type i = 0; i < m_Joins.size(); i++) |
| 3682 | { |
| 3683 | Join* join = m_Joins[i]; |
| 3684 | |
| 3685 | OutRec *outRec1 = GetOutRec(join->OutPt1->Idx); |
| 3686 | OutRec *outRec2 = GetOutRec(join->OutPt2->Idx); |
| 3687 | |
| 3688 | if (!outRec1->Pts || !outRec2->Pts) continue; |
| 3689 | if (outRec1->IsOpen || outRec2->IsOpen) continue; |
| 3690 | |
| 3691 | //get the polygon fragment with the correct hole state (FirstLeft) |
| 3692 | //before calling JoinPoints() ... |
| 3693 | OutRec *holeStateRec; |
| 3694 | if (outRec1 == outRec2) holeStateRec = outRec1; |
| 3695 | else if (OutRec1RightOfOutRec2(outRec1, outRec2)) holeStateRec = outRec2; |
| 3696 | else if (OutRec1RightOfOutRec2(outRec2, outRec1)) holeStateRec = outRec1; |
| 3697 | else holeStateRec = GetLowermostRec(outRec1, outRec2); |
| 3698 | |
| 3699 | if (!JoinPoints(join, outRec1, outRec2)) continue; |
| 3700 | |
| 3701 | if (outRec1 == outRec2) |
| 3702 | { |
| 3703 | //instead of joining two polygons, we've just created a new one by |
| 3704 | //splitting one polygon into two. |
| 3705 | outRec1->Pts = join->OutPt1; |
| 3706 | outRec1->BottomPt = 0; |
| 3707 | outRec2 = CreateOutRec(); |
| 3708 | outRec2->Pts = join->OutPt2; |
| 3709 | |
| 3710 | //update all OutRec2.Pts Idx's ... |
| 3711 | UpdateOutPtIdxs(*outRec2); |
| 3712 | |
| 3713 | if (Poly2ContainsPoly1(outRec2->Pts, outRec1->Pts)) |
| 3714 | { |
| 3715 | //outRec1 contains outRec2 ... |
| 3716 | outRec2->IsHole = !outRec1->IsHole; |
| 3717 | outRec2->FirstLeft = outRec1; |
| 3718 | |
| 3719 | if (m_UsingPolyTree) FixupFirstLefts2(outRec2, outRec1); |
| 3720 | |
| 3721 | if ((outRec2->IsHole ^ m_ReverseOutput) == (Area(*outRec2) > 0)) |
| 3722 | ReversePolyPtLinks(outRec2->Pts); |
| 3723 | |
| 3724 | } else if (Poly2ContainsPoly1(outRec1->Pts, outRec2->Pts)) |
| 3725 | { |
| 3726 | //outRec2 contains outRec1 ... |
| 3727 | outRec2->IsHole = outRec1->IsHole; |
| 3728 | outRec1->IsHole = !outRec2->IsHole; |
| 3729 | outRec2->FirstLeft = outRec1->FirstLeft; |
| 3730 | outRec1->FirstLeft = outRec2; |
| 3731 | |
| 3732 | if (m_UsingPolyTree) FixupFirstLefts2(outRec1, outRec2); |
| 3733 | |
| 3734 | if ((outRec1->IsHole ^ m_ReverseOutput) == (Area(*outRec1) > 0)) |
| 3735 | ReversePolyPtLinks(outRec1->Pts); |
| 3736 | } |
nothing calls this directly
no test coverage detected