computeIntersectsForChain6 method
void
computeIntersectsForChain6(
- int start0,
- int end0,
- MonotoneChainEdge mce,
- int start1,
- int end1,
- SegmentIntersector ei,
Implementation
void computeIntersectsForChain6(int start0, int end0, MonotoneChainEdge mce,
int start1, int end1, SegmentIntersector ei) {
//Debug.println("computeIntersectsForChain:" + p00 + p01 + p10 + p11);
// terminating condition for the recursion
if (end0 - start0 == 1 && end1 - start1 == 1) {
ei.addIntersections(e, start0, mce.e, start1);
return;
}
// nothing to do if the envelopes of these chains don't overlap
if (!overlaps(start0, end0, mce, start1, end1)) return;
// the chains overlap, so split each in half and iterate (binary search)
int mid0 = (start0 + end0) ~/ 2;
int mid1 = (start1 + end1) ~/ 2;
// Assert: mid != start or end (since we checked above for end - start <= 1)
// check terminating conditions before recursing
if (start0 < mid0) {
if (start1 < mid1)
computeIntersectsForChain6(start0, mid0, mce, start1, mid1, ei);
if (mid1 < end1)
computeIntersectsForChain6(start0, mid0, mce, mid1, end1, ei);
}
if (mid0 < end0) {
if (start1 < mid1)
computeIntersectsForChain6(mid0, end0, mce, start1, mid1, ei);
if (mid1 < end1)
computeIntersectsForChain6(mid0, end0, mce, mid1, end1, ei);
}
}