public Cell(int x, int y, Circuit circuit) { this.circuit = circuit; this.x = x; this.y = y; layers = new CellLayer[Enum.GetValues(typeof(LayerType)).Length]; for (int clid = 0; clid < layers.Length; clid++) { layers[clid] = new CellLayer((Cell.LayerType)Enum.GetValues(typeof(Cell.LayerType)).GetValue(clid), this); } }
private CellLayerGroup createGroup(CellLayer cl) { CellLayerGroup layerGroup = new CellLayerGroup(); if (cl.groupedIn == false) { layerGroup.layers.Add(cl); cl.groupedIn = true; } connectLayers(cl, layerGroup); return layerGroup; }
// ajoute récursivement les cellules dans un groupe private void connectLayers(CellLayer cl, CellLayerGroup layerGroup) { foreach (Cell c in cl.links) { // cellule existante encore non groupée. arrêt à la première porte if (c != null && c.layers[(int)cl.layerType].groupedIn == false && c.layers[(int)Cell.LayerType.NPN].isSet == false && c.layers[(int)Cell.LayerType.PNP].isSet == false ) { layerGroup.layers.Add(c.layers[(int)cl.layerType]); c.layers[(int)cl.layerType].groupedIn = true; if (c.layers[(int)cl.layerType].parentCell.via) layerGroup.viaCells.Add(c); connectLayers(c.layers[(int)cl.layerType], layerGroup); } // ajout d'une porte à la liste de portes if (c != null) { if (c.layers[(int)Cell.LayerType.NPN].isSet && c.layers[(int)Cell.LayerType.NPN].groupedIn == false ) { c.layers[(int)Cell.LayerType.NPN].groupedIn = true; subGates.Add(c); } else if (c.layers[(int)Cell.LayerType.PNP].isSet && c.layers[(int)Cell.LayerType.PNP].groupedIn == false ) { c.layers[(int)Cell.LayerType.PNP].groupedIn = true; subGates.Add(c); } } } }