public bool AddCellSilicon(Position position, SiliconType siliconType) { var cell = _cellMatrix[position]; if (!cell.IsValidCell || IsCellLocked(cell) || cell.Silicon != SiliconLayerContent.None) { return(false); } var slcType = siliconType == SiliconType.NType ? SiliconLayerContent.NType : SiliconLayerContent.PType; _cellMatrix.UpdateCellContent(position, new CellContent(cell) { Silicon = slcType }); return(true); }
public Layer(SavedLayer savedLayer) : this(savedLayer.Template) { var layerData = savedLayer.Data; // todo: verification var height = layerData.Cells.GetLength(0); var width = layerData.Cells.GetLength(1); if (width != Template.Width || height != Template.Height) { throw new ArgumentException(); } if (layerData.RightLinks.GetLength(0) != height || layerData.RightLinks.GetLength(1) != width) { throw new ArgumentException(); } if (layerData.BottomLinks.GetLength(0) != height || layerData.BottomLinks.GetLength(1) != width) { throw new ArgumentException(); } Width = width; Height = height; _cellMatrix = new LayerCellMatrix(this); for (var i = 0; i < height; i++) { for (var j = 0; j < width; j++) { _cellMatrix.UpdateCellContent(new Position(j, i), layerData.Cells[i, j]); _cellMatrix.UpdateLinkContent(new Position(j, i), Side.Right, layerData.RightLinks[i, j]); _cellMatrix.UpdateLinkContent(new Position(j, i), Side.Bottom, layerData.BottomLinks[i, j]); } } CommitChanges(false); }