Example #1
0
        private void btAddPackPalletAnalysis_Click(object sender, EventArgs e)
        {
            try
            {
                // get selected box
                BoxProperties boxProperties = SelectedBox;
                // get selected pallet
                PalletProperties palletProperties = SelectedPallet;
                // get selected caseOptimSolution
                CaseOptimSolution sol         = SelectedSolution;
                PackArrangement   arrangement = sol.CaseDefinition.Arrangement;
                // build new case name
                string name = string.Format("{0}_{1}*{2}*{3}_{4}{5}"
                                            , boxProperties.Name
                                            , arrangement._iLength
                                            , arrangement._iWidth
                                            , arrangement._iHeight
                                            , sol.CaseDefinition.Dim0
                                            , sol.CaseDefinition.Dim1);
                // build new case description
                string description = string.Format("Case generated by case optimization for box {0} and pallet {1}"
                                                   , boxProperties.Name
                                                   , palletProperties.Name);
                // analysis name/description
                string analysisName = string.Format("OptimAnalysis{0}_{1}*{2}*{3}_{4}{5}"
                                                    , boxProperties.Name
                                                    , boxProperties.Name
                                                    , arrangement._iLength
                                                    , arrangement._iWidth
                                                    , arrangement._iHeight
                                                    , sol.CaseDefinition.Dim0
                                                    , sol.CaseDefinition.Dim1);
                string analysisDescription = string.Format("Pallet analysis generated by case optimisation for box {0} and pallet {1}"
                                                           , boxProperties.Name
                                                           , palletProperties.Name);
                // create PackProperties
                HalfAxis.HAxis axis          = PackProperties.Orientation(sol.CaseDefinition.Dim0, sol.CaseDefinition.Dim1);
                double         wrapperWeight = WrapperCardboard.EstimateWeight(
                    SelectedBox
                    , arrangement
                    , axis
                    , NoWalls
                    , WallThickness
                    , WallSurfaceMass);
                // cardboard wrapper
                WrapperCardboard wrapper = new WrapperCardboard(WallThickness, wrapperWeight, Color.Chocolate);
                wrapper.SetNoWalls(NoWalls[0], NoWalls[1], NoWalls[2]);
                // pack
                PackProperties pack = _document.CreateNewPack(
                    name, description
                    , boxProperties, arrangement, axis
                    , wrapper);
                // constraint set
                ConstraintSetCasePallet constraintSet = new ConstraintSetCasePallet();
                constraintSet.Overhang = new Vector2D(OverhangX, OverhangY);
                constraintSet.SetMaxHeight(new OptDouble(true, MaximumPalletHeight));
                constraintSet.OptMaxWeight = new OptDouble(false, 0);
                // interlayer
                List <InterlayerProperties> listInterlayers = new List <InterlayerProperties>();
                // layer desc
                List <LayerDesc> layerDescs = new List <LayerDesc>();
                // create analysis
                Analysis analysis = _document.CreateNewAnalysisCasePallet(
                    analysisName, analysisDescription
                    , pack, palletProperties
                    , listInterlayers
                    , null, null, null
                    , constraintSet, layerDescs
                    );

                /*
                 * // constraint set
                 * PackPalletConstraintSet constraintSet = new PackPalletConstraintSet();
                 * constraintSet.OverhangX = OverhangX;
                 * constraintSet.OverhangY = OverhangY;
                 * constraintSet.MaximumPalletHeight = new OptDouble(true, MaximumPalletHeight);
                 * // create analysis
                 * _document.CreateNewPackPalletAnalysis(
                 *  analysisName
                 *  , analysisDescription
                 *  , pack
                 *  , palletProperties
                 *  , null
                 *  , constraintSet
                 *  , new PackPalletSolver());
                 */
            }
            catch (Exception ex)
            {
                _log.Error(ex.ToString());
            }
        }
 public void Draw(Graphics3DControl ctrl, Graphics3D graphics)
 {
     // ### draw pallet
     if (graphCtrlPallet == ctrl)
     {
         PalletProperties pp     = SelectedPallet;
         Pallet           pallet = new Pallet(pp);
         pallet.Draw(graphics, Transform3D.Identity);
         DimensionCube dc = new DimensionCube(pp.Length, pp.Width, pp.Height)
         {
             FontSize = 6.0f
         };
         graphics.AddDimensions(dc);
     }
     // ### draw case definition
     else if (ctrl == graphCtrlBoxesLayout)
     {
         // ### draw case definition
         try
         {
             // get selected solution
             CaseOptimSolution solution = SelectedSolution;
             if (null == solution)
             {
                 return;
             }
             // instantiate case definition viewer
             CaseDefinitionViewer cdv = new CaseDefinitionViewer(SelectedSolution.CaseDefinition, SelectedBox, BuildCaseOptimConstraintSet());
             cdv.Orientation = SelectedSolution.PalletSolution.FirstCaseOrientation;
             cdv.Draw(graphics);
         }
         catch (Exception ex)
         {
             _log.Error(ex.ToString());
         }
     }
     // ### draw associated pallet solution
     else if (ctrl == graphCtrlPalletLayout)
     {
         try
         {
             // get selected solution
             CaseOptimSolution solution = SelectedSolution;
             // get selected box
             BoxProperties boxProperties = SelectedBox;
             // get selected pallet
             PalletProperties palletProperties = SelectedPallet;
             if (null != solution && null != boxProperties && null != palletProperties)
             {
                 Vector3D      outerDim       = solution.CaseDefinition.OuterDimensions(boxProperties, BuildCaseOptimConstraintSet());
                 BoxProperties caseProperties = new BoxProperties(null, outerDim.X, outerDim.Y, outerDim.Z);
                 caseProperties.SetColor(Color.Chocolate);
                 CasePalletSolutionViewer.Draw(graphics, solution.PalletSolution, caseProperties, null, palletProperties);
             }
         }
         catch (Exception ex)
         {
             _log.Error(ex.ToString());
         }
     }
 }
Example #3
0
        private void btAddCasePalletAnalysis_Click(object sender, EventArgs e)
        {
            try
            {
                // get selected box
                BoxProperties boxProperties = SelectedBox;
                // get selected pallet
                PalletProperties palletProperties = SelectedPallet;
                // get selected caseOptimSolution
                CaseOptimSolution sol         = SelectedSolution;
                PackArrangement   arrangement = sol.CaseDefinition.Arrangement;
                // build new case name
                string name = string.Format("{0}_{1}*{2}*{3}_{4}{5}"
                                            , boxProperties.Name
                                            , arrangement._iLength
                                            , arrangement._iWidth
                                            , arrangement._iHeight
                                            , sol.CaseDefinition.Dim0
                                            , sol.CaseDefinition.Dim1);
                // build new case description
                string description = string.Format("Case generated by case optimization for box {0} and pallet {1}"
                                                   , boxProperties.Name
                                                   , palletProperties.Name);
                // analysis name/description
                string analysisName = string.Format("OptimAnalysis{0}_{1}*{2}*{3}_{4}{5}"
                                                    , boxProperties.Name
                                                    , boxProperties.Name
                                                    , arrangement._iLength
                                                    , arrangement._iWidth
                                                    , arrangement._iHeight
                                                    , sol.CaseDefinition.Dim0
                                                    , sol.CaseDefinition.Dim1);
                string analysisDescription = string.Format("Pallet analysis generated by case optimisation for box {0} and pallet {1}"
                                                           , boxProperties.Name
                                                           , palletProperties.Name);
                // create PackProperties
                HalfAxis.HAxis axis          = PackProperties.Orientation(sol.CaseDefinition.Dim0, sol.CaseDefinition.Dim1);
                double         wrapperWeight = WrapperCardboard.EstimateWeight(
                    SelectedBox
                    , arrangement
                    , axis
                    , NoWalls
                    , WallThickness
                    , WallSurfaceMass);

/*
 *              // add new case
 *              CaseOfBoxesProperties caseProperties = _document.CreateNewCaseOfBoxes(
 *                  name, description
 *                  , boxProperties
 *                  , sol.CaseDefinition
 *                  , BuildCaseOptimConstraintSet());
 *              // set color
 *              caseProperties.SetColor(Color.Chocolate);
 *              // add new pallet analysis
 *              List<CasePalletSolution> palletSolutionList = new List<CasePalletSolution>();
 *              palletSolutionList.Add(sol.PalletSolution);
 *              Analysis analysis = _document.CreateNewCasePalletAnalysis(
 *                  analysisName
 *                  , analysisDescription
 *                  , caseProperties
 *                  , palletProperties
 *                  , null, null
 *                  , null, null, null
 *                  , BuildCasePalletConstraintSet()
 *                  , palletSolutionList);
 */
            }
            catch (Exception ex)
            {
                _log.Error(ex.ToString());
            }
        }
        private bool GenerateProject(out Document doc, out CasePalletAnalysis analysis, out CasePalletSolution casePalletSolution)
        {
            doc                = null;
            analysis           = null;
            casePalletSolution = null;

            try
            {
                // build solution
                doc = new Document(
                    _boxName,
                    string.Format(Properties.Resources.ID_OPTDOCUMENTDESCRIPTION, _boxName),
                    string.Empty,
                    DateTime.Now,
                    null);
                // box
                BoxProperties boxProperties = doc.CreateNewBox(SelectedBox);
                // pallet
                PalletProperties palletProperties = doc.CreateNewPallet(SelectedPallet);
                // get selected caseOptimSolution
                CaseOptimSolution sol         = SelectedSolution;
                PackArrangement   arrangement = sol.CaseDefinition.Arrangement;
                // build new case name
                string arrangName = string.Format("{0}_{1}x{2}x{3}_{4}{5}"
                                                  , boxProperties.Name
                                                  , arrangement._iLength
                                                  , arrangement._iWidth
                                                  , arrangement._iHeight
                                                  , sol.CaseDefinition.Dim0
                                                  , sol.CaseDefinition.Dim1);
                // build new case description
                string description = string.Format(
                    Properties.Resources.ID_OPTCASEDESCRIPTION
                    , boxProperties.Name
                    , palletProperties.Name);
                // add new case
                CaseOfBoxesProperties caseProperties = doc.CreateNewCaseOfBoxes(
                    arrangName, description
                    , boxProperties
                    , sol.CaseDefinition
                    , BuildCaseOptimConstraintSet());
                // set color
                caseProperties.SetColor(Color.Chocolate);
                // add new pallet analysis
                string analysisName = string.Format(
                    Properties.Resources.ID_OPTANALYSISNAME
                    , boxProperties.Name
                    , boxProperties.Name
                    , arrangement._iLength
                    , arrangement._iWidth
                    , arrangement._iHeight
                    , sol.CaseDefinition.Dim0
                    , sol.CaseDefinition.Dim1);
                string analysisDescription = string.Format(
                    Properties.Resources.ID_OPTANALYSISDESCRIPTION
                    , boxProperties.Name
                    , palletProperties.Name);
                List <CasePalletSolution> palletSolutionList = new List <CasePalletSolution>();
                palletSolutionList.Add(sol.PalletSolution);
                analysis = doc.CreateNewCasePalletAnalysis(
                    analysisName
                    , analysisDescription
                    , caseProperties
                    , palletProperties
                    , null
                    , null
                    , null
                    , null
                    , null
                    , BuildPalletConstraintSet()
                    , palletSolutionList);
            }
            catch (Exception ex)
            {
                _log.Error(ex.ToString());
                return(false);
            }
            return(true);
        }