private void btSelectSolution_Click(object sender, EventArgs e)
 {
     try
     {
         int iSel = GetCurrentSolutionIndex();
         // get selected solution
         _sol = gridSolutions.Rows[iSel].Tag as PackPalletSolution;
         if (null == _sol)
         {
             return;
         }
         if (!_analysis.HasSolutionSelected(_sol))
         {
             _analysis.SelectSolutionBySol(_sol);
         }
         else
         {
             _analysis.UnselectSolutionBySol(_sol);
         }
     }
     catch (Exception ex)
     {
         _log.Error(ex.ToString());
     }
 }
Beispiel #2
0
 public SelPackPalletSolution(Document document, PackPalletAnalysis analysis, PackPalletSolution sol)
     : base(document)
 {
     _analysis = analysis;
     _solution = sol;
     ID.Name   = sol.Title;
 }
        private int GetCurrentSolutionIndex()
        {
            PackPalletSolution sol = GetCurrentSolution();

            if (null == sol)
            {
                return(-1);
            }
            // find and return index of sol
            return(_analysis.Solutions.IndexOf(sol, 0));
        }
 public void Update(ItemBase item)
 {
     // update grid
     FillGrid();
     // select first solution
     if (gridSolutions.RowsCount > 0)
     {
         gridSolutions.Selection.SelectRow(1, true);
     }
     if (_analysis.Solutions.Count > 0)
     {
         _sol = _analysis.Solutions[0];
     }
     // draw
     graphCtrlSolution.Invalidate();
 }
 private void onGridSolutionSelectionChanged(object sender, SourceGrid.RangeRegionChangedEventArgs e)
 {
     SourceGrid.RangeRegion region = gridSolutions.Selection.GetSelectionRegion();
     int[] indexes = region.GetRowsIndex();
     // no selection -> exit
     if (indexes.Length == 0)
     {
         return;
     }
     // get selected solution
     _sol = gridSolutions.Rows[indexes[0]].Tag as PackPalletSolution;
     //_sol = _analysis.Solutions[indexes[0]];
     // update select/unselect button text
     UpdateSelectButtonText();
     // redraw
     graphCtrlSolution.Invalidate();
 }
        /// <summary>
        /// grid line clicked
        /// </summary>
        private void clickEvent_Click(object sender, EventArgs e)
        {
            SourceGrid.CellContext context = (SourceGrid.CellContext)sender;
            int iSel = context.Position.Row;

            // select row
            gridSolutions.Selection.SelectRow(iSel, true);
            // get selected solution
            PackPalletSolution sol = gridSolutions.Rows[iSel].Tag as PackPalletSolution;

            if (!_analysis.HasSolutionSelected(sol))
            {
                _analysis.SelectSolutionBySol(sol);
            }
            else
            {
                _analysis.UnselectSolutionBySol(sol);
            }
        }
Beispiel #7
0
        private List <PackPalletSolution> GenerateSolutions()
        {
            List <PackPalletSolution> solutions = new List <PackPalletSolution>();

            HalfAxis.HAxis[] axes = { HalfAxis.HAxis.AXIS_Z_N, HalfAxis.HAxis.AXIS_Z_P };
            // loop throught all patterns
            foreach (LayerPattern pattern in _patterns)
            {
                // loop throught all axes
                foreach (HalfAxis.HAxis axis in axes) // axis
                {
                    // loop through
                    Layer  layer = new Layer(_packProperties, _palletProperties, _constraintSet, axis, false);
                    double actualLength = 0.0, actualWidth = 0.0;
                    if (!pattern.GetLayerDimensionsChecked(layer, out actualLength, out actualWidth))
                    {
                        continue;
                    }
                    pattern.GenerateLayer(layer, actualLength, actualWidth);

                    // filter by layer weight
                    if (_constraintSet.MaximumLayerWeight.Activated &&
                        (layer.Count * _packProperties.Weight > _constraintSet.MaximumLayerWeight.Value))
                    {
                        continue;
                    }
                    // filter by maximum space
                    if (_constraintSet.MaximumSpaceAllowed.Activated &&
                        layer.MaximumSpace > _constraintSet.MaximumSpaceAllowed.Value)
                    {
                        continue;
                    }
                    double layerHeight = layer.BoxHeight;

                    string   title    = string.Format("{0}-{1}", pattern.Name, axis.ToString());
                    double   zLayer   = 0.0;
                    BoxLayer boxLayer = new BoxLayer(zLayer, "");
                    foreach (LayerPosition layerPos in layer)
                    {
                        LayerPosition layerPosTemp = AdjustLayerPosition(layerPos);
                        BoxPosition   boxPos       = new BoxPosition(
                            layerPosTemp.Position
                            - (0.5 * _constraintSet.OverhangX) * Vector3D.XAxis
                            - (0.5 * _constraintSet.OverhangY) * Vector3D.YAxis
                            + zLayer * Vector3D.ZAxis
                            , layerPosTemp.LengthAxis
                            , layerPosTemp.WidthAxis
                            );
                        boxLayer.Add(boxPos);
                    }
                    boxLayer.MaximumSpace = layer.MaximumSpace;
                    BBox3D layerBBox = boxLayer.BoundingBox(_packProperties);
                    // filter by overhangX
                    if (_constraintSet.MinOverhangX.Activated &&
                        (0.5 * (layerBBox.Length - _palletProperties.Length) < _constraintSet.MinOverhangX.Value))
                    {
                        continue;
                    }
                    // filter by overhangY
                    if (_constraintSet.MinOverhangY.Activated &&
                        (0.5 * (layerBBox.Width - _palletProperties.Width) < _constraintSet.MinOverhangY.Value))
                    {
                        continue;
                    }

                    double interlayerThickness = null != _interlayerProperties ? _interlayerProperties.Thickness : 0;
                    double interlayerWeight    = null != _interlayerProperties ? _interlayerProperties.Weight : 0;

                    PackPalletSolution sol = new PackPalletSolution(null, title, boxLayer);
                    int noLayer            = 1,
                        noInterlayer       = (null != _interlayerProperties && _constraintSet.HasFirstInterlayer) ? 1 : 0;

                    bool maxHeightReached = _constraintSet.MaximumPalletHeight.Activated &&
                                            (_packProperties.Height
                                             + noInterlayer * interlayerThickness
                                             + noLayer * layer.BoxHeight) > _constraintSet.MaximumPalletHeight.Value;
                    bool maxWeightReached = _constraintSet.MaximumPalletWeight.Activated &&
                                            (_palletProperties.Weight
                                             + noInterlayer * interlayerWeight
                                             + noLayer * boxLayer.Count * _packProperties.Weight > _constraintSet.MaximumPalletWeight.Value);

                    noLayer = 0; noInterlayer = 0;
                    int  iCountInterlayer = 0, iCountSwap = 1;
                    bool bSwap = false;
                    while (!maxHeightReached && !maxWeightReached)
                    {
                        bool bInterlayer = (0 == iCountInterlayer) && ((noLayer != 0) || _constraintSet.HasFirstInterlayer);
                        // actually insert new layer
                        sol.AddLayer(bSwap, bInterlayer);
                        // increment number of layers
                        noLayer++;
                        noInterlayer += (bInterlayer ? 1 : 0);
                        // update iCountInterlayer && iCountSwap
                        ++iCountInterlayer;
                        if (iCountInterlayer >= _constraintSet.InterlayerPeriod)
                        {
                            iCountInterlayer = 0;
                        }
                        ++iCountSwap;
                        if (iCountSwap > _constraintSet.LayerSwapPeriod)
                        {
                            iCountSwap = 1; bSwap = !bSwap;
                        }
                        // update maxHeightReached & maxWeightReached
                        maxHeightReached = _constraintSet.MaximumPalletHeight.Activated &&
                                           (_palletProperties.Height
                                            + (noInterlayer + (iCountInterlayer == 0 ? 1 : 0)) * interlayerThickness
                                            + (noLayer + 1) * layer.BoxHeight) > _constraintSet.MaximumPalletHeight.Value;
                        maxWeightReached = _constraintSet.MaximumPalletWeight.Activated &&
                                           (_palletProperties.Weight
                                            + (noInterlayer + (iCountInterlayer == 0 ? 1 : 0)) * interlayerWeight
                                            + (noLayer + 1) * boxLayer.Count * _packProperties.Weight > _constraintSet.MaximumPalletWeight.Value);
                    }

                    if (sol.PackCount > 0)
                    {
                        solutions.Add(sol);
                    }
                } // axis
            }     // pattern
            solutions.Sort();
            return(solutions);
        }
Beispiel #8
0
 public PackPalletSolutionViewer(PackPalletSolution solution)
 {
     _analysis = null != solution ? solution.Analysis : null;
     _solution = solution;
 }