Пример #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;
 }