private void GenerateSparseIntersectionsAlongVerticalAxis() { this.currentAxisPointComparer = new VerticalPointComparer(); var vertexPoints = this.verticalVertexPoints.OrderBy(point => point, this.currentAxisPointComparer).GetEnumerator(); var bboxSteinerPoints = new EnumeratorWrapper <Point>(this.boundingBoxSteinerPoints.OrderBy(point => point, this.currentAxisPointComparer)); base.ScanDirection = ScanDirection.VerticalInstance; SetVectorsAndCoordMaps(base.ScanDirection); this.GenerateSparseIntersections(vertexPoints, bboxSteinerPoints); }
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); } }
private bool AddSteinerPointsToInterveningSegments(Point currentVertexPoint, EnumeratorWrapper <Point> bboxSteinerPoints, ScanSegmentVectorItem item) { // With overlaps, we may have bboxSteinerPoints on segments that do not contain vertices. while (bboxSteinerPoints.HasCurrent && (this.currentAxisPointComparer.Compare(bboxSteinerPoints.Current, currentVertexPoint) == -1)) { if (!item.TraverseToSegmentContainingPoint(bboxSteinerPoints.Current)) { // Done with this vectorItem, move to the next item. return(false); } this.AddPointsToCurrentSegmentIntersections(bboxSteinerPoints, item); } return(true); }
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"); }