Пример #1
0
        public List <Analysis> BuildAnalyses(ConstraintSetAbstract constraintSet)
        {
            var analyses = new List <Analysis>();
            // build layer list
            var            solver = new LayerSolver();
            List <Layer2D> layers = solver.BuildLayers(
                _packable.OuterDimensions
                , new Vector2D(_caseProperties.InsideLength, _caseProperties.InsideWidth)
                , 0.0     /* offsetZ */
                , constraintSet
                , true
                );

            Solution.SetSolver(solver);
            // loop on layers
            foreach (Layer2D layer in layers)
            {
                var layerDescs = new List <LayerDesc>();
                layerDescs.Add(layer.LayerDescriptor);
                var analysis = new AnalysisBoxCase(null, _packable, _caseProperties, constraintSet as ConstraintSetBoxCase);
                analysis.AddSolution(layerDescs);
                // only add analysis if it has a valid solution
                if (analysis.Solution.ItemCount > 0)
                {
                    analyses.Add(analysis);
                }
            }
            return(analyses);
        }
Пример #2
0
        static void Main(string[] args)
        {

            bool bestLayersOnly = true;
            Vector3D dimBox = new Vector3D(400.0, 300.0, 150.0);
            Vector2D dimContainer = new Vector2D(1200.0, 1000.0);
            ConstraintSetCasePallet constraintSet = new ConstraintSetCasePallet();
            constraintSet.SetMaxHeight(1200.0); 

            try
            {
                LayerSolver solver = new LayerSolver();
                List<Layer2D> layers = solver.BuildLayers(dimBox, dimContainer, constraintSet, bestLayersOnly);

                int solIndex = 0;
                foreach (Layer2D layer in layers)
                {
                    string fileName = string.Format("{0}_{1}.bmp", layer.Name, solIndex++);
                    string filePath = Path.Combine(Path.GetTempPath(), fileName);
                    Console.WriteLine(string.Format("Generating {0}...", filePath));

                    Graphics2DImage graphics = new Graphics2DImage( new Size(150, 150) );
                    SolutionViewerLayer solViewer = new SolutionViewerLayer(layer);
                    BoxProperties bProperties = new BoxProperties(null, 400.0, 300.0, 150.0);
                    bProperties.SetColor(Color.Brown);
                    solViewer.Draw(graphics, bProperties, 1500.0);
                    graphics.SaveAs(filePath);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Пример #3
0
        public List <AnalysisLayered> BuildAnalyses(bool allowMultipleLayerOrientations)
        {
            var analyses = new List <AnalysisLayered>();

            // get best set of layers
            if (allowMultipleLayerOrientations)
            {
                var listLayerEncap = new List <KeyValuePair <LayerEncap, int> >();
                LayerSolver.GetBestCombination(
                    _packable.OuterDimensions,
                    _packable.Bulge,
                    _caseProperties.GetStackingDimensions(ConstraintSet),
                    ConstraintSet,
                    ref listLayerEncap);

                var layerEncaps = new List <LayerEncap>();
                foreach (var vp in listLayerEncap)
                {
                    layerEncaps.Add(vp.Key);
                }

                var analysis = new AnalysisBoxCase(null, _packable, _caseProperties, ConstraintSet);
                analysis.AddSolution(layerEncaps);
                // only add analysis if it has a valid solution
                if (analysis.Solution.ItemCount > 0)
                {
                    analyses.Add(analysis);
                }
            }
            else
            {
                // build layer list
                var solver = new LayerSolver();
                List <Layer2DBrickImp> layers = solver.BuildLayers(
                    _packable.OuterDimensions
                    , _packable.Bulge
                    , new Vector2D(_caseProperties.InsideLength, _caseProperties.InsideWidth)
                    , 0.0  /* offsetZ */
                    , ConstraintSet
                    , true
                    );
                SolutionLayered.SetSolver(solver);
                // loop on layers
                foreach (Layer2DBrickImp layer in layers)
                {
                    var layerDescs = new List <LayerDesc> {
                        layer.LayerDescriptor
                    };
                    var analysis = new AnalysisBoxCase(null, _packable, _caseProperties, ConstraintSet);
                    analysis.AddSolution(layerDescs);
                    // only add analysis if it has a valid solution
                    if (analysis.Solution.ItemCount > 0)
                    {
                        analyses.Add(analysis);
                    }
                }
            }
            return(analyses);
        }
Пример #4
0
        public List <Analysis> BuildAnalyses(ConstraintSetAbstract constraintSet, bool allowMultipleLayerOrientations)
        {
            var analyses = new List <Analysis>();
            var constraintSetCasePallet = constraintSet as ConstraintSetCasePallet;

            if (null == constraintSetCasePallet)
            {
                return(analyses);
            }
            Vector2D overhang = constraintSetCasePallet.Overhang;

            if (allowMultipleLayerOrientations)
            {
                List <KeyValuePair <LayerDesc, int> > listLayer = new List <KeyValuePair <LayerDesc, int> >();
                LayerSolver.GetBestCombination(
                    _packable.OuterDimensions,
                    _palletProperties.GetStackingDimensions(constraintSet),
                    constraintSet,
                    ref listLayer);
                Solution.SetSolver(new LayerSolver());
                var analysis = new AnalysisCasePallet(_packable, _palletProperties, constraintSet as ConstraintSetCasePallet);
                analysis.AddSolution(listLayer);
                // only add analysis if it has a valid solution
                if (analysis.Solution.ItemCount > 0)
                {
                    analyses.Add(analysis);
                }
            }
            else
            {
                // build layer list
                var            solver = new LayerSolver();
                List <Layer2D> layers = solver.BuildLayers(
                    _packable.OuterDimensions
                    , new Vector2D(_palletProperties.Length + 2.0 * overhang.X, _palletProperties.Width + 2.0 * overhang.Y)
                    , _palletProperties.Height
                    , constraintSetCasePallet
                    , true
                    );
                Solution.SetSolver(solver);
                // loop on layers
                foreach (Layer2D layer in layers)
                {
                    var layerDescs = new List <LayerDesc> {
                        layer.LayerDescriptor
                    };
                    var analysis = new AnalysisCasePallet(_packable, _palletProperties, constraintSet as ConstraintSetCasePallet);
                    analysis.AddSolution(layerDescs);
                    // only add analysis if it has a valid solution
                    if (analysis.Solution.ItemCount > 0)
                    {
                        analyses.Add(analysis);
                    }
                }
            }
            return(analyses);
        }
Пример #5
0
        public Layer2D BuildBestLayer(ConstraintSetAbstract constraintSet)
        {
            // build layer list
            var            solver = new LayerSolver();
            List <Layer2D> layers = solver.BuildLayers(
                _packable.OuterDimensions
                , new Vector2D(_caseProperties.InsideLength, _caseProperties.InsideWidth)
                , 0.0     /* offsetZ */
                , constraintSet
                , true
                );

            if (layers.Count > 0)
            {
                return(layers[0]);
            }
            return(null);
        }
Пример #6
0
        public Layer2DBrickImp BuildBestLayer()
        {
            // build layer list
            var solver = new LayerSolver();
            List <Layer2DBrickImp> layers = solver.BuildLayers(
                Packable.OuterDimensions
                , new Vector2D(PalletProperties.Length + 2.0 * ConstraintSet.Overhang.X, PalletProperties.Width + 2.0 * ConstraintSet.Overhang.Y)
                , PalletProperties.Height
                , ConstraintSet
                , true
                );

            if (layers.Count > 0)
            {
                return(layers[0]);
            }
            return(null);
        }
Пример #7
0
        public Layer2D BuildBestLayer(ConstraintSetAbstract constraintSet)
        {
            var      constraintSetCasePallet = constraintSet as ConstraintSetCasePallet;
            Vector2D overhang = constraintSetCasePallet.Overhang;
            // build layer list
            var            solver = new LayerSolver();
            List <Layer2D> layers = solver.BuildLayers(
                _packable.OuterDimensions
                , new Vector2D(_palletProperties.Length + 2.0 * overhang.X, _palletProperties.Width + 2.0 * overhang.Y)
                , _palletProperties.Height
                , constraintSetCasePallet
                , true
                );

            if (layers.Count > 0)
            {
                return(layers[0]);
            }
            return(null);
        }
Пример #8
0
        public List <Analysis> BuildAnalyses(ConstraintSetAbstract constraintSet)
        {
            var analyses = new List <Analysis>();
            var constraintSetCasePallet = constraintSet as ConstraintSetCasePallet;

            if (null == constraintSetCasePallet)
            {
                return(analyses);
            }
            Vector2D overhang = constraintSetCasePallet.Overhang;
            // build layer list
            var            solver = new LayerSolver();
            List <Layer2D> layers = solver.BuildLayers(
                _packable.OuterDimensions
                , new Vector2D(_palletProperties.Length + 2.0 * overhang.X, _palletProperties.Width + 2.0 * overhang.Y)
                , _palletProperties.Height
                , constraintSetCasePallet
                , true
                );

            Solution.SetSolver(solver);
            // loop on layers
            foreach (Layer2D layer in layers)
            {
                var layerDescs = new List <LayerDesc>();
                layerDescs.Add(layer.LayerDescriptor);
                var analysis = new AnalysisCasePallet(_packable, _palletProperties, constraintSet as ConstraintSetCasePallet);
                analysis.AddSolution(layerDescs);
                // only add analysis if it has a valid solution
                if (analysis.Solution.ItemCount > 0)
                {
                    analyses.Add(analysis);
                }
            }
            return(analyses);
        }
        private void onInputChanged(object sender, EventArgs e)
        {
            try
            {
                // get case /pallet
                ItemBaseCB itemBaseCase = cbCases.SelectedItem as ItemBaseCB;
                if (null == itemBaseCase) return;
                BProperties bProperties = itemBaseCase.Item as BProperties;

                ItemBaseCB itemBasePallet = cbPallets.SelectedItem as ItemBaseCB;
                if (null == itemBasePallet) return;
                PalletProperties palletProperties = itemBasePallet.Item as PalletProperties;
                // compute
                LayerSolver solver = new LayerSolver();
                List<Layer2D> layers = solver.BuildLayers(
                    bProperties.OuterDimensions
                    , new Vector2D(palletProperties.Length + 2.0 * uCtrlOverhang.ValueX, palletProperties.Width + 2.0 * uCtrlOverhang.ValueY)
                    , BuildConstraintSet()
                    , checkBoxBestLayersOnly.Checked);
                // update control
                uCtrlLayerList.BProperties = bProperties;
                uCtrlLayerList.ContainerHeight = uCtrlOptMaximumHeight.Value.Value;
                uCtrlLayerList.LayerList = layers;
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message);
            }
        }