Ejemplo n.º 1
0
        public void DrawLayer(Graphics3D graphics, int layerIndex)
        {
            // sanity check
            if (null == _solution)
            {
                return;
            }

            if (_showDimensions)
            {
                BoxLayer layer  = layerIndex % 2 == 0 ? _solution.Layer : _solution.LayerSwapped;
                uint     pickId = 0;
                foreach (BoxPosition bPosition in layer)
                {
                    graphics.AddBox(new Pack(pickId++, _solution.Analysis.PackProperties, bPosition));
                }
                graphics.AddDimensions(
                    new DimensionCube(layer.BoundingBox(_solution.Analysis.PackProperties)
                                      , Color.Black, false));
            }
        }
Ejemplo n.º 2
0
        public void Draw(Graphics2D graphics)
        {
            if (null == _solution || _solution.LayerCount == 0)
            {
                return;
            }

            BoxLayer blayer = _solution.Layer;

            if (blayer != null)
            {
                // initialize Graphics2D object
                graphics.NumberOfViews = 1;
                BBox3D bbox = blayer.BoundingBox(_analysis.PackProperties);
                graphics.SetViewport(0.0f, 0.0f, (float)bbox.Length, (float)bbox.Width);
                graphics.SetCurrentView(0);
                graphics.DrawRectangle(Vector2D.Zero, new Vector2D(_analysis.PalletProperties.Length, _analysis.PalletProperties.Width), Color.Black);
                uint pickId = 0;
                foreach (BoxPosition bPosition in blayer)
                {
                    graphics.DrawBox(new Box(pickId++, _analysis.PackProperties, bPosition));
                }
            }
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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 LayerPattern.All)
            {
                // loop throught all axes
                foreach (HalfAxis.HAxis axis in axes) // axis
                {
                    // loop through
                    Layer2D layer = BuildLayer(_packProperties, _palletProperties, _constraintSet, axis, false, 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, 0);
                    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;
        }