public int CountOf(Detail detail) { foreach (OrderPair pair in Pairs) if (pair.Detail.Volume == detail.Volume) return pair.Num; return 0; }
public Cut(Detail billet_, Detail mainDetail_, double sectThick_, double left_) { billet = billet_; mainDetail = mainDetail_; sectThick = sectThick_; left = left_; }
public int GetNumber(Detail detail) { for (int i = 0; i < order.Count; i++) { if (order[i].Detail.Volume == detail.Volume) return i; } throw new InvalidProgramException("В разрезе нет детали, хотя должна быть)"); }
public OrderForm(int dimension) { InitializeComponent(); tbxCount.Text = Count.ToString(); switch(dimension){ case 1: Detail = new Detail1D(pgrdTest, new double[] { 1.0 }); break; case 2: Detail = new Detail2D(pgrdTest, new double[] { 1.0, 1.0 }); break; default: throw new NotImplementedException(); } pgrdTest.SelectedObject = Detail; }
public OrderForm(Detail det, int num) { InitializeComponent(); Count = num; tbxCount.Text = Count.ToString(); switch(det.Dimension){ case 1: Detail = new Detail1D(pgrdTest, new double[] { ((Detail1D)det).Length }); break; case 2: Detail = new Detail2D(pgrdTest, new double[] { ((Detail2D)det).Length, ((Detail2D)det).Width }); break; default: throw new NotImplementedException(); } pgrdTest.SelectedObject = Detail; }
public void Fill(Detail det, double sect) { int count = (int)(left / (det.Volume + sect)); int countSect = count; double fillSize = count * (det.Volume + sect); if (left - fillSize >= det.Volume) { count++; fillSize += det.Volume; } sectThick += countSect * sect; left -= fillSize; if (count != 0) Pairs.Add(new OrderPair(det, count)); }
public override Cut Fill(Detail det, double sect) { int count = (int)(Volume / (det.Volume + sect)); int countSect = count; double fillSize = count * (det.Volume + sect); if (Volume - fillSize >= det.Volume) { count++; fillSize += det.Volume; } Cut retCut = new Cut(this, det, countSect * sect, Volume - fillSize); retCut.Pairs.Add(new OrderPair(det, count)); return retCut; }
public Task(int dim, Detail billet_, OrderPair[] order_) { Dimension = dim; if (billet_.Dimension != Dimension) throw new InvalidOperationException("Размерность заготовки не совпадает с размерностью самой задачи!"); billet = billet_; foreach (OrderPair p in order_) { if (p.Detail.Dimension == Dimension) order.Add(p); else throw new InvalidOperationException("Размерность одной из деталей заказа не совпадает с размерностью самой задачи!"); } }
public bool Add(Detail det) { if (Left >= det.Volume) { bool exist = false; foreach (OrderPair p in Pairs) { if (p.Detail.Volume == det.Volume) { p.Num++; exist = true; break; } } if (!exist) Pairs.Add(new OrderPair(det, 1)); Left -= (det.Volume + sectThick); return true; } return false; }
public void Remove(Detail detail, double sect) { for (int i = 0; i < Pairs.Count; i++) { if (Pairs[i].Detail.Volume == detail.Volume) { Pairs[i].Num--; left += sect + Pairs[i].Detail.Volume; sectThick -= sect; if (Pairs[i].Num == 0) Pairs.RemoveAt(i); break; } } }
public Detail RemoveButNotLast(Detail lastMinDetail, double sect) { // не главную и не последнюю! for (int i = Pairs.Count - 1; i >= 0; i--) { if (Pairs[i].Detail.Volume != mainDetail.Volume) { if (lastMinDetail.Volume == Pairs[i].Detail.Volume) continue; Pairs[i].Num--; left += sect + Pairs[i].Detail.Volume; sectThick -= sect; if (i + 1 < Pairs.Count) for (int j = i + 1; j < Pairs.Count; j++) { left += (sect + Pairs[i + 1].Detail.Volume) * Pairs[i + 1].Num; sectThick -= sect * Pairs[i + 1].Num; Pairs.RemoveAt(i + 1); } if (Pairs[i].Num == 0) { Detail retDet = Pairs[i].Detail; Pairs.RemoveAt(i); return retDet; } return Pairs[i].Detail; } } return null; }
public abstract Cut Fill(Detail det, double sect);
public Task(Detail billet_) { Dimension = billet_.Dimension; billet = billet_; }
public OrderPair(Detail det, int numDet) { Detail = det; Num = numDet; }