private void ComputeIntersectsForChain(int start0, int end0, MonotoneChainEdge mce, int start1, int end1, SegmentIntersector ei) { Coordinate p00 = pts[start0]; Coordinate p01 = pts[end0]; Coordinate p10 = mce.pts[start1]; Coordinate p11 = mce.pts[end1]; // 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 env1.Initialize(p00, p01); env2.Initialize(p10, p11); if (!env1.Intersects(env2)) { 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) { ComputeIntersectsForChain(start0, mid0, mce, start1, mid1, ei); } if (mid1 < end1) { ComputeIntersectsForChain(start0, mid0, mce, mid1, end1, ei); } } if (mid0 < end0) { if (start1 < mid1) { ComputeIntersectsForChain(mid0, end0, mce, start1, mid1, ei); } if (mid1 < end1) { ComputeIntersectsForChain(mid0, end0, mce, mid1, end1, ei); } } }
public void ComputeIntersectsForChain(int chainIndex0, MonotoneChainEdge mce, int chainIndex1, SegmentIntersector si) { ComputeIntersectsForChain(startIndex[chainIndex0], startIndex[chainIndex0 + 1], mce, mce.startIndex[chainIndex1], mce.startIndex[chainIndex1 + 1], si); }
public void ComputeIntersections(MonotoneChain mc, SegmentIntersector si) { this.mce.ComputeIntersectsForChain(chainIndex, mc.mce, mc.chainIndex, si); }
/// <summary> /// Computes all mutual intersections between two sets of edges. /// </summary> /// <param name="edges0">A list of edges to test for intersections.</param> /// <param name="edges1">A list of edges to test for intersections.</param> /// <param name="si">The SegmentIntersector to use.</param> public abstract void ComputeIntersections(EdgeCollection edges0, EdgeCollection edges1, SegmentIntersector si);
/// <summary> Computes all self-intersections between edges in a set of edges, /// allowing client to choose whether self-intersections are computed. /// </summary> /// <param name="edges">A list of edges to test for intersections.</param> /// <param name="si">The SegmentIntersector to use.</param> /// <param name="testAllSegments">true if self-intersections are to be tested as well /// </param> public abstract void ComputeIntersections(EdgeCollection edges, SegmentIntersector si, bool testAllSegments);
public void ComputeIntersections(SweepLineSegment ss, SegmentIntersector si) { si.AddIntersections(edge, ptIndex, ss.edge, ss.ptIndex); }