private HConstraintSetPallet ConvertDCSBConstraintSet(DCSBHConstraintSet constraintSet) { return(new HConstraintSetPallet() { MaximumHeight = constraintSet.MaxHeight.Value_d, Overhang = new Vector2D(constraintSet.Overhang.M0, constraintSet.Overhang.M1) }); }
/* * public DCSBHSolutionList SB_GetHCasePalletSolution(DCSBContentItem[] sbContentItems, DCSBPallet sbPallet, DCSBHConstraintSet sbConstraintSet) * { * var lErrors = new List<string>(); * var sbSolutions = new List<DCSBHSolution>(); * * try * { * // list of content items * var contentItems = new List<ContentItem>(); * foreach (var sbci in sbContentItems) * { * contentItems.Add( * new ContentItem(ConvertDCSBCase(sbci.Case), sbci.Number, sbci.Orientation.ToArray()) * ); * } * // pallet * var palletProperties = ConvertDCSBPallet(sbPallet); * // constraint set * var constraintSet = new HConstraintSetPallet() * { * Overhang = new Vector2D(sbConstraintSet.Overhang.M0, sbConstraintSet.Overhang.M1), * MaximumHeight = sbConstraintSet.MaxHeight.Value_d * }; * // solve * var solver = new HSolver(); * var solutions = solver.BuildSolutions( * new HAnalysisPallet(null) * { * Content = contentItems, * Pallet = palletProperties, * ConstraintSet = constraintSet * } * ); * // analyse each solution * int solIndex = 0; * foreach (var sol in solutions) * { * sbSolutions.Add( * new DCSBHSolution() * { * SolIndex = solIndex, * PalletCount = sol.SolItemCount, * Algorithm = sol.Algorithm * } * ); * } * } * catch (Exception ex) * { * lErrors.Add(ex.Message); * _log.Error(ex.ToString()); * } * return new DCSBHSolutionList() * { * Solutions = sbSolutions.ToArray(), * Errors = lErrors.ToArray() * }; * } */ public DCSBHSolutionItem SB_GetHSolutionPart( DCSBContentItem[] sbContentItems, DCSBPallet sbPallet, DCSBHConstraintSet sbConstraintSet, int solIndex, int binIndex, DCCompFormat expectedFormat, bool showCotations) { var lErrors = new List <string>(); Vector3D cameraPosition = Graphics3D.Corner_0; byte[] imageBytes = null; string[] errors = null; double weightLoad = 0.0, weightTotal = 0.0; Vector3D bbLoad = new Vector3D(); Vector3D bbGlob = new Vector3D(); try { if (StackBuilderProcessor.GetHSolutionPart( ConvertDCSBContentItems(sbContentItems), ConvertDCSBPallet(sbPallet), ConvertDCSBConstraintSet(sbConstraintSet), solIndex, binIndex, cameraPosition, showCotations, 0.03f, new Size(expectedFormat.Size.CX, expectedFormat.Size.CY), ref weightLoad, ref weightTotal, ref bbLoad, ref bbGlob, ref imageBytes, ref errors) ) { foreach (string err in errors) { lErrors.Add(err); } return(new DCSBHSolutionItem() { SolIndex = solIndex, BinIndex = binIndex, WeightLoad = weightLoad, WeightTotal = weightTotal, BBoxLoad = new DCSBDim3D(bbLoad.X, bbLoad.Y, bbLoad.Z), BBoxTotal = new DCSBDim3D(bbGlob.X, bbGlob.Y, bbGlob.Z), OutFile = new DCCompFileOutput() { Bytes = imageBytes, Format = new DCCompFormat() { Format = EOutFormat.IMAGE, Size = new DCCompSize() { CX = expectedFormat.Size.CX, CY = expectedFormat.Size.CY } } }, Errors = lErrors.ToArray() }); } } catch (Exception ex) { lErrors.Add(ex.Message); _log.Error(ex.ToString()); } return(new DCSBHSolutionItem() { Errors = lErrors.ToArray() }); }
public DCSBHSolution SB_GetHSolutionBestCasePallet(DCSBContentItem[] sbConstentItems, DCSBPallet sbPallet, DCSBHConstraintSet sbConstraintSet, DCCompFormat expectedFormat, bool showCotations) { var lErrors = new List <string>(); Vector3D cameraPosition = Graphics3D.Corner_0; int palletCount = 0; byte[] imageBytes = null; string algorithm = string.Empty; string[] errors = null; try { if (StackBuilderProcessor.GetHSolutionBestCasePallet( ConvertDCSBContentItems(sbConstentItems), ConvertDCSBPallet(sbPallet), ConvertDCSBConstraintSet(sbConstraintSet), cameraPosition, showCotations, 0.03f, new Size(expectedFormat.Size.CX, expectedFormat.Size.CY), ref palletCount, ref algorithm, ref imageBytes, ref errors)) { foreach (string err in errors) { lErrors.Add(err); } return(new DCSBHSolution() { SolIndex = 0, PalletCount = palletCount, Algorithm = string.Empty, OutFile = new DCCompFileOutput() { Bytes = imageBytes, Format = new DCCompFormat() { Format = EOutFormat.IMAGE, Size = new DCCompSize() { CX = expectedFormat.Size.CX, CY = expectedFormat.Size.CY } } }, Errors = lErrors.ToArray() }); } } catch (Exception ex) { lErrors.Add(ex.Message); _log.Error(ex.ToString()); } return(new DCSBHSolution() { Errors = lErrors.ToArray() }); }