/// <summary> /// Initialize simulator for given building and people map /// </summary> /// <param name="bm">Building map</param> /// <param name="pm">People map</param> public void SetupSimulator(BuildingMap bm, PeopleMap pm) { if (bm == null) return; if (pm == null) return; _buildingMap = bm; _peopleMap = pm; _evacuationMap.InitializeFromBuildingMap(_buildingMap); }
/// <summary> /// Method initializes evacuation map from given building map /// </summary> /// <param name="bm">Building map</param> public void InitializeFromBuildingMap(BuildingMap bm) { _map = new SortedDictionary<int, IDictionary<int, IDictionary<int, EvacuationElement>>>(); //setup shape and neighbourhood passages foreach(var e in bm.Floors) { Floor f = e.Value; int level = e.Key; IDictionary<int, IDictionary<int, EvacuationElement>> floorMap = new SortedDictionary<int, IDictionary<int, EvacuationElement>>(); foreach (var row in f.Tiles) { IDictionary<int, EvacuationElement> tempRow = new SortedDictionary<int, EvacuationElement>(); foreach (var tile in row.Value) { EvacuationElement ee = new EvacuationElement(tile.Value.Capacity); //setup passages for (int i = 0; i < 4; ++i) { ee.NeighboursPassages[i] = tile.Value.Side[i]; } tempRow.Add(tile.Key, ee); } floorMap.Add(row.Key, tempRow); } _map.Add(level, floorMap); } //setup neighbourhood foreach (var floor in _map) { foreach (var row in floor.Value) { foreach (var tile in row.Value) { tile.Value.Neighbours[(int)Direction.DOWN] = Get(floor.Key, row.Key + 1, tile.Key); tile.Value.Neighbours[(int)Direction.UP] = Get(floor.Key, row.Key - 1, tile.Key); tile.Value.Neighbours[(int)Direction.LEFT] = Get(floor.Key, row.Key, tile.Key - 1); tile.Value.Neighbours[(int)Direction.RIGHT] = Get(floor.Key, row.Key, tile.Key + 1); //creating special evacuation element for stairs for (int i = 0; i < 4; ++i) { if (tile.Value.NeighboursPassages[i].Type == WallElementType.STAIR_ENTRY) { tile.Value.Neighbours[i] = new StairsEvacuationElement((StairsEntry)tile.Value.NeighboursPassages[i], this); } } } } } }