Ejemplo n.º 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);
        }
Ejemplo n.º 2
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);
        }
        public override void OnNext()
        {
            base.OnNext();
            try
            {
                var layerEncaps = new List <LayerEncap>();
                foreach (ILayer2D layer2D in uCtrlLayerList.Selected)
                {
                    layerEncaps.Add(new LayerEncap(layer2D.LayerDescriptor));
                }

                SolutionLayered.SetSolver(new LayerSolver());

                AnalysisBoxCase analysis = AnalysisCast;
                if (null == analysis)
                {
                    AnalysisBase = _document.CreateNewAnalysisBoxCase(
                        ItemName, ItemDescription
                        , SelectedBoxProperties, SelectedCase
                        , new List <InterlayerProperties>()
                        , BuildConstraintSet()
                        , layerEncaps
                        );
                }
                else
                {
                    analysis.ID.SetNameDesc(ItemName, ItemDescription);
                    analysis.Content        = SelectedBoxProperties;
                    analysis.CaseProperties = SelectedCase;
                    analysis.ConstraintSet  = BuildConstraintSet();
                    analysis.AddSolution(layerEncaps);

                    _document.UpdateAnalysis(analysis);
                }
                Close();
            }
            catch (Exception ex)
            {
                _log.Error(ex.ToString());
            }
        }