public static void GetSolution( Vector3D caseDim, double caseWeight, Bitmap bmpTexture, int palletIndex, double palletWeight, double maxPalletHeight, List <BoxPositionIndexed> boxPositions, bool mirrorLength, bool mirrorWidth, List <bool> interlayers, double angle, Size sz, ref byte[] imageBytes, ref int caseCount, ref int layerCount, ref double weightLoad, ref double weightTotal, ref Vector3D bbLoad, ref Vector3D bbGlob ) { SolutionLayered.SetSolver(new LayerSolver()); // case var boxProperties = new BoxProperties(null, caseDim.X, caseDim.Y, caseDim.Z) { TapeColor = Color.Tan, TapeWidth = new OptDouble(true, 50.0) }; if (null != bmpTexture) { double ratio = (double)bmpTexture.Height / bmpTexture.Width; boxProperties.AddTexture(HalfAxis.HAxis.AXIS_X_N, TexturePosition(caseDim.Y, caseDim.Z, ratio), TextureSize(caseDim.Y, caseDim.Z, ratio), 0.0, bmpTexture); boxProperties.AddTexture(HalfAxis.HAxis.AXIS_X_P, TexturePosition(caseDim.Y, caseDim.Z, ratio), TextureSize(caseDim.Y, caseDim.Z, ratio), 0.0, bmpTexture); boxProperties.AddTexture(HalfAxis.HAxis.AXIS_Y_N, TexturePosition(caseDim.X, caseDim.Z, ratio), TextureSize(caseDim.X, caseDim.Z, ratio), 0.0, bmpTexture); boxProperties.AddTexture(HalfAxis.HAxis.AXIS_Y_P, TexturePosition(caseDim.X, caseDim.Z, ratio), TextureSize(caseDim.X, caseDim.Z, ratio), 0.0, bmpTexture); } boxProperties.SetWeight(caseWeight); boxProperties.SetAllColors(Enumerable.Repeat(Color.Beige, 6).ToArray()); // pallet Vector3D palletDim = PalletIndexToDim3D(palletIndex); var palletProperties = new PalletProperties(null, PalletIndexToPalletType(palletIndex), palletDim.X, palletDim.Y, palletDim.Z) { Weight = palletWeight, Color = Color.Yellow }; // constraint set var constraintSet = new ConstraintSetCasePallet(); constraintSet.SetAllowedOrientations(new bool[] { false, false, true }); constraintSet.SetMaxHeight(new OptDouble(true, maxPalletHeight)); // layer 2D var layer2D = new Layer2DBrickExpIndexed(caseDim, new Vector2D(), "", HalfAxis.HAxis.AXIS_Z_P); layer2D.SetPositions(boxPositions); // analysis var analysis = new AnalysisCasePallet(boxProperties, palletProperties, constraintSet); analysis.AddInterlayer(new InterlayerProperties(null, "interlayer", "", palletDim.X, palletDim.Y, 1.0, 0.0, Color.LightYellow)); analysis.AddSolution(layer2D, mirrorLength, mirrorWidth); // solution SolutionLayered sol = analysis.SolutionLay; var solutionItems = sol.SolutionItems; int iCount = solutionItems.Count; for (int i = 0; i < iCount; ++i) { solutionItems[i].InterlayerIndex = ((i < interlayers.Count) && interlayers[i]) ? 0 : -1; } if (iCount < interlayers.Count && interlayers[iCount]) { analysis.PalletCapProperties = new PalletCapProperties(null, "palletcap", "", palletDim.X, palletDim.Y, 1, palletDim.X, palletDim.Y, 0.0, 0.0, Color.LightYellow); } layerCount = analysis.SolutionLay.LayerCount; caseCount = analysis.Solution.ItemCount; weightLoad = analysis.Solution.LoadWeight; weightTotal = analysis.Solution.Weight; bbGlob = analysis.Solution.BBoxGlobal.DimensionsVec; bbLoad = analysis.Solution.BBoxLoad.DimensionsVec; // generate image path Graphics3DImage graphics = new Graphics3DImage(sz) { BackgroundColor = Color.Transparent, FontSizeRatio = ConfigSettings.FontSizeRatio, ShowDimensions = true }; graphics.SetCameraPosition(10000.0, angle, 45.0); using (ViewerSolution sv = new ViewerSolution(analysis.SolutionLay)) sv.Draw(graphics, Transform3D.Identity); graphics.Flush(); Bitmap bmp = graphics.Bitmap; ImageConverter converter = new ImageConverter(); imageBytes = (byte[])converter.ConvertTo(bmp, typeof(byte[])); }
public static void GetSolution( Vector3D caseDim, double caseWeight, Vector3D palletDim, double palletWeight, double maxPalletHeight, List <BoxPosition> boxPositions, bool alternateLayer, bool interlayerBottom, bool interlayerIntermediate, bool interlayerTop, double angle, ref byte[] imageBytes, ref int caseCount, ref int layerCount, ref double weightLoad, ref double weightTotal, ref Vector3D bbLoad, ref Vector3D bbGlob ) { SolutionLayered.SetSolver(new LayerSolver()); // case var boxProperties = new BoxProperties(null, caseDim.X, caseDim.Y, caseDim.Z) { TapeColor = Color.LightGray, TapeWidth = new OptDouble(true, 50.0) }; boxProperties.SetWeight(caseWeight); boxProperties.SetAllColors(Enumerable.Repeat(Color.Beige, 6).ToArray()); // pallet var palletProperties = new PalletProperties(null, "EUR2", palletDim.X, palletDim.Y, palletDim.Z) { Weight = palletWeight, Color = Color.Yellow }; // constraint set var constraintSet = new ConstraintSetCasePallet(); constraintSet.SetAllowedOrientations(new bool[] { false, false, true }); constraintSet.SetMaxHeight(new OptDouble(true, maxPalletHeight)); // layer 2D var layer2D = new Layer2DBrickExp(caseDim, new Vector2D(), "", HalfAxis.HAxis.AXIS_Z_P); layer2D.SetPositions(boxPositions); // analysis var analysis = new AnalysisCasePallet(boxProperties, palletProperties, constraintSet); analysis.AddInterlayer(new InterlayerProperties(null, "interlayer", "", palletDim.X, palletDim.Y, 1.0, 0.0, Color.LightYellow)); analysis.AddSolution(layer2D, alternateLayer); if (interlayerTop) { analysis.PalletCapProperties = new PalletCapProperties(null, "palletcap", "", palletDim.X, palletDim.Y, 1, palletDim.X, palletDim.Y, 0.0, 0.0, Color.LightYellow); } // solution SolutionLayered sol = analysis.SolutionLay; var solutionItems = sol.SolutionItems; int iCount = solutionItems.Count; for (int i = 0; i < iCount; ++i) { bool hasInterlayer = (i == 0 && interlayerBottom) || (i != 0 && interlayerIntermediate); solutionItems[i].InterlayerIndex = hasInterlayer ? 0 : -1; } layerCount = analysis.SolutionLay.LayerCount; caseCount = analysis.Solution.ItemCount; weightLoad = analysis.Solution.LoadWeight; weightTotal = analysis.Solution.Weight; bbGlob = analysis.Solution.BBoxGlobal.DimensionsVec; bbLoad = analysis.Solution.BBoxLoad.DimensionsVec; // generate image path Graphics3DImage graphics = new Graphics3DImage(new Size(500, 500)) { FontSizeRatio = ConfigSettings.FontSizeRatio, ShowDimensions = true }; graphics.SetCameraPosition(10000.0, angle, 45.0); using (ViewerSolution sv = new ViewerSolution(analysis.SolutionLay)) sv.Draw(graphics, Transform3D.Identity); graphics.Flush(); Bitmap bmp = graphics.Bitmap; ImageConverter converter = new ImageConverter(); imageBytes = (byte[])converter.ConvertTo(bmp, typeof(byte[])); }