private void GenerateSparseIntersections(IEnumerator <Point> vertexPoints, EnumeratorWrapper <Point> bboxSteinerPoints) { this.perpendicularSegmentVector.ResetForIntersections(); this.parallelSegmentVector.ResetForIntersections(); // Position the enumerations to the first point. vertexPoints.MoveNext(); bboxSteinerPoints.MoveNext(); foreach (var item in parallelSegmentVector.Items) { for (;;) { if (!item.CurrentSegment.ContainsPoint(vertexPoints.Current)) { // Done accumulating intersections for the current segment; move to the next segment. if (!this.AddSteinerPointsToInterveningSegments(vertexPoints.Current, bboxSteinerPoints, item) || !item.TraverseToSegmentContainingPoint(vertexPoints.Current)) { // Done with this vectorItem, move to the next item. break; } } this.AddPointsToCurrentSegmentIntersections(bboxSteinerPoints, item); this.GenerateIntersectionsFromVertexPointForCurrentSegment(vertexPoints.Current, item); if (item.PointIsCurrentEndAndNextStart(vertexPoints.Current)) { // MoveNext will always return true because the test to enter this block returned true. item.MoveNext(); Debug.Assert(item.HasCurrent, "MoveNext ended before EndAndNextStart"); continue; } if (!vertexPoints.MoveNext()) { // No more vertexPoints; we're done. Debug.Assert(!bboxSteinerPoints.HasCurrent, "Some boundingBoxSteinerPoints remain"); return; } } } // We should have exited in the "no more vertexPoints" case above. Debug.Assert(false, "Mismatch in points and segments"); }
private void AddPointsToCurrentSegmentIntersections(EnumeratorWrapper <Point> pointsToAdd, ScanSegmentVectorItem parallelItem) { // The first Steiner point should be in the segment, unless we have a non-orthogonal or overlapped or both situation // that results in no Steiner points having been generated, or Steiner points being generated on a segment that has // the opposite overlap state from the segment containing the corresponding vertex. for (; pointsToAdd.HasCurrent && parallelItem.CurrentSegment.ContainsPoint(pointsToAdd.Current); pointsToAdd.MoveNext()) { int steinerSlot = this.FindPerpendicularSlot(pointsToAdd.Current, 0); this.AddSlotToSegmentIntersections(parallelItem, steinerSlot); } }