| 2497 | } |
| 2498 | |
| 2499 | func eventRelation(rel Relation, zs []Point, event *SweepPoint, rights []*SweepPoint, self bool) (Relation, []Point) { |
| 2500 | // event is left and is the last segment of the set of overlapping segments |
| 2501 | |
| 2502 | // handle right-events to the left of the current event, these do not appear in status/event.prev |
| 2503 | if event.left { |
| 2504 | // add intersections left-to-right (after splitting always at endpoints) |
| 2505 | for _, right := range rights { |
| 2506 | if right.clipping != event.clipping { |
| 2507 | p, q := event, right |
| 2508 | if event.clipping { |
| 2509 | p, q = q, p |
| 2510 | } |
| 2511 | if p.open && q.open { |
| 2512 | if p.end && q.end { |
| 2513 | rel |= relBB |
| 2514 | } else if p.end { |
| 2515 | rel |= relBI |
| 2516 | } else if q.end { |
| 2517 | rel |= relIB |
| 2518 | } else { |
| 2519 | rel |= relII |
| 2520 | } |
| 2521 | } else if p.open { |
| 2522 | if p.end { |
| 2523 | rel |= relBB |
| 2524 | } else { |
| 2525 | rel |= relIB |
| 2526 | } |
| 2527 | } else if q.open { |
| 2528 | if q.end { |
| 2529 | rel |= relBB |
| 2530 | } else { |
| 2531 | rel |= relBI |
| 2532 | } |
| 2533 | } else { |
| 2534 | rel |= relBB |
| 2535 | } |
| 2536 | if (!right.other.overlapped || right.end) && (len(zs) == 0 || zs[len(zs)-1] != event.Point) { |
| 2537 | // add endpoint intersections of non-overlapped segments |
| 2538 | zs = append(zs, event.Point) |
| 2539 | } |
| 2540 | } |
| 2541 | } |
| 2542 | return rel, zs |
| 2543 | } |
| 2544 | event = event.other // get left-event |
| 2545 | |
| 2546 | // handle overlapping segments |
| 2547 | hasSubject, hasClipping := !event.clipping, event.clipping |
| 2548 | for i := len(rights) - 1; 0 <= i; i-- { |
| 2549 | other := rights[i].other |
| 2550 | if other.Point != event.Point { |
| 2551 | break |
| 2552 | } |
| 2553 | |
| 2554 | if event.clipping == other.clipping { |
| 2555 | event.selfWindings += other.selfWindings |
| 2556 | event.otherSelfWindings += other.otherSelfWindings |