public SolutionItem(SolutionItem solItem) { _indexLayer = solItem._indexLayer; _indexInterlayer = solItem._indexInterlayer; _symmetryX = solItem._symmetryX; _symmetryY = solItem._symmetryY; }
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()); } }
public bool IsLayerTypeOf(SolutionItem solItem) { return(IndexLayer == solItem.LayerIndex && SymetryX == solItem.SymetryX && SymetryY == solItem.SymetryY); }
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(); }