예제 #1
0
    public AutoroutingMap(AutoroutingMap map)
    {
        Width  = map.Width;
        Height = map.Height;

        tiles = new AutoroutingTile[Width, Height];

        for (int y = 0; y < Height; y++)
        {
            for (int x = 0; x < Width; x++)
            {
                tiles[x, y] = new AutoroutingTile(x, y);

                tiles[x, y].Cost = map.tiles[x, y].Cost;
            }
        }

        foreach (AutoroutingNet n in map.nets)
        {
            AutoroutingNet autoroutingNet = new AutoroutingNet();
            foreach (AutoroutingTile t in n.Tiles)
            {
                autoroutingNet.Tiles.Add(tiles[t.X, t.Y]);
                tiles[t.X, t.Y].Net = autoroutingNet;
            }
            autoroutingNet.Start = tiles[n.Start.X, n.Start.Y];
            autoroutingNet.End   = tiles[n.End.X, n.End.Y];
            nets.Add(autoroutingNet);
        }
    }
예제 #2
0
    public AutoroutingMap(Map map)
    {
        Width  = map.Width;
        Height = map.Height;

        tiles = new AutoroutingTile[Width, Height];
        for (int y = 0; y < Height; y++)
        {
            for (int x = 0; x < Width; x++)
            {
                tiles[x, y]      = new AutoroutingTile(x, y);
                tiles[x, y].Cost = 1;
            }
        }

        foreach (Machine m in map.Machines)
        {
            foreach (Point p in m.GetOccupiedTiles())
            {
                tiles[p.X, p.Y].Cost = Single.PositiveInfinity;
            }
        }

        foreach (Conveyor n in map._conveyors)
        {
            AutoroutingNet autoroutingNet = new AutoroutingNet();
            foreach (ConveyorSegment t in n._segments)
            {
                foreach (Point p in t._start.GetPointsTo(t._end))
                {
                    autoroutingNet.Tiles.Add(tiles[p.X, p.Y]);
                    tiles[p.X, p.Y].Net = autoroutingNet;
                }
            }
            autoroutingNet.Start            = tiles[n._start.X, n._start.Y];
            autoroutingNet.End              = tiles[n._end.X, n._end.Y];
            autoroutingNet.originalConveyor = n;
            nets.Add(autoroutingNet);
        }
    }