private void OnEditLayerRight(object sender, EventArgs e)
 {
     try
     {
         // get content
         if (!(cbCases.SelectedType is Packable packable))
         {
             return;
         }
         // get container
         var      constraintSet = BuildConstraintSet();
         Vector2D layerDim      = new Vector2D(SelectedPallet.Length, SelectedPallet.Width) + 2 * constraintSet.Overhang;
         // get selected layer
         ILayer2D[] layers = uCtrlLayerListEdited.Selected;
         if (layers.Length != 1)
         {
             return;
         }
         Layer2DBrickExp layer = layers[0] as Layer2DBrickExp;
         using (var form = new FormEditLayer(layer, packable))
         {
             form.TopMost = true;
             if (DialogResult.OK == form.ShowDialog())
             {
                 _layersEdited.Remove(layer);
                 _layersEdited.Add(form.Layer);
                 FillEditedLayerList();
             }
         }
     }
     catch (Exception ex)
     {
         _log.Error(ex.ToString());
     }
 }
        public FormEditLayer(Layer2DBrickExp layer, Packable content)
        {
            InitializeComponent();

            Layer   = layer;
            Content = content as PackableBrick;
            uCtrlLayerEditor.Content = Content;
            uCtrlLayerEditor.Layer   = Layer;
        }
        public static void GetSolution(
            Vector3D caseDim, double caseWeight, Bitmap bmpTexture,
            Vector3D palletDim, double palletWeight,
            double maxPalletHeight,
            List <BoxPosition> 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
            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, 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 Export(
            Vector3D caseDim, double caseWeight,
            Vector3D palletDim, double palletWeight,
            double maxPalletHeight,
            List <BoxPosition> boxPositions,
            bool mirrorLength, bool mirrorWidth,
            List <bool> interlayers,
            ref byte[] fileBytes)
        {
            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
            var layer2D = new Layer2DBrickExp(caseDim, new Vector2D(palletDim.X, palletDim.Y), "", 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);


            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.Export(analysis, ref stream);
            // save stream to file
            using (var br = new BinaryReader(stream))
                fileBytes = br.ReadBytes((int)stream.Length);
        }
        public static void GenerateExport(Vector3D caseDim, double caseWeight, Bitmap bmpTexture,
                                          Vector3D palletDim, double palletWeight,
                                          double maxPalletHeight,
                                          List <BoxPosition> 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
            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.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);
        }
Exemple #6
0
    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[]));
    }