public static Bitmap Draw(Layer2D layer, BProperties bProperties, double height, Size size, bool selected) { Graphics2DImage graphics = new Graphics2DImage(size); using (SolutionViewerLayer solViewer = new SolutionViewerLayer(layer)) { solViewer.Draw(graphics, bProperties, height, selected); } return graphics.Bitmap; }
/// <summary> /// Compute layer bouding box /// </summary> /// <param name="bProperties">Case properties</param> /// <returns>bounding box</returns> public BBox3D BoundingBox(BProperties bProperties) { BBox3D bbox = new BBox3D(); foreach (BoxPosition bpos in this) { Vector3D[] pts = new Vector3D[8]; Vector3D vI = HalfAxis.ToVector3D(bpos.DirectionLength); Vector3D vJ = HalfAxis.ToVector3D(bpos.DirectionWidth); Vector3D vK = Vector3D.CrossProduct(vI, vJ); pts[0] = bpos.Position; pts[1] = bpos.Position + bProperties.Length * vI; pts[2] = bpos.Position + bProperties.Width * vJ; pts[3] = bpos.Position + bProperties.Length * vI + bProperties.Width * vJ; pts[4] = bpos.Position + bProperties.Height * vK; pts[5] = bpos.Position + bProperties.Width * vJ + bProperties.Height * vK;; pts[6] = bpos.Position + HalfAxis.ToVector3D(bpos.DirectionWidth) * bProperties.Width; pts[7] = bpos.Position + HalfAxis.ToVector3D(bpos.DirectionLength) * bProperties.Length + HalfAxis.ToVector3D(bpos.DirectionWidth) * bProperties.Width; foreach (Vector3D pt in pts) { bbox.Extend(pt); } } return(bbox); }
public CasePalletAnalysis( BProperties boxProperties, PalletProperties palletProperties, InterlayerProperties interlayerProperties, InterlayerProperties interlayerPropertiesAntiSlip, PalletCornerProperties palletCorners, PalletCapProperties palletCap, PalletFilmProperties palletFilm, PalletConstraintSet constraintSet) : base(boxProperties.ParentDocument) { // sanity checks if (palletProperties.ParentDocument != ParentDocument || (interlayerProperties != null && interlayerProperties.ParentDocument != ParentDocument)) { throw new Exception("box, pallet, interlayer do not belong to the same document"); } if ((boxProperties is BoxProperties && constraintSet is BundlePalletConstraintSet) || (boxProperties is BundleProperties && constraintSet is CasePalletConstraintSet)) { throw new Exception("Invalid analysis: either BoxProperties with ConstraintSetBundle or BundleProperties with ConstraintSetBox"); } // has interlayer ? constraintSet.HasInterlayer = null != interlayerProperties; // setting members this.BProperties = boxProperties; this.PalletProperties = palletProperties; this.InterlayerProperties = interlayerProperties; this.InterlayerPropertiesAntiSlip = interlayerPropertiesAntiSlip; this.PalletCornerProperties = palletCorners; this.PalletCapProperties = palletCap; this.PalletFilmProperties = palletFilm; this.ConstraintSet = constraintSet; }
public static void Draw(BProperties boxProperties, HalfAxis.HAxis axis, PictureBox pictureBox) { // get horizontal angle double angle = 45; // instantiate graphics Graphics3DImage graphics = new Graphics3DImage(pictureBox.Size); graphics.CameraPosition = new Vector3D( Math.Cos(angle * Math.PI / 180.0) * Math.Sqrt(2.0) * 10000.0 , Math.Sin(angle * Math.PI / 180.0) * Math.Sqrt(2.0) * 10000.0 , 10000.0); graphics.Target = Vector3D.Zero; graphics.SetViewport(-500.0f, -500.0f, 500.0f, 500.0f); // draw Box box = new Box(0, boxProperties); // set axes HalfAxis.HAxis lengthAxis = HalfAxis.HAxis.AXIS_X_P; HalfAxis.HAxis widthAxis = HalfAxis.HAxis.AXIS_Y_P; switch (axis) { case HalfAxis.HAxis.AXIS_X_P: lengthAxis = HalfAxis.HAxis.AXIS_Z_P; widthAxis = HalfAxis.HAxis.AXIS_X_P; break; case HalfAxis.HAxis.AXIS_Y_P: lengthAxis = HalfAxis.HAxis.AXIS_X_P; widthAxis = HalfAxis.HAxis.AXIS_Z_N; break; case HalfAxis.HAxis.AXIS_Z_P: lengthAxis = HalfAxis.HAxis.AXIS_X_P; widthAxis = HalfAxis.HAxis.AXIS_Y_P; break; default: break; } box.LengthAxis = treeDiM.StackBuilder.Basics.HalfAxis.ToVector3D(lengthAxis); box.WidthAxis = treeDiM.StackBuilder.Basics.HalfAxis.ToVector3D(widthAxis); // draw box graphics.AddBox(box); graphics.Flush(); // set to picture box pictureBox.Image = graphics.Bitmap; }
public Box(uint pickId, BProperties bProperties) { _pickId = pickId; _dim[0] = bProperties.Length; _dim[1] = bProperties.Width; _dim[2] = bProperties.Height; _colors = bProperties.Colors; // IsBundle ? _isBundle = bProperties.IsBundle; // textures BoxProperties boxProperties = bProperties as BoxProperties; if (null != boxProperties) { List<Pair<HalfAxis.HAxis, Texture>> textures = boxProperties.TextureList; foreach (Pair<HalfAxis.HAxis, Texture> tex in textures) { int iIndex = (int)tex.first; if (null == _textureLists[iIndex]) _textureLists[iIndex] = new List<Texture>(); _textureLists[iIndex].Add(tex.second); } // tape _showTape = boxProperties.ShowTape; _tapeWidth = boxProperties.TapeWidth; _tapeColor = boxProperties.TapeColor; } }
public CasePalletAnalysis( BProperties boxProperties, PalletProperties palletProperties, InterlayerProperties interlayerProperties, InterlayerProperties interlayerPropertiesAntiSlip, PalletCornerProperties palletCorners, PalletCapProperties palletCap, PalletFilmProperties palletFilm, PalletConstraintSet constraintSet) : base(boxProperties.ParentDocument) { // sanity checks if (palletProperties.ParentDocument != ParentDocument || (interlayerProperties != null && interlayerProperties.ParentDocument != ParentDocument)) throw new Exception("box, pallet, interlayer do not belong to the same document"); if ((boxProperties is BoxProperties && constraintSet is BundlePalletConstraintSet) || (boxProperties is BundleProperties && constraintSet is CasePalletConstraintSet)) throw new Exception("Invalid analysis: either BoxProperties with ConstraintSetBundle or BundleProperties with ConstraintSetBox"); // has interlayer ? constraintSet.HasInterlayer = null != interlayerProperties; // setting members this.BProperties = boxProperties; this.PalletProperties = palletProperties; this.InterlayerProperties = interlayerProperties; this.InterlayerPropertiesAntiSlip = interlayerPropertiesAntiSlip; this.PalletCornerProperties = palletCorners; this.PalletCapProperties = palletCap; this.PalletFilmProperties = palletFilm; this.ConstraintSet = constraintSet; }
private Layer2D GenerateBestLayer( BProperties bProperties, PalletProperties palletProperties, PalletCornerProperties cornerProperties, PalletConstraintSet constraintSet, HalfAxis.HAxis hAxis) { Layer2D bestLayer = null; // loop through all patterns foreach (LayerPattern pattern in LayerPattern.All) { // is pattern allowed if (!_constraintSet.AllowPattern(pattern.Name)) continue; // direction 1 Layer2D layer1 = BuildLayer(bProperties, palletProperties, cornerProperties, constraintSet, hAxis, false, false); double actualLength = 0.0, actualWidth = 0.0; pattern.GetLayerDimensionsChecked(layer1, out actualLength, out actualWidth); pattern.GenerateLayer(layer1, actualLength, actualWidth); // save as best pattern if (null == bestLayer || bestLayer.Count < layer1.Count) bestLayer = layer1; // direction 2 (opposite) Layer2D layer2 = BuildLayer(bProperties, palletProperties, cornerProperties, constraintSet, HalfAxis.Opposite(hAxis), false, false); actualLength = 0.0; actualWidth = 0.0; pattern.GetLayerDimensionsChecked(layer2, out actualLength, out actualWidth); pattern.GenerateLayer(layer2, actualLength, actualWidth); // save as best pattern if (null == bestLayer || bestLayer.Count < layer2.Count) bestLayer = layer2; } return bestLayer; }
public CaseOptimAnalysis( BProperties boxProperties , PalletProperties palletProperties , PalletConstraintSet palletConstraintSet , CaseOptimConstraintSet caseOptimConstraintSet) : base(boxProperties.ParentDocument) { }
public CaseOptimAnalysis( BProperties boxProperties , PalletProperties palletProperties , PalletConstraintSet palletConstraintSet , CaseOptimConstraintSet caseOptimConstraintSet) : base(boxProperties.ParentDocument) { }
public BoxCaseAnalysis(BProperties bProperties, BoxProperties caseProperties, BCaseConstraintSet constraintSet) : base(bProperties.ParentDocument) { if (!constraintSet.IsValid) throw new Exception("Using invalid box/case constraintset -> Can not instantiate box/case analysis!"); this.BProperties = bProperties; this.CaseProperties = caseProperties; _constraintSet = constraintSet; }
public void ProcessAnalysis(BoxCaseAnalysis analysis) { _bProperties = analysis.BProperties; _caseProperties = analysis.CaseProperties; _constraintSet = analysis.ConstraintSet; if (!_constraintSet.IsValid) throw new EngineException("Constraint set is invalid!"); analysis.Solutions = GenerateSolutions(); }
public BoxCaseAnalysis(BProperties bProperties, BoxProperties caseProperties, BCaseConstraintSet constraintSet) : base(bProperties.ParentDocument) { if (!constraintSet.IsValid) { throw new Exception("Using invalid box/case constraintset -> Can not instantiate box/case analysis!"); } this.BProperties = bProperties; this.CaseProperties = caseProperties; _constraintSet = constraintSet; }
/* * /// <summary> * /// Compute layer bouding box * /// </summary> * /// <param name="bProperties">Case properties</param> * /// <returns>bounding box</returns> * public BBox3D BoundingBox(BProperties bProperties) * { * BBox3D bbox = new BBox3D(); * * foreach (BoxPosition bpos in this) * { * Vector3D[] pts = new Vector3D[8]; * Vector3D vI = HalfAxis.ToVector3D(bpos.DirectionLength); * Vector3D vJ = HalfAxis.ToVector3D(bpos.DirectionWidth); * Vector3D vK = Vector3D.CrossProduct(vI, vJ); * pts[0] = bpos.Position; * pts[1] = bpos.Position + bProperties.Length * vI; * pts[2] = bpos.Position + bProperties.Width * vJ; * pts[3] = bpos.Position + bProperties.Length * vI + bProperties.Width * vJ; * pts[4] = bpos.Position + bProperties.Height * vK; * pts[5] = bpos.Position + bProperties.Width * vJ + bProperties.Height * vK; ; * pts[6] = bpos.Position + HalfAxis.ToVector3D(bpos.DirectionWidth) * bProperties.Width; * pts[7] = bpos.Position + HalfAxis.ToVector3D(bpos.DirectionLength) * bProperties.Length + HalfAxis.ToVector3D(bpos.DirectionWidth) * bProperties.Width; * * foreach (Vector3D pt in pts) * bbox.Extend(pt); * } * return bbox; * } * * public BBox3D BoundingBox(PackProperties packProperties) * { * BBox3D bbox = new BBox3D(); * * foreach (BoxPosition bpos in this) * { * Vector3D[] pts = new Vector3D[8]; * Vector3D vI = HalfAxis.ToVector3D(bpos.DirectionLength); * Vector3D vJ = HalfAxis.ToVector3D(bpos.DirectionWidth); * Vector3D vK = Vector3D.CrossProduct(vI, vJ); * pts[0] = bpos.Position; * pts[1] = bpos.Position + packProperties.Length * vI; * pts[2] = bpos.Position + packProperties.Width * vJ; * pts[3] = bpos.Position + packProperties.Length * vI + packProperties.Width * vJ; * pts[4] = bpos.Position + packProperties.Height * vK; * pts[5] = bpos.Position + packProperties.Width * vJ + packProperties.Height * vK; ; * pts[6] = bpos.Position + HalfAxis.ToVector3D(bpos.DirectionWidth) * packProperties.Width; * pts[7] = bpos.Position + HalfAxis.ToVector3D(bpos.DirectionLength) * packProperties.Length + HalfAxis.ToVector3D(bpos.DirectionWidth) * packProperties.Width; * * foreach (Vector3D pt in pts) * bbox.Extend(pt); * } * * return bbox; * } */ public double Thickness(BProperties bProperties) { if (Count == 0) { return(0.0); } BoxPosition bPos = this[0]; Vector3D diagonale = bProperties.Length * HalfAxis.ToVector3D(bPos.DirectionLength) + bProperties.Width * HalfAxis.ToVector3D(bPos.DirectionWidth) + bProperties.Height * Vector3D.CrossProduct(HalfAxis.ToVector3D(bPos.DirectionLength), HalfAxis.ToVector3D(bPos.DirectionWidth)); return(Math.Abs(diagonale.Z)); }
public AnalysisCasePallet( BProperties bProperties, PalletProperties palletProperties, ConstraintSetCasePallet constraintSet) : base(bProperties.ParentDocument) { // sanity checks if (palletProperties.ParentDocument != ParentDocument) throw new Exception("box & pallet do not belong to the same document"); _bProperties = bProperties; _palletProperties = palletProperties; _constraintSet = constraintSet; }
/// <summary> /// Process case/pallet analysis /// </summary> /// <param name="analysis">Pallet analysis to process</param> public void ProcessAnalysis(CasePalletAnalysis analysis) { _bProperties = analysis.BProperties; _palletProperties = analysis.PalletProperties; _interlayerProperties = analysis.InterlayerProperties; _interlayerPropertiesAntiSlip = analysis.InterlayerPropertiesAntiSlip; _cornerProperties = analysis.PalletCornerProperties; _capProperties = analysis.PalletCapProperties; _constraintSet = analysis.ConstraintSet; // check contraint set validity if (!_constraintSet.IsValid) throw new EngineException("Constraint set is invalid!"); // generate solutions analysis.Solutions = GenerateSolutions(); }
public AnalysisCasePallet( BProperties bProperties, PalletProperties palletProperties, ConstraintSetCasePallet constraintSet) : base(bProperties.ParentDocument) { // sanity checks if (palletProperties.ParentDocument != ParentDocument) { throw new Exception("box & pallet do not belong to the same document"); } _bProperties = bProperties; _palletProperties = palletProperties; _constraintSet = constraintSet; }
public List<CasePalletSolution> Process( BoxProperties boxProperties, PalletProperties palletProperties, InterlayerProperties interlayerProperties, InterlayerProperties interlayerPropertiesAntiSlip, PalletConstraintSet constraintSet) { _bProperties = boxProperties; _palletProperties = palletProperties; _interlayerProperties = interlayerProperties; _interlayerPropertiesAntiSlip = interlayerPropertiesAntiSlip; _constraintSet = constraintSet; // check constraint set validity if (!_constraintSet.IsValid) throw new EngineException("Constraint set is invalid!"); // generate solutions return GenerateSolutions(); }
public void Draw(Graphics2D graphics, BProperties bProperties, double height, bool selected) { graphics.NumberOfViews = 1; graphics.Graphics.Clear(selected ? Color.LightBlue : Color.White); graphics.SetViewport(0.0f, 0.0f, (float)_layer.PalletLength, (float)_layer.PalletWidth); if (_layer != null) { graphics.SetCurrentView(0); graphics.DrawRectangle(Vector2D.Zero, new Vector2D(_layer.PalletLength, _layer.PalletWidth), Color.Black); uint pickId = 0; foreach (LayerPosition bPosition in _layer) graphics.DrawBox(new Box(pickId++, bProperties, bPosition)); // draw axes bool showAxis = false; if (showAxis) { // draw axis X graphics.DrawLine(Vector2D.Zero, new Vector2D(_layer.PalletLength, 0.0), Color.Red); // draw axis Y graphics.DrawLine(Vector2D.Zero, new Vector2D(0.0, _layer.PalletWidth), Color.Green); } } Size s = graphics.Size; // *** Annotate : begin *** string annotation = string.Format( "{0}*{1}={2}" , _layer.Count , _layer.NoLayers(height) , _layer.CountInHeight(height) ); Font tfont = new Font("Arial", _fontSize); Color brushColor = Color.White; Color backgroundColor = Color.Black; StringFormat sf = new StringFormat(); sf.Alignment = StringAlignment.Far; sf.LineAlignment = StringAlignment.Far; System.Drawing.Graphics g = graphics.Graphics; Size txtSize = g.MeasureString(annotation, tfont).ToSize(); g.FillRectangle(new SolidBrush(backgroundColor), new Rectangle(s.Width - txtSize.Width - 2, s.Height - txtSize.Height - 2, txtSize.Width + 2, txtSize.Height + 2)); g.DrawString(annotation, tfont, new SolidBrush(brushColor), new Point(s.Width - 3, s.Height - 3), sf); // *** Annotate : end *** }
public Layer2D BuildLayer(BProperties bProperties, BoxProperties caseProperties , HalfAxis.HAxis axisOrtho, bool swapped) { return new Layer2D( new Vector3D(bProperties.Length, bProperties.Width, bProperties.Height) , new Vector2D(caseProperties.InsideLength, caseProperties.InsideWidth) , axisOrtho , swapped ); }
/// <summary> /// Constructor /// </summary> /// <param name="boxProperties">Encapsulated box properties</param> public BoxItem(BProperties boxProperties) { _boxProperties = boxProperties; }
public void Draw(Graphics3D graphics, BProperties bProperties, double height, bool selected) { }
public BoxCaseAnalysis CreateNewBoxCaseAnalysis( string name, string description , BProperties boxProperties, BoxProperties caseProperties , BCaseConstraintSet constraintSet , IBoxCaseAnalysisSolver solver) { BoxCaseAnalysis analysis = new BoxCaseAnalysis(boxProperties, caseProperties, constraintSet); analysis.Name = name; analysis.Description = description; // insert in list _boxCaseAnalyses.Add(analysis); // compute analysis if (null != solver) { solver.ProcessAnalysis(analysis); if (analysis.Solutions.Count < 1) { // remove analysis from list if it has no valid solution _boxCaseAnalyses.Remove(analysis); return null; } } // notify listeners NotifyOnNewBoxCaseAnalysis(analysis); Modify(); return analysis; }
public BoxCaseAnalysis CreateNewBoxCaseAnalysis( string name, string description , BProperties boxProperties, BoxProperties caseProperties , BCaseConstraintSet constraintSet , List<BoxCaseSolution> solutions) { BoxCaseAnalysis analysis = new BoxCaseAnalysis(boxProperties, caseProperties, constraintSet); analysis.Name = name; analysis.Description = description; // insert in list _boxCaseAnalyses.Add(analysis); // set solutions analysis.Solutions = solutions; // notify listeners NotifyOnNewBoxCaseAnalysis(analysis); // set solution selected if it is unique if (solutions.Count == 1) analysis.SelectSolutionByIndex(0); return analysis; }
/// <summary> /// Creates a new analysis without generating solutions /// </summary> /// <param name="name">Name of analysis</param> /// <param name="description">Description</param> /// <param name="box">Case</param> /// <param name="pallet">Pallet</param> /// <param name="interlayer">Interlayer</param> /// <param name="constraintSet">PalletConstraintSet</param> /// <param name="solutions">Solutions</param> /// <returns>CasePalletAnalysis generated using input parameters</returns> public CasePalletAnalysis CreateNewCasePalletAnalysis( string name, string description , BProperties box, PalletProperties pallet , InterlayerProperties interlayer, InterlayerProperties interlayerAntiSlip , PalletCornerProperties palletCorners, PalletCapProperties palletCap, PalletFilmProperties palletFilm , PalletConstraintSet constraintSet , List<CasePalletSolution> solutions) { CasePalletAnalysis analysis = new CasePalletAnalysis( box, pallet, interlayer, interlayerAntiSlip, palletCorners, palletCap, palletFilm, constraintSet); analysis.Name = name; analysis.Description = description; // insert in list _casePalletAnalyses.Add(analysis); // set solutions analysis.Solutions = solutions; // notify listeners NotifyOnNewCasePalletAnalysisCreated(analysis); // set solution selected if it is unique if (solutions.Count == 1) analysis.SelectSolutionByIndex(0); return analysis; }
public AnalysisCasePallet CreateNewAnalysisCasePallet( string name, string description , BProperties box, PalletProperties pallet , List<InterlayerProperties> interlayers , PalletCornerProperties palletCorners, PalletCapProperties palletCap, PalletFilmProperties palletFilm , ConstraintSetCasePallet constraintSet , List<LayerDesc> layerDescs ) { AnalysisCasePallet analysis = new AnalysisCasePallet(box, pallet, constraintSet); foreach (InterlayerProperties interlayer in interlayers) analysis.AddInterlayer(interlayer); analysis.PalletCornerProperties = palletCorners; analysis.PalletCapProperties = palletCap; analysis.PalletFilmProperties = palletFilm; analysis.AddSolution(layerDescs); // notify listeners NotifyOnNewAnalysisCreated(analysis); Modify(); return analysis; }
/// <summary> /// Creates a new analysis in this document + compute solutions /// </summary> /// <param name="name"></param> /// <param name="description"></param> /// <param name="box"></param> /// <param name="pallet"></param> /// <param name="interlayer"></param> /// <param name="constraintSet"></param> /// <param name="solver">Node : analysis creation requires a solver</param> /// <returns>An analysis</returns> public CasePalletAnalysis CreateNewCasePalletAnalysis( string name, string description , BProperties box, PalletProperties pallet , InterlayerProperties interlayer, InterlayerProperties interlayerAntiSlip , PalletCornerProperties palletCorners, PalletCapProperties palletCap, PalletFilmProperties palletFilm , PalletConstraintSet constraintSet , ICasePalletAnalysisSolver solver) { CasePalletAnalysis analysis = new CasePalletAnalysis( box, pallet, interlayer, interlayerAntiSlip, palletCorners, palletCap, palletFilm, constraintSet); analysis.Name = name; analysis.Description = description; // insert in list _casePalletAnalyses.Add(analysis); // compute analysis solver.ProcessAnalysis(analysis); if (analysis.Solutions.Count < 1) { // remove analysis from list if it has no valid solution _casePalletAnalyses.Remove(analysis); return null; } // notify listeners NotifyOnNewCasePalletAnalysisCreated(analysis); Modify(); return analysis; }
protected Layer2D BuildLayer( BProperties boxProperties, PalletProperties palletProperties, PalletCornerProperties cornerProperties , PalletConstraintSet constraintSet, HalfAxis.HAxis axisOrtho, bool swapped, bool inversed) { double cornerThickness = null != cornerProperties ? cornerProperties.Thickness : 0.0; return new Layer2D( new Vector3D() , new Vector2D(palletProperties.Length + constraintSet.OverhangX - 2.0 * cornerThickness, palletProperties.Width + constraintSet.OverhangY - 2.0 * cornerThickness) , axisOrtho , swapped); }
public Box(uint pickId, BProperties bProperties, BoxPosition bPosition) { if (!bPosition.IsValid) throw new GraphicsException("Invalid BoxPosition: can not create box"); _pickId = pickId; _dim[0] = bProperties.Length; _dim[1] = bProperties.Width; _dim[2] = bProperties.Height; _colors = bProperties.Colors; BoxProperties boxProperties = bProperties as BoxProperties; if (null != boxProperties) { List<Pair<HalfAxis.HAxis, Texture>> textures = boxProperties.TextureList; foreach (Pair<HalfAxis.HAxis, Texture> tex in textures) { int iIndex = (int)tex.first; if (null == _textureLists[iIndex]) _textureLists[iIndex] = new List<Texture>(); _textureLists[iIndex].Add(tex.second); } _showTape = boxProperties.ShowTape; _tapeWidth = boxProperties.TapeWidth; _tapeColor = boxProperties.TapeColor; } // set position Position = bPosition.Position; // set direction length LengthAxis = HalfAxis.ToVector3D(bPosition.DirectionLength); // set direction width WidthAxis = HalfAxis.ToVector3D(bPosition.DirectionWidth); // IsBundle ? _isBundle = bProperties.IsBundle; if (bProperties.IsBundle) { BundleProperties bundleProp = bProperties as BundleProperties; if (null != bundleProp) _noFlats = bundleProp.NoFlats; } }