public static Grid GenerateGrid(AbstractionModel model, int time) { List<List<LED>> map = new List<List<LED>>(); for (int i = 0; i < model.AbstractPositionModel.Count; i++) { List<LED> column = new List<LED>(); for (int j = 0; j < model.AbstractPositionModel[i].Length; j++) { column.Add(new LED(model.AbstractPositionModel[i][j], j + 1, Grid.Column[i])); } map.Add(column); } return new Grid(map); }
public static List<bool[]> GetPartInclusive(AbstractionModel am, int startColumn, int stopColumn) { if (startColumn < 0 | startColumn > am.AbstractPositionModel.Count - 1 | stopColumn > am.AbstractPositionModel.Count - 1 ) throw new ArgumentException(); List<bool[]> part = new List<bool[]>(); for(int i = startColumn; i <= stopColumn;i++) { List<bool> columnParts = new List<bool>(); for(int j = 0; j < am.AbstractPositionModel[i].Length; j++) { columnParts.Add(am.AbstractPositionModel[i][j]); } part.Add(columnParts.ToArray()); } return part; }
// Loads a symbol into the grid (positive) public void LoadModel(int column, AbstractionModel am, AbstractionLoadMode gr) { if (column < 0 | column >= map.Count) return; switch (gr) { case AbstractionLoadMode.Positive: { for (int i = column - 1; i < map.Count; i++) { for (int j = 0; j < am.AbstractPositionModel.Count; j++) { for (int h = 0; h < am.AbstractPositionModel[j].Length; h++) { if (map[i][h].State != am.AbstractPositionModel[j][h]) map[i][h].FlipState(); } } } } break; case AbstractionLoadMode.Negative: { for (int i = column - 1; i < map.Count; i++) { for (int j = 0; j < am.AbstractPositionModel.Count; j++) { for (int h = 0; h < am.AbstractPositionModel[j].Length; h++) { if (map[i][h].State == am.AbstractPositionModel[j][h]) map[i][h].FlipState(); } } } } break; } }