Exemplo n.º 1
0
        public Block(Street streetEast, Street streetSouth, Street streetWest, Street streetNorth,
            Intersection southEast, Intersection southWest, Intersection northEast, Intersection northWest)
        {
            this.SouthEast = southEast;
            this.SouthWest = southWest;
            this.NorthEast = northEast;
            this.NorthWest = northWest;
            this.Children = new List<Block>(4);
            this.streets = new[] { streetEast, streetSouth, streetWest, streetNorth };

            this.East = streetEast.Intersections[0].Position.X;
            this.West = streetWest.Intersections[0].Position.X;
            this.South = streetSouth.Intersections[0].Position.Y;
            this.North = streetNorth.Intersections[0].Position.Y;

            this.Width = this.East - this.West;
            this.Height = this.North - this.South;
        }
Exemplo n.º 2
0
        public static Block MakeRoot(float width, float height)
        {
            var x           = width / 2;
            var y           = height / 2;
            var streetWidth = 5.U();

            var i00 = new Intersection(-x, -y);
            var i10 = new Intersection(x, -y);
            var i01 = new Intersection(-x, y);
            var i11 = new Intersection(x, y);

            var sEast  = new Street(i11, i10, streetWidth);
            var sSouth = new Street(i10, i00, streetWidth);
            var sWest  = new Street(i00, i01, streetWidth);
            var sNorth = new Street(i01, i11, streetWidth);

            return(new Block(
                       sEast, sSouth, sWest, sNorth,
                       i10, i00, i11, i01
                       ));
        }
Exemplo n.º 3
0
        private void splitCross(Block block)
        {
            Unit streetWidthNS, streetWidthEW;
            var  x = this.divide(block.East, block.West, out streetWidthEW);
            var  y = this.divide(block.South, block.North, out streetWidthNS);

            var nodeCenter = new Intersection(x, y);
            var nodeEast   = new Intersection(block.East, y);
            var nodeWest   = new Intersection(block.West, y);
            var nodeSouth  = new Intersection(x, block.South);
            var nodeNorth  = new Intersection(x, block.North);

            var streetEast  = block[Block.Side.East];
            var streetWest  = block[Block.Side.West];
            var streetSouth = block[Block.Side.South];
            var streetNorth = block[Block.Side.North];

            streetEast.AddIntersection(nodeEast);
            streetWest.AddIntersection(nodeWest);
            streetSouth.AddIntersection(nodeSouth);
            streetNorth.AddIntersection(nodeNorth);

            var streetToEast  = new Street(nodeCenter, nodeEast, streetWidthEW);
            var streetToWest  = new Street(nodeCenter, nodeWest, streetWidthEW);
            var streetToSouth = new Street(nodeCenter, nodeSouth, streetWidthNS);
            var streetToNorth = new Street(nodeCenter, nodeNorth, streetWidthNS);

            var childSE = new Block(streetEast, streetSouth, streetToSouth, streetToEast, block.SouthEast, nodeSouth, nodeEast, nodeCenter);
            var childSW = new Block(streetToSouth, streetSouth, streetWest, streetToWest, nodeSouth, block.SouthWest, nodeCenter, nodeWest);
            var childNE = new Block(streetToNorth, streetToWest, streetWest, streetNorth, nodeCenter, nodeWest, nodeNorth, block.NorthWest);
            var childNW = new Block(streetEast, streetToEast, streetToNorth, streetNorth, nodeEast, nodeCenter, block.NorthEast, nodeNorth);

            block.Children.Add(childSE);
            block.Children.Add(childSW);
            block.Children.Add(childNE);
            block.Children.Add(childNW);
        }
Exemplo n.º 4
0
        private void splitNorthSouth(Block block)
        {
            Unit streetWidth;
            var  x = this.divide(block.East, block.West, out streetWidth);

            var nodeSouth = new Intersection(x, block.South);
            var nodeNorth = new Intersection(x, block.North);

            var streetEast  = block[Block.Side.East];
            var streetWest  = block[Block.Side.West];
            var streetSouth = block[Block.Side.South];
            var streetNorth = block[Block.Side.North];

            streetSouth.AddIntersection(nodeSouth);
            streetNorth.AddIntersection(nodeNorth);

            var streetSplit = new Street(nodeSouth, nodeNorth, streetWidth);

            var childE = new Block(streetEast, streetSouth, streetSplit, streetNorth, block.SouthEast, nodeSouth, block.NorthEast, nodeNorth);
            var childW = new Block(streetSplit, streetSouth, streetWest, streetNorth, nodeSouth, block.SouthWest, nodeNorth, block.NorthWest);

            block.Children.Add(childE);
            block.Children.Add(childW);
        }
Exemplo n.º 5
0
        private void splitEastWest(Block block)
        {
            Unit streetWidth;
            var  y = this.divide(block.South, block.North, out streetWidth);

            var nodeEast = new Intersection(block.East, y);
            var nodeWest = new Intersection(block.West, y);

            var streetEast  = block[Block.Side.East];
            var streetWest  = block[Block.Side.West];
            var streetSouth = block[Block.Side.South];
            var streetNorth = block[Block.Side.North];

            streetEast.AddIntersection(nodeEast);
            streetWest.AddIntersection(nodeWest);

            var streetSplit = new Street(nodeEast, nodeWest, streetWidth);

            var childS = new Block(streetEast, streetSouth, streetWest, streetSplit, block.SouthEast, block.SouthWest, nodeEast, nodeWest);
            var childN = new Block(streetEast, streetSplit, streetWest, streetNorth, nodeEast, nodeWest, block.NorthEast, block.NorthWest);

            block.Children.Add(childS);
            block.Children.Add(childN);
        }
Exemplo n.º 6
0
        private void splitNorthSouth(Block block)
        {
            Unit streetWidth;
            var x = this.divide(block.East, block.West, out streetWidth);

            var nodeSouth = new Intersection(x, block.South);
            var nodeNorth = new Intersection(x, block.North);

            var streetEast = block[Block.Side.East];
            var streetWest = block[Block.Side.West];
            var streetSouth = block[Block.Side.South];
            var streetNorth = block[Block.Side.North];

            streetSouth.AddIntersection(nodeSouth);
            streetNorth.AddIntersection(nodeNorth);

            var streetSplit = new Street(nodeSouth, nodeNorth, streetWidth);

            var childE = new Block(streetEast, streetSouth, streetSplit, streetNorth, block.SouthEast, nodeSouth, block.NorthEast, nodeNorth);
            var childW = new Block(streetSplit, streetSouth, streetWest, streetNorth, nodeSouth, block.SouthWest, nodeNorth, block.NorthWest);

            block.Children.Add(childE);
            block.Children.Add(childW);
        }
Exemplo n.º 7
0
        private void splitEastWest(Block block)
        {
            Unit streetWidth;
            var y = this.divide(block.South, block.North, out streetWidth);

            var nodeEast = new Intersection(block.East, y);
            var nodeWest = new Intersection(block.West, y);

            var streetEast = block[Block.Side.East];
            var streetWest = block[Block.Side.West];
            var streetSouth = block[Block.Side.South];
            var streetNorth = block[Block.Side.North];

            streetEast.AddIntersection(nodeEast);
            streetWest.AddIntersection(nodeWest);

            var streetSplit = new Street(nodeEast, nodeWest, streetWidth);

            var childS = new Block(streetEast, streetSouth, streetWest, streetSplit, block.SouthEast, block.SouthWest, nodeEast, nodeWest);
            var childN = new Block(streetEast, streetSplit, streetWest, streetNorth, nodeEast, nodeWest, block.NorthEast, block.NorthWest);

            block.Children.Add(childS);
            block.Children.Add(childN);
        }
Exemplo n.º 8
0
        private void splitCross(Block block)
        {
            Unit streetWidthNS, streetWidthEW;
            var x = this.divide(block.East, block.West, out streetWidthEW);
            var y = this.divide(block.South, block.North, out streetWidthNS);

            var nodeCenter = new Intersection(x, y);
            var nodeEast = new Intersection(block.East, y);
            var nodeWest = new Intersection(block.West, y);
            var nodeSouth = new Intersection(x, block.South);
            var nodeNorth = new Intersection(x, block.North);

            var streetEast = block[Block.Side.East];
            var streetWest = block[Block.Side.West];
            var streetSouth = block[Block.Side.South];
            var streetNorth = block[Block.Side.North];

            streetEast.AddIntersection(nodeEast);
            streetWest.AddIntersection(nodeWest);
            streetSouth.AddIntersection(nodeSouth);
            streetNorth.AddIntersection(nodeNorth);

            var streetToEast = new Street(nodeCenter, nodeEast, streetWidthEW);
            var streetToWest = new Street(nodeCenter, nodeWest, streetWidthEW);
            var streetToSouth = new Street(nodeCenter, nodeSouth, streetWidthNS);
            var streetToNorth = new Street(nodeCenter, nodeNorth, streetWidthNS);

            var childSE = new Block(streetEast, streetSouth, streetToSouth, streetToEast, block.SouthEast, nodeSouth, nodeEast, nodeCenter);
            var childSW = new Block(streetToSouth, streetSouth, streetWest, streetToWest, nodeSouth, block.SouthWest, nodeCenter, nodeWest);
            var childNE = new Block(streetToNorth, streetToWest, streetWest, streetNorth, nodeCenter, nodeWest, nodeNorth, block.NorthWest);
            var childNW = new Block(streetEast, streetToEast, streetToNorth, streetNorth, nodeEast, nodeCenter, block.NorthEast, nodeNorth);

            block.Children.Add(childSE);
            block.Children.Add(childSW);
            block.Children.Add(childNE);
            block.Children.Add(childNW);
        }
Exemplo n.º 9
0
        public static Block MakeRoot(float width, float height)
        {
            var x = width / 2;
            var y = height / 2;
            var streetWidth = 5.U();

            var i00 = new Intersection(-x, -y);
            var i10 = new Intersection(x, -y);
            var i01 = new Intersection(-x, y);
            var i11 = new Intersection(x, y);

            var sEast = new Street(i11, i10, streetWidth);
            var sSouth = new Street(i10, i00, streetWidth);
            var sWest = new Street(i00, i01, streetWidth);
            var sNorth = new Street(i01, i11, streetWidth);

            return new Block(
                sEast, sSouth, sWest, sNorth,
                i10, i00, i11, i01
                );
        }