/// <summary> /// 开始排样 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void toolStripButton6_Click(object sender, EventArgs e) { if (listPlate.Count <= 0) { MessageBox.Show("请先加载需要排样的件号"); return; } #region 检查原材料是否符合标准 if (listStock.Count <= 0) { MessageBox.Show("请输入一定数量的原材料钢板"); return; } else { //for (int i = 0; i < listStock.Count; i++) //{ // Console.WriteLine("编号:{0},数量:{1}", // listStock[i].StockId, (listStock[i].Num - listStock[i].UseNum)); //} bool haveStock = false; for (int i = 0; i < listStock.Count; i++) { if (listStock[i].Num - listStock[i].UseNum > 0) { haveStock = true; } } if (!haveStock) { MessageBox.Show("请输入一定数量的原材料钢板"); return; } } #endregion GeneForm geneFrom = new GeneForm(this); geneFrom.ShowDialog(); #region 加载原材料钢板 for (int i = 0; i < listStock.Count; i++) { if (listStock[i].Num - listStock[i].UseNum > 0) { #region 加载原材料钢板的时候,创建原材料钢板的面域以及逆时针循环的点集 for (int j = 0; j < listStock[i].StockForm.Count; j++) { listStock[i].StockForm[j].ShapeID = CADInterface.globalID; CADInterface.globalID = CADInterface.globalID + 1; CADInterface.currentShapes.Add(listStock[i].StockForm[j]); } BaseModel newStockModel = new AddOper().addModel(listStock[i].StockForm); listStock[i].ListModel.Add(newStockModel); CADInterface.currentPlates.Add(newStockModel); CADInterface.nowStock = listStock[i]; newStockModel.Draw(CADInterface.bGrp.Graphics); ZoomOper zoom = new ShapeOper.ZoomOper(); zoom.zoomYuanCaiLiao(this.tableLayoutPanel1); CADInterface.DrawShap(); #endregion break; } } #endregion GeneSuanFa gene = new GeneSuanFa(); NFPSuanFa nfp = new NFPSuanFa(); #region 对读取的钢板件号进行遗传编码 geneCode.AddRange(gene.createGeneCode(listPlate)); #endregion //Console.WriteLine("种群大小:{0}", geneCode.Count); DateTime beforDT = System.DateTime.Now; PaiYangFangAn fangAn = nfp.createFirstFangAn(geneCode, CADInterface.nowStock, angleTest); DateTime afterDT = System.DateTime.Now; TimeSpan ts = afterDT.Subtract(beforDT); Console.WriteLine("获取初始解的时间:{0}", ts.TotalSeconds); DateTime beforDT1 = System.DateTime.Now; fangAn = gene.getFinallyFangAn(geneCode, fangAn); DateTime afterDT1 = System.DateTime.Now; TimeSpan ts1 = afterDT1.Subtract(beforDT1); Console.WriteLine("获取最终解的时间:{0}", ts1.TotalSeconds); Console.WriteLine("获取最终解的利用率:{0}", fangAn.LiYouLv); #region 最终方案中已使用的基因编码,置为true for (int i = 0; i < fangAn.ListPlate.Count; i++) { for (int j = 0; j < geneCode.Count; j++) { if (fangAn.ListPlate[i].Plate.InheritanceID == geneCode[j].InheritanceID) { geneCode[j].HadUsedGene = true; break; } } } #endregion }
/// <summary> /// 右击菜单,Zoom功能 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ZoomOper_Click(object sender, EventArgs e) { ZoomOper zoom = new ShapeOper.ZoomOper(); zoom.zoomYuanCaiLiao(this.tableLayoutPanel1); }