MCPcopy Create free account
hub / github.com/TheForceEngine/TheForceEngine / JoinPoints

Method JoinPoints

TheForceEngine/TFE_Polygon/clipper.cpp:3458–3614  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3456//------------------------------------------------------------------------------
3457
3458bool Clipper::JoinPoints(Join *j, OutRec* outRec1, OutRec* outRec2)
3459{
3460 OutPt *op1 = j->OutPt1, *op1b;
3461 OutPt *op2 = j->OutPt2, *op2b;
3462
3463 //There are 3 kinds of joins for output polygons ...
3464 //1. Horizontal joins where Join.OutPt1 & Join.OutPt2 are vertices anywhere
3465 //along (horizontal) collinear edges (& Join.OffPt is on the same horizontal).
3466 //2. Non-horizontal joins where Join.OutPt1 & Join.OutPt2 are at the same
3467 //location at the Bottom of the overlapping segment (& Join.OffPt is above).
3468 //3. StrictSimple joins where edges touch but are not collinear and where
3469 //Join.OutPt1, Join.OutPt2 & Join.OffPt all share the same point.
3470 bool isHorizontal = (j->OutPt1->Pt.Y == j->OffPt.Y);
3471
3472 if (isHorizontal && (j->OffPt == j->OutPt1->Pt) &&
3473 (j->OffPt == j->OutPt2->Pt))
3474 {
3475 //Strictly Simple join ...
3476 if (outRec1 != outRec2) return false;
3477 op1b = j->OutPt1->Next;
3478 while (op1b != op1 && (op1b->Pt == j->OffPt))
3479 op1b = op1b->Next;
3480 bool reverse1 = (op1b->Pt.Y > j->OffPt.Y);
3481 op2b = j->OutPt2->Next;
3482 while (op2b != op2 && (op2b->Pt == j->OffPt))
3483 op2b = op2b->Next;
3484 bool reverse2 = (op2b->Pt.Y > j->OffPt.Y);
3485 if (reverse1 == reverse2) return false;
3486 if (reverse1)
3487 {
3488 op1b = DupOutPt(op1, false);
3489 op2b = DupOutPt(op2, true);
3490 op1->Prev = op2;
3491 op2->Next = op1;
3492 op1b->Next = op2b;
3493 op2b->Prev = op1b;
3494 j->OutPt1 = op1;
3495 j->OutPt2 = op1b;
3496 return true;
3497 } else
3498 {
3499 op1b = DupOutPt(op1, true);
3500 op2b = DupOutPt(op2, false);
3501 op1->Next = op2;
3502 op2->Prev = op1;
3503 op1b->Prev = op2b;
3504 op2b->Next = op1b;
3505 j->OutPt1 = op1;
3506 j->OutPt2 = op1b;
3507 return true;
3508 }
3509 }
3510 else if (isHorizontal)
3511 {
3512 //treat horizontal joins differently to non-horizontal joins since with
3513 //them we're not yet sure where the overlapping is. OutPt1.Pt & OutPt2.Pt
3514 //may be anywhere along the horizontal edge.
3515 op1b = op1;

Callers

nothing calls this directly

Calls 4

DupOutPtFunction · 0.85
GetOverlapFunction · 0.85
JoinHorzFunction · 0.85
SlopesEqualFunction · 0.85

Tested by

no test coverage detected