示例#1
0
        // 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);
        }
示例#2
0
        // display the nesting result.
        private void DisplayNestResult()
        {
            if (m_sheetList == null)
            {
                return;
            }

            m_bDisableEvent = true;

            // display detail info of each sheet.
            shtListView.Items.Clear();
            for (int i = 0; i < m_sheetList.Size(); i++)
            {
                SheetEx sheet = m_sheetList.GetSheetByIndex(i);

                // insert a row.
                int          iCount = shtListView.Items.Count + 1;
                ListViewItem item   = shtListView.Items.Add(iCount.ToString());

                // "name" column.
                item.SubItems.Add(sheet.GetName());

                // "sheet count" column.
                item.SubItems.Add(sheet.GetCount().ToString());

                // "material name" column.
                item.SubItems.Add(sheet.GetMat().GetName());

                // hold the sheet ID.
                item.Tag = sheet.GetID();
            }

            /************************************************************************/
            // part group.

            NestPartListEx nestPartList = m_nestTask.GetNestPartList();

            // submitted part count.
            int iSubmitPartCount = 0;

            for (int i = 0; i < nestPartList.Size(); i++)
            {
                iSubmitPartCount += nestPartList.GetNestPartByIndex(i).GetNestCount();
            }
            subPartTextBox.Text = iSubmitPartCount.ToString();

            // the count of the nested parts.
            int iNestedPartCount = m_sheetList.GetPartInstTotalCount();

            nestPartTextBox.Text = iNestedPartCount.ToString();

            // display detailed info of each part.
            partListView.Items.Clear();
            for (int i = 0; i < nestPartList.Size(); i++)
            {
                NestPartEx nestPart = nestPartList.GetNestPartByIndex(i);
                PartEx     part     = nestPart.GetPart();

                // insert a row.
                int          iCount = partListView.Items.Count + 1;
                ListViewItem item   = partListView.Items.Add(iCount.ToString());

                // "name" column.
                item.SubItems.Add(part.GetName());

                // "submitted count" column.
                item.SubItems.Add(nestPart.GetNestCount().ToString());

                // "nested count" column.
                int iNestedCount = m_sheetList.GetPartInstCount(part.GetID());
                item.SubItems.Add(iNestedCount.ToString());
            }
            /************************************************************************/

            /************************************************************************/
            // material group.

            MatListEx matList = m_nestTask.GetMatList();

            // the utilization of material.
            double dUtilization = NestHelper.CalcMatUtil(m_sheetList, m_nestTask.GetNestParam());

            utilTextBox.Text = dUtilization.ToString("0.00");

            matListView.Items.Clear();
            for (int i = 0; i < matList.Size(); i++)
            {
                MatEx mat = matList.GetMatByIndex(i);

                // insert a row.
                int          iCount = matListView.Items.Count + 1;
                ListViewItem item   = matListView.Items.Add(iCount.ToString());

                // "name" column.
                item.SubItems.Add(mat.GetName());

                // "submitted count" column.
                item.SubItems.Add(mat.GetCount().ToString());

                // "consumed count" column.
                int iConsumedCount = m_sheetList.GetSheetCount(mat.GetID());
                item.SubItems.Add(iConsumedCount.ToString());
            }
            /************************************************************************/

            // preview the first sheet.
            if (shtListView.Items.Count > 0)
            {
                shtListView.Items[0].Selected = true;

                // get the select sheet.
                ListView.SelectedListViewItemCollection selItems = shtListView.SelectedItems;
                ListViewItem item          = selItems[0];
                long         iSheetID      = (long)item.Tag;
                SheetEx      selectedSheet = m_sheetList.GetSheetByID(iSheetID);

                // fit the window.
                DrawHelper.FitWindow(selectedSheet.GetMat().GetBoundaryRect(), m_shtViewPort, shtPreViewWnd);

                PreviewSheet();
            }

            m_bDisableEvent = false;
        }