Esempio n. 1
0
        public static void Export(
            Vector3D caseDim, double caseWeight,
            int palletIndex, double palletWeight,
            int noLayers,
            List <BoxPositionIndexed> listBoxPositionIndexed,
            bool mirrorLength, bool mirrorWidth,
            List <bool> interlayers,
            ref byte[] fileBytes,
            System.Drawing.Imaging.ImageFormat imageFormat,
            ref byte[] imageFileBytes)
        {
            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
            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.OptMaxLayerNumber = noLayers;

            // layer
            var layer2D = new Layer2DBrickExpIndexed(caseDim, new Vector2D(palletDim.X, palletDim.Y), "", HalfAxis.HAxis.AXIS_Z_P);

            layer2D.SetPositions(listBoxPositionIndexed);
            // 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);


            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);
            }

            // export
            var exporter = ExporterFactory.GetExporterByName("csv (TechnologyBSA)");

            exporter.PositionCoordinateMode = Exporter.CoordinateMode.CM_COG;
            Stream stream = new MemoryStream();

            exporter.ExportIndexed(analysis, ref stream);
            // save stream to file
            using (var br = new BinaryReader(stream))
                fileBytes = br.ReadBytes((int)stream.Length);

            // image
            var graphics = new Graphics3DImage(ConfigSettings.ExportImageSize)
            {
                CameraPosition = Graphics3D.Corner_0,
                ShowDimensions = ConfigSettings.ExportShowDimensions
            };

            using (ViewerSolution sv = new ViewerSolution(analysis.SolutionLay))
                sv.Draw(graphics, Transform3D.Identity);
            graphics.Flush();

            imageFileBytes = ImageToByteArray(graphics.Bitmap, imageFormat);
        }
Esempio n. 2
0
        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[]));
        }
Esempio n. 3
0
        public static void GenerateExport(Vector3D caseDim, double caseWeight, Bitmap bmpTexture,
                                          int palletIndex, double palletWeight,
                                          int layerNumber,
                                          List <BoxPositionIndexed> boxPositions,
                                          bool mirrorLength, bool mirrorWidth,
                                          List <bool> interlayers,
                                          string filePath,
                                          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.OptMaxLayerNumber = layerNumber;
            // 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.White));
            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.White);
            }
            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;
            // export file
            var exporter = new ExporterGLB();

            exporter.Export(analysis, filePath);
        }