private void AddBinaryDivisionSlotsToSegmentIntersections(ScanSegmentVectorItem parallelItem, int startSlot, int siteSlot, int endSlot) { // The input parameters' slots have already been added to the segment's coords. // If there was no object to the low or high side, then the start or end slot was already // the graphbox max (0 or perpSegmentVector.Length, respectively). So start dividing. int low = 0; int high = this.perpendicularSegmentVector.Length - 1; // Terminate when we are one away because we don't have an edge from a point to itself. while ((high - low) > 1) { int mid = low + ((high - low) / 2); // We only use the half of the graph that the site is in, so arbitrarily decide that it is // in the lower half if it is at the midpoint. if (siteSlot <= mid) { high = mid; if ((siteSlot < high) && (high <= endSlot)) { this.AddSlotToSegmentIntersections(parallelItem, high); } continue; } low = mid; if ((siteSlot > low) && (low >= startSlot)) { this.AddSlotToSegmentIntersections(parallelItem, low); } } }
private void AddSlotToSegmentIntersections(ScanSegmentVectorItem parallelItem, int perpSlot) { ScanSegmentVectorItem perpItem = this.perpendicularSegmentVector[perpSlot]; parallelItem.CurrentSegment.AddSparseVertexCoord(perpItem.Coord); perpItem.AddPerpendicularCoord(parallelItem.Coord); }
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 void GenerateIntersectionsFromVertexPointForCurrentSegment(Point site, ScanSegmentVectorItem parallelItem) { int perpStartSlot = this.FindPerpendicularSlot(parallelItem.CurrentSegment.Start, 1); int perpEndSlot = this.FindPerpendicularSlot(parallelItem.CurrentSegment.End, -1); int siteSlot = this.FindPerpendicularSlot(site, 0); // See comments in FindIntersectingSlot; we don't add non-extreme vertices in the perpendicular direction // so in some heavily-overlapped scenarios, we may not have any intersections within this scan segment. if (perpStartSlot >= perpEndSlot) { return; } this.AddSlotToSegmentIntersections(parallelItem, perpStartSlot); this.AddSlotToSegmentIntersections(parallelItem, perpEndSlot); if ((siteSlot > perpStartSlot) && (siteSlot < perpEndSlot)) { this.AddSlotToSegmentIntersections(parallelItem, siteSlot); this.AddBinaryDivisionSlotsToSegmentIntersections(parallelItem, perpStartSlot, siteSlot, perpEndSlot); } }
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); }