示例#1
0
        public (SimpleCoordinates, SimpleCoordinates) mergeWith(
            SimpleCoordinates that)
        {
            SimpleCoordinates withThisX = new SimpleCoordinates(this.x, that.y);
            SimpleCoordinates withThisY = new SimpleCoordinates(that.x, this.y);

            return(withThisX, withThisY);
        }
示例#2
0
 private void drawStreetsAroundIn(SimpleCoordinates divisionCoordinates,
                                  Rect rect)
 {
     drawStreetBetweenAt(Defs.horizontal, rect.lowerBound.x,
                         rect.upperBound.x, divisionCoordinates.y);
     drawStreetBetweenAt(Defs.vertical, rect.lowerBound.y,
                         rect.upperBound.y, divisionCoordinates.x);
     this.map[divisionCoordinates.y, divisionCoordinates.x] += 2;
 }
示例#3
0
        public (Rect, Rect, Rect, Rect) divideAt(
            SimpleCoordinates divisionCoordinates)
        {
            (SimpleCoordinates, SimpleCoordinates)lowerMerge =
                this.lowerBound.mergeWith(divisionCoordinates);
            (SimpleCoordinates, SimpleCoordinates)upperMerge =
                divisionCoordinates.mergeWith(this.upperBound);
            Rect secondQuadrant = new Rect(lowerBound, divisionCoordinates);
            Rect thirdQuadrant  = new Rect(lowerMerge.Item1, upperMerge.Item1);
            Rect firstQuadrant  = new Rect(lowerMerge.Item2, upperMerge.Item2);
            Rect forthQuadrant  = new Rect(divisionCoordinates, upperBound);

            return(firstQuadrant, secondQuadrant, thirdQuadrant, forthQuadrant);
        }
示例#4
0
        private void makeSubMapQuadrantsOn(Rect rect)
        {
            if (!rect.canBeDividedWithAtLeast(this.minSpaceBetweenStreets) ||
                !DivisionPoint.hasDivisionWithNoAdjacentStreets(rect))
            {
                return;
            }
            SimpleCoordinates divisionCoordinates = getDivisionCoordinates(rect);

            drawStreetsAroundIn(divisionCoordinates, rect);
            (Rect firstQuadrant, Rect secondQuadrant, Rect thirdQuadrant,
             Rect fourthQuadrant) = rect.divideAt(divisionCoordinates);
            // Order matters here! Otherwise checking adjacent street corners may fail.
            makeSubMapQuadrantsOn(secondQuadrant);
            makeSubMapQuadrantsOn(thirdQuadrant);
            makeSubMapQuadrantsOn(firstQuadrant);
            makeSubMapQuadrantsOn(fourthQuadrant);
        }
示例#5
0
 public Rect(uint xInit, uint yInit, uint xEnd, uint yEnd)
 {
     this.lowerBound = new SimpleCoordinates(xInit, yInit);
     this.upperBound = new SimpleCoordinates(xEnd, yEnd);
 }
示例#6
0
 public Rect(
     SimpleCoordinates lowerBound, SimpleCoordinates upperBound)
 {
     this.lowerBound = lowerBound;
     this.upperBound = upperBound;
 }