public override SolverUpdateable GetBaseJoint() { PointOnLineJoint polj = new PointOnLineJoint(Ent1.Body, Ent2.Body, Ent2.GetPosition().ToBVector(), Direction.Normalize().ToBVector(), Ent2.GetPosition().ToBVector()); //polj.SpringSettings.Stiffness = DEF_STIFF * 400; //polj.SpringSettings.Damping = DEF_DAMP * 400; return(polj); }
public FrmEditPofile(Ent2 ent, DataTable source, bool isEdit) { InitializeComponent(); this._myEnt = ent; this._isEdit = isEdit; ResultTable = source.Copy(); this.StartPosition = FormStartPosition.CenterParent; }
public override SolverUpdateable GetBaseJoint() { LinearAxisMotor lam = new LinearAxisMotor(Ent1.Body, Ent2.Body, Ent2.GetPosition().ToBVector(), Ent2.GetPosition().ToBVector(), Axis.ToBVector()); lam.Settings.Mode = Mode ? MotorMode.Servomechanism : MotorMode.VelocityMotor; lam.Settings.Servo.Goal = 1; lam.Settings.Servo.SpringSettings.Stiffness = 300; lam.Settings.Servo.SpringSettings.Damping = 70; return(lam); }
private void btnDelProfile_Click(object sender, EventArgs e) { try { int index = gvResult.FocusedRowHandle; if (index < 0) { MessageBox.Show(@"请选择需要删除的板材", @"提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { Ent2 ent = new Ent2(); ent.Key = gvResult.GetRowCellValue(index, "Key").ToString(); Ent1 ent1 = new Ent1(); ent1.Length = Convert.ToInt32(gvResult.GetRowCellValue(index, "Length").ToString()); ent1.Qty = Convert.ToInt32(gvResult.GetRowCellValue(index, "Qty").ToString()); ent1.Area = Convert.ToInt32(gvResult.GetRowCellValue(index, "Area").ToString()); ent1.Depth = gvResult.GetRowCellValue(index, "Depth").ToString(); ent.MyEnt = ent1; string info = string.Format("确定要删除{0}中长度为【{1}】mm,面积为:【{2}】mm的【{3}】条型材?", ent.Key, ent.MyEnt.Length, ent.MyEnt.Area, ent.MyEnt.Qty); if (MessageBox.Show(info, @"提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { for (int i = 0; i < ResultTable.Rows.Count; i++) { if (ResultTable.Rows[i]["Key"].ToString() == ent.Key && ResultTable.Rows[i]["Length"].ToString() == ent.MyEnt.Length.ToString() && ResultTable.Rows[i]["Area"].ToString() == ent.MyEnt.Area.ToString() && ResultTable.Rows[i]["Qty"].ToString() == ent.MyEnt.Qty.ToString()) { ResultTable.Rows.RemoveAt(i); ResultTable.AcceptChanges(); break; } } DataRow[] tempRows = ResultTable.Select(string.Format("Key='{0}'", ent.Key)); int totalArea = 0; foreach (var row in tempRows) { totalArea += Convert.ToInt32(row["Qty"]) * Convert.ToInt32(row["Area"]); row["AreaSum"] = totalArea; } gcResult.DataSource = ResultTable; } } } catch (Exception ex) { MessageBox.Show(ex.Message, @"错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// 获取新的列表 /// </summary> /// <param name="list"></param> /// <returns></returns> private static List <Ent2> GetNewList(List <Ent1> list) { list = list.OrderByDescending(s => s.Length).ThenByDescending(s => s.Area).ToList(); List <Ent2> newList = new List <Ent2>(); int keyCount = 1000; foreach (var ent in list) { Ent2 ent2 = new Ent2(); ent2 = new Ent2(); ent2.MyEnt = ent; ent2.Key = "MyKey" + keyCount++; newList.Add(ent2); } return(newList); }
private void btnEditProfile_Click(object sender, EventArgs e) { try { int index = gvResult.FocusedRowHandle; if (index < 0) { MessageBox.Show(@"请选择需要修改的板材", @"提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { Ent2 ent = new Ent2(); ent.Key = gvResult.GetRowCellValue(index, "Key").ToString(); Ent1 ent1 = new Ent1(); ent1.Length = Convert.ToInt32(gvResult.GetRowCellValue(index, "Length").ToString()); ent1.Qty = Convert.ToInt32(gvResult.GetRowCellValue(index, "Qty").ToString()); ent1.Area = Convert.ToInt32(gvResult.GetRowCellValue(index, "Area").ToString()); ent1.Depth = gvResult.GetRowCellValue(index, "Depth").ToString(); ent.MyEnt = ent1; var frm = new FrmEditPofile(ent, ResultTable, true); if (frm.ShowDialog() == DialogResult.OK) { if (frm.ResultTable != null) { ResultTable = frm.ResultTable; } gcResult.DataSource = ResultTable; } frm.Dispose(); } } catch (Exception ex) { MessageBox.Show(ex.Message, @"错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static List <Ent2> CountList(List <Ent1> list) { List <Ent2> resultList = new List <Ent2>(); _index = 1; _maxNum = GetMaxNum(); try { List <Ent2> newList = GetNewList(list); newList = newList.OrderByDescending(s => s.MyEnt.Depth).ThenByDescending(s => s.MyEnt.Length).ThenByDescending(s => s.MyEnt.Area).ToList(); int total = 0; //剔除单个类型的型材可以满足一张板的型材 foreach (var item in newList) { total = item.MyEnt.Area * item.MyEnt.Qty; if (total <= _maxNum && total >= _maxNum - 10) { Ent2 tEnt2 = new Ent2(); tEnt2.Key = "BC" + _index++; tEnt2.MyEnt = item.MyEnt; tEnt2.Area = total; resultList.Add(tEnt2); _hasKey.Add(item.Key); } } START : RemoveItem(ref newList, _hasKey); total = 0; _hasKey.Clear(); if (newList.Count <= 0) { return(resultList); } int listIndex = 1; int listCount = newList.Count; string depth = string.Empty; foreach (var item in newList) { if (string.IsNullOrEmpty(depth)) { depth = item.MyEnt.Depth; } if (_hasKey.Contains(item.Key)) { continue; } if (item.MyEnt.Qty <= 0) { continue; } if (depth != item.MyEnt.Depth) { continue; } int tempQty = item.MyEnt.Qty; for (int i = 1; i <= tempQty; i++) { total += item.MyEnt.Area; if (total <= _maxNum && total >= _maxNum - 10) { Ent1 tEnt = new Ent1(); tEnt.Length = item.MyEnt.Length; tEnt.Area = item.MyEnt.Area; tEnt.Depth = item.MyEnt.Depth; tEnt.Path = item.MyEnt.Path; tEnt.Qty = i; Ent2 tEnt2 = new Ent2(); tEnt2.Key = "BC" + _index; tEnt2.MyEnt = tEnt; tEnt2.Area = total; resultList.Add(tEnt2); if (i == tempQty) { _hasKey.Add(item.Key); } _index++; item.MyEnt.Qty -= i; goto START; } else if (total <= _maxNum && i == tempQty) { Ent1 tEnt = new Ent1(); tEnt.Length = item.MyEnt.Length; tEnt.Area = item.MyEnt.Area; tEnt.Qty = item.MyEnt.Qty; tEnt.Depth = item.MyEnt.Depth; tEnt.Path = item.MyEnt.Path; Ent2 tEnt2 = new Ent2(); tEnt2.Key = "BC" + _index; tEnt2.MyEnt = tEnt; tEnt2.Area = total; resultList.Add(tEnt2); _hasKey.Add(item.Key); } else if (total == _maxNum && i < tempQty) { Ent1 tEnt = new Ent1(); tEnt.Length = item.MyEnt.Length; tEnt.Area = item.MyEnt.Area; tEnt.Qty = i; tEnt.Depth = item.MyEnt.Depth; tEnt.Path = item.MyEnt.Path; Ent2 tEnt2 = new Ent2(); tEnt2.Key = "BC" + _index; tEnt2.MyEnt = tEnt; tEnt2.Area = total; resultList.Add(tEnt2); item.MyEnt.Qty -= i; _index++; goto START; } else if (total > _maxNum && i != tempQty) { total -= item.MyEnt.Area; if (total < _maxNum) { Ent1 tEnt = new Ent1(); tEnt.Length = item.MyEnt.Length; tEnt.Area = item.MyEnt.Area; tEnt.Depth = item.MyEnt.Depth; tEnt.Path = item.MyEnt.Path; tEnt.Qty = (i - 1); Ent2 tEnt2 = new Ent2(); tEnt2.Key = "BC" + _index; tEnt2.MyEnt = tEnt; tEnt2.Area = total; resultList.Add(tEnt2); item.MyEnt.Qty -= (i - 1); } break; } else if (total > _maxNum && i == tempQty) { if (tempQty > 1) { Ent1 tEnt = new Ent1(); tEnt.Length = item.MyEnt.Length; tEnt.Area = item.MyEnt.Area; tEnt.Depth = item.MyEnt.Depth; tEnt.Path = item.MyEnt.Path; tEnt.Qty = (i - 1); Ent2 tEnt2 = new Ent2(); tEnt2.Key = "BC" + _index; tEnt2.MyEnt = tEnt; tEnt2.Area = total - item.MyEnt.Area * (i - 1); resultList.Add(tEnt2); item.MyEnt.Qty -= (i - 1); if (listIndex == listCount) { _index++; goto START; } } total -= item.MyEnt.Area; } } listIndex++; } if (newList.Count > 0) { _index++; goto START; } } catch (Exception) { throw; } return(resultList); }
public override SolverUpdateable GetBaseJoint() { DistanceLimit dl = new DistanceLimit(Ent1.Body, Ent2.Body, (Ent1Pos + Ent1.GetPosition()).ToBVector(), (Ent2Pos + Ent2.GetPosition()).ToBVector(), Min, Max); return(dl); }
public override SolverUpdateable GetBaseJoint() { return(new PointOnLineJoint(Ent1.Body, Ent2.Body, Ent2.GetPosition().ToBVector(), Direction.Normalize().ToBVector(), Ent2.GetPosition().ToBVector())); }
protected override void btnAdd_ItemClick(object sender, ItemClickEventArgs e) { base.btnAdd_ItemClick(sender, e); try { string key = txtkey.Text; int length = 0; int area = 0; int qty = 0; if (string.IsNullOrEmpty(txtkey.Text)) { MessageBox.Show(@"所属板材不能为空!", @"提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } if (string.IsNullOrEmpty(txtArea.Text)) { MessageBox.Show(@"型材面积不能为空!", @"提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } if (string.IsNullOrEmpty(txtLength.Text)) { MessageBox.Show(@"型材长度不能为空!", @"提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } if (string.IsNullOrEmpty(txtQty.Text)) { MessageBox.Show(@"型材数量不能为空!", @"提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } int.TryParse(txtArea.Text.Trim(), out area); int.TryParse(txtLength.Text.Trim(), out length); int.TryParse(txtQty.Text.Trim(), out qty); if (!_isEdit) { _myEnt = new Ent2(); Ent1 ent1 = new Ent1(); ent1.Qty = qty; ent1.Length = length; ent1.Area = area; ent1.Depth = txtDepth.Text.Trim(); _myEnt.Key = txtkey.Text.Trim().ToUpper(); _myEnt.MyEnt = ent1; DataRow newRow = ResultTable.NewRow(); newRow["Key"] = _myEnt.Key; newRow["Key1"] = _myEnt.Key; if (_myEnt.Area == 0) { _myEnt.Area = _myEnt.MyEnt.Area * _myEnt.MyEnt.Qty; } newRow["AreaSum"] = _myEnt.Area; newRow["Length"] = _myEnt.MyEnt.Length; newRow["Qty"] = _myEnt.MyEnt.Qty; newRow["Area"] = _myEnt.MyEnt.Area; newRow["Depth"] = _myEnt.MyEnt.Depth; ResultTable.Rows.Add(newRow); } else { DataRow[] rows = ResultTable.Select(string.Format("Depth = '{4}' AND Key='{0}' AND Length={1} AND Qty={2} AND Area={3}" , _myEnt.Key, _myEnt.MyEnt.Length, _myEnt.MyEnt.Qty, _myEnt.MyEnt.Area, _myEnt.MyEnt.Depth)); foreach (var row in rows) { row["Key"] = _myEnt.Key.ToUpper(); row["AreaSum"] = area * qty; row["Length"] = length; row["Qty"] = qty; row["Area"] = area; row["Depth"] = txtDepth.Text.Trim(); } } DataView dv = ResultTable.DefaultView; dv.Sort = "Key Asc,Length Desc"; ResultTable = dv.ToTable(); DataRow[] tempRows = ResultTable.Select(string.Format("Key='{0}'", _myEnt.Key)); int totalArea = 0; foreach (var row in tempRows) { totalArea += Convert.ToInt32(row["Qty"]) * Convert.ToInt32(row["Area"]); row["AreaSum"] = totalArea; } DialogResult = DialogResult.OK; } catch (Exception ex) { MessageBox.Show(ex.Message, @"提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } }