// init the tree by part name. private void InitTreeByPart() { partPmtTreeView.Nodes.Clear(); PartPmtListEx partPmtList = m_sheet.GetPartPmtList(); PartListEx partList = partPmtList.GetPartList(); for (int i = 0; i < partList.Size(); i++) { PartEx part = partList.GetPartByIndex(i); // append the part node. TreeNode partNode = partPmtTreeView.Nodes.Add(part.GetName()); partNode.ImageIndex = 0; partNode.SelectedImageIndex = 0; partNode.Tag = part.GetID(); // insert each part pmt node. PartPmtListEx partPmtList1 = partPmtList.GetAllPmtOfPart(part.GetID()); for (int j = 0; j < partPmtList1.Size(); j++) { PartPmtEx partPmt = partPmtList1.GetPartPmtByIndex(j); // append the part placement node. String strNodeName = "Placement "; strNodeName += (j + 1); TreeNode pmtNode = partNode.Nodes.Add(strNodeName); pmtNode.ImageIndex = 1; pmtNode.SelectedImageIndex = 1; pmtNode.Tag = partPmt.GetID(); } } }
// calc the utilization of the material. static public double CalcMatUtil(SheetListEx sheetList, NestParamEx nestParam) { double dUtilization = .0; // calculate the utilization of material. double dMatArea = .0, dNestedArea = .0; for (int i = 0; i < sheetList.Size(); i++) { SheetEx sheet = sheetList.GetSheetByIndex(i); int iSheetCount = sheet.GetCount(); dMatArea += sheet.GetMat().GetArea() * iSheetCount; // go through each part placement object in the sheet. PartPmtListEx partPmtList = sheet.GetPartPmtList(); for (int j = 0; j < partPmtList.Size(); j++) { PartPmtEx partPmt = partPmtList.GetPartPmtByIndex(j); PartEx part = partPmt.GetPart(); // the area of the part. double dPartArea = NestFacadeEx.GetPartArea(part, nestParam.GetConTol()); // part count in the part placement object. int iPartCount = 1; if (partPmt.IsGrid()) { iPartCount = partPmt.GetRowCount() * partPmt.GetColCount(); } dNestedArea += iSheetCount * iPartCount * dPartArea; } } // figure out the utilization. if (dMatArea == 0 || dNestedArea == 0) { dUtilization = .0; } else { dUtilization = (dNestedArea / dMatArea) * 100; } return(dUtilization); }
// draw the part placements. static public void DrawPartPmts(PartPmtListEx partPmts, PartPmtListEx selected_partPmts, GlViewPortEx viewPort, Dictionary <long, int> partColorConfig, ImpDataListEx impDataList) { for (int k = 0; k < partPmts.Size(); k++) { PartPmtEx partPmt = partPmts.GetPartPmtByIndex(k); PartEx part = partPmt.GetPart(); // set the color and line width. if (selected_partPmts != null && selected_partPmts.GetPartPmtByID(partPmt.GetID()) != null) { viewPort.SetLineWidth(6); viewPort.SetDrawColor(Color.Red); } else { viewPort.SetLineWidth(2); int iColor = partColorConfig[part.GetID()]; viewPort.SetDrawColor(ColorTranslator.FromOle(iColor)); } // get the ImpData object. ImpDataEx impData = null; for (int m = 0; m < impDataList.Size(); m++) { ImpDataEx tmpImpData = impDataList.GetImpDataByIndex(m); if (tmpImpData.GetPartID() == part.GetID()) { impData = tmpImpData; break; } } // draw the first instance in the grid. { // draw base geom. GeomItemListEx geomItems_not_poly = impData.GetBaseGeomList(); if (geomItems_not_poly != null) { viewPort.DrawGeomItemList_With_Mat(geomItems_not_poly, partPmt.GetMatrix()); } // draw poly data. PolyDataListEx polyDataList = impData.GetPolyDataList(); if (polyDataList != null) { for (int m = 0; m < polyDataList.Size(); m++) { PolyDataEx polyData = polyDataList.GetPolyDataByIndex(m); viewPort.DrawLoop_With_Mat(polyData, partPmt.GetMatrix()); } } } // draw other parts in the grid. if (partPmt.IsGrid()) { int iColCount = partPmt.GetColCount(); int iRowCount = partPmt.GetRowCount(); double dSpacingX = partPmt.GetSpacingX(); double dSpacingY = partPmt.GetSpacingY(); for (int i = 0; i < iColCount; i++) { for (int j = 0; j < iRowCount; j++) { if (i == 0 && j == 0) { continue; } // prepare the transform matrix. double dOffsetX = dSpacingX * i; double dOffsetY = dSpacingY * j; Vector2DEx offsetVect = new Vector2DEx(dOffsetX, dOffsetY); Matrix2DEx mat = partPmt.GetMatrix(); mat.Transfer(offsetVect.X(), offsetVect.Y()); // draw base geom. GeomItemListEx geomItems_not_poly = impData.GetBaseGeomList(); if (geomItems_not_poly != null) { viewPort.DrawGeomItemList_With_Mat(geomItems_not_poly, mat); } // draw poly data. PolyDataListEx polyDataList = impData.GetPolyDataList(); if (polyDataList != null) { for (int m = 0; m < polyDataList.Size(); m++) { PolyDataEx polyData = polyDataList.GetPolyDataByIndex(m); viewPort.DrawLoop_With_Mat(polyData, mat); } } } } } } }