Exemple #1
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);
        }
Exemple #2
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);
        }