示例#1
0
        private void RebuildSolutionItemList()
        {
            bool   criterionReached = false;
            double zTop             = _analysis.Offset.Z;
            double weight           = _analysis.ContainerWeight;

            foreach (SolutionItem solItem in _solutionItems)
            {
                weight += _layers[solItem.LayerIndex].Count * _analysis.ContentWeight;
                zTop   += _layers[solItem.LayerIndex].BoxHeight + ((-1 != solItem.InterlayerIndex) ? _interlayers[solItem.InterlayerIndex].Thickness : 0.0);

                ConstraintSetAbstract constraintSet = _analysis.ConstraintSet;
                criterionReached = (ConstraintSet.OptMaxHeight.Activated && zTop >= constraintSet.OptMaxHeight.Value) ||
                                   (ConstraintSet.OptMaxWeight.Activated && weight >= constraintSet.OptMaxWeight.Value);

                if (criterionReached)
                {
                    break;
                }
            }

            // add layers until
            while (!criterionReached)
            {
                SolutionItem solItem = _solutionItems.Last();

                weight += _layers[solItem.LayerIndex].Count * _analysis.ContentWeight;
                zTop   += _layers[solItem.LayerIndex].BoxHeight + ((-1 != solItem.InterlayerIndex) ? _interlayers[solItem.InterlayerIndex].Thickness : 0.0);

                _solutionItems.Add(new SolutionItem(solItem));

                ConstraintSetAbstract constraintSet = _analysis.ConstraintSet;
                criterionReached = (ConstraintSet.OptMaxHeight.Activated && zTop >= constraintSet.OptMaxHeight.Value) ||
                                   (ConstraintSet.OptMaxWeight.Activated && weight >= constraintSet.OptMaxWeight.Value);
            }

            // remove unneeded layer
            while (criterionReached)
            {
                SolutionItem solItem = _solutionItems.Last();

                weight -= _layers[solItem.LayerIndex].Count * _analysis.ContentWeight;
                zTop   -= _layers[solItem.LayerIndex].BoxHeight + ((-1 != solItem.InterlayerIndex) ? _interlayers[solItem.InterlayerIndex].Thickness : 0.0);

                ConstraintSetAbstract constraintSet = _analysis.ConstraintSet;
                criterionReached = (ConstraintSet.OptMaxHeight.Activated && zTop >= constraintSet.OptMaxHeight.Value) ||
                                   (ConstraintSet.OptMaxWeight.Activated && weight >= constraintSet.OptMaxWeight.Value);

                _solutionItems.Remove(solItem);
            }
            // reset bounding box to force recompute
            _bbox.Reset();
        }
示例#2
0
        public void RebuildSolutionItemList()
        {
            try
            {
                ConstraintSetAbstract constraintSet = Analysis.ConstraintSet;
                double zTop   = Analysis.Offset.Z;
                double weight = Analysis.ContainerWeight;
                int    number = 0;

                List <SolutionItem> solutionItems = new List <SolutionItem>();
                foreach (SolutionItem solItem in _solutionItems)
                {
                    number += _layerTypes[index : solItem.LayerIndex].Count;
                    weight += _layerTypes[index : solItem.LayerIndex].Count * Analysis.ContentWeight;
                    zTop   += _layerTypes[solItem.LayerIndex].LayerHeight + ((-1 != solItem.InterlayerIndex) ? Analysis.Interlayer(solItem.InterlayerIndex).Thickness : 0.0);

                    solutionItems.Add(solItem);

                    if (constraintSet.OneCriterionReached(zTop, weight, number, solutionItems.Count))
                    {
                        break;
                    }
                }

                // add layers until
                while (!constraintSet.OneCriterionReached(zTop, weight, number, solutionItems.Count))
                {
                    SolutionItem solItem = null;
                    if (solutionItems.Count > 0)
                    {
                        solItem = solutionItems.Last();
                    }
                    else
                    {
                        solItem = new SolutionItem(0, -1, false, false);
                    }

                    if (solItem.LayerIndex >= _layerTypes.Count)
                    {
                        throw new Exception(string.Format("Layer index out of range!"));
                    }

                    number += _layerTypes[solItem.LayerIndex].Count;
                    weight += _layerTypes[solItem.LayerIndex].Count * Analysis.ContentWeight;

                    // using zTopAdded because zTop must not be incremented if SolutionItem object is
                    // not actually added
                    double zTopIfAdded = zTop + _layerTypes[solItem.LayerIndex].LayerHeight
                                         + ((-1 != solItem.InterlayerIndex) ? Analysis.Interlayer(solItem.InterlayerIndex).Thickness : 0.0);

                    // only checking on height because weight / number can be modified without removing
                    // a layer (while outputing solution as a list of case)
                    if (!constraintSet.CritHeightReached(zTopIfAdded))
                    {
                        solutionItems.Add(new SolutionItem(solItem));
                        zTop = zTopIfAdded;
                    }
                    else
                    {
                        break;
                    }
                }
                // remove unneeded layer
                while (constraintSet.CritHeightReached(zTop) && solutionItems.Count > 0)
                {
                    SolutionItem solItem = solutionItems.Last();

                    if (solItem.LayerIndex >= _layerTypes.Count)
                    {
                        throw new Exception(string.Format("Layer index out of range!"));
                    }
                    number -= _layerTypes[solItem.LayerIndex].Count;
                    weight -= _layerTypes[solItem.LayerIndex].Count * Analysis.ContentWeight;
                    zTop   -= _layerTypes[solItem.LayerIndex].LayerHeight
                              + ((-1 != solItem.InterlayerIndex) ? Analysis.Interlayer(solItem.InterlayerIndex).Thickness : 0.0);

                    solutionItems.Remove(solItem);
                }
                _solutionItems.Clear();
                _solutionItems = solutionItems;

                // reset bounding box to force recompute
                _bbox.Reset();
            }
            catch (Exception ex)
            {
                _log.Error(ex.ToString());
            }
        }
示例#3
0
        public void RebuildSolutionItemList()
        {
            bool   criterionReached = false;
            double zTop             = _analysis.Offset.Z;
            double weight           = _analysis.ContainerWeight;

            List <SolutionItem> solutionItems = new List <SolutionItem>();

            foreach (SolutionItem solItem in _solutionItems)
            {
                weight += _layerTypes[solItem.LayerIndex].Count * _analysis.ContentWeight;
                zTop   += _layerTypes[solItem.LayerIndex].LayerHeight + ((-1 != solItem.InterlayerIndex) ? _analysis.Interlayer(solItem.InterlayerIndex).Thickness : 0.0);

                ConstraintSetAbstract constraintSet = _analysis.ConstraintSet;
                criterionReached = (ConstraintSet.OptMaxHeight.Activated && zTop >= constraintSet.OptMaxHeight.Value) ||
                                   (ConstraintSet.OptMaxWeight.Activated && weight >= constraintSet.OptMaxWeight.Value);

                solutionItems.Add(solItem);

                if (criterionReached)
                {
                    break;
                }
            }

            // add layers until
            while (!criterionReached)
            {
                SolutionItem solItem = null;
                if (solutionItems.Count > 0)
                {
                    solItem = solutionItems.Last();
                }
                else
                {
                    solItem = new SolutionItem(0, -1, false, false);
                }

                if (solItem.LayerIndex >= _layerTypes.Count)
                {
                    throw new Exception(string.Format("Layer index out of range!"));
                }

                weight += _layerTypes[solItem.LayerIndex].Count * _analysis.ContentWeight;
                zTop   += _layerTypes[solItem.LayerIndex].LayerHeight + ((-1 != solItem.InterlayerIndex) ? _analysis.Interlayer(solItem.InterlayerIndex).Thickness : 0.0);

                solutionItems.Add(new SolutionItem(solItem));

                ConstraintSetAbstract constraintSet = _analysis.ConstraintSet;
                criterionReached = (ConstraintSet.OptMaxHeight.Activated && zTop >= constraintSet.OptMaxHeight.Value) ||
                                   (ConstraintSet.OptMaxWeight.Activated && weight >= constraintSet.OptMaxWeight.Value);
            }

            // remove unneeded layer
            while (criterionReached)
            {
                SolutionItem solItem = null;
                if (solutionItems.Count > 0)
                {
                    solItem = solutionItems.Last();
                }
                else
                {
                    solItem = new SolutionItem(0, -1, false, false);
                }

                if (solItem.LayerIndex >= _layerTypes.Count)
                {
                    throw new Exception(string.Format("Layer index out of range!"));
                }

                weight -= _layerTypes[solItem.LayerIndex].Count * _analysis.ContentWeight;
                zTop   -= _layerTypes[solItem.LayerIndex].LayerHeight + ((-1 != solItem.InterlayerIndex) ? _analysis.Interlayer(solItem.InterlayerIndex).Thickness : 0.0);

                ConstraintSetAbstract constraintSet = _analysis.ConstraintSet;
                criterionReached = (ConstraintSet.OptMaxHeight.Activated && zTop >= constraintSet.OptMaxHeight.Value) ||
                                   (ConstraintSet.OptMaxWeight.Activated && weight >= constraintSet.OptMaxWeight.Value);

                solutionItems.Remove(solItem);
            }
            _solutionItems.Clear();
            _solutionItems = solutionItems;

            // reset bounding box to force recompute
            _bbox.Reset();
        }