コード例 #1
0
        public override void OnNext()
        {
            try
            {
                Layer2DBrickImp selLayer = SelectedLayer;
                var layerEncaps = new List<LayerEncap>() { new LayerEncap(selLayer.LayerDescriptor) };
                SolutionLayered.SetSolver(new LayerSolver());
                AnalysisCasePallet analysis = AnalysisCast;
                if (null == analysis)
                    _item = _document.CreateNewAnalysisCasePallet(
                        ItemName, ItemDescription
                        , SelectedPackable, SelectedPallet
                        , new List<InterlayerProperties>()
                        , null, null, null
                        , BuildConstraintSet()
                        , layerEncaps
                        );
                else
                {
                    analysis.ID.SetNameDesc(ItemName, ItemDescription);
                    analysis.Content = SelectedPackable;
                    analysis.PalletProperties = SelectedPallet;
                    analysis.ConstraintSet = BuildConstraintSet();
                    analysis.AddSolution(layerEncaps);

                    _document.UpdateAnalysis(analysis);
                }
                Close();
            }
            catch (Exception ex)
            {
                _log.Error(ex.ToString());
            }
        }
コード例 #2
0
        public List <Analysis> BuildAnalyses(ConstraintSetAbstract constraintSet, bool allowMultipleLayerOrientations)
        {
            var analyses = new List <Analysis>();
            var constraintSetCasePallet = constraintSet as ConstraintSetCasePallet;

            if (null == constraintSetCasePallet)
            {
                return(analyses);
            }
            Vector2D overhang = constraintSetCasePallet.Overhang;

            if (allowMultipleLayerOrientations)
            {
                List <KeyValuePair <LayerDesc, int> > listLayer = new List <KeyValuePair <LayerDesc, int> >();
                LayerSolver.GetBestCombination(
                    _packable.OuterDimensions,
                    _palletProperties.GetStackingDimensions(constraintSet),
                    constraintSet,
                    ref listLayer);
                Solution.SetSolver(new LayerSolver());
                var analysis = new AnalysisCasePallet(_packable, _palletProperties, constraintSet as ConstraintSetCasePallet);
                analysis.AddSolution(listLayer);
                // only add analysis if it has a valid solution
                if (analysis.Solution.ItemCount > 0)
                {
                    analyses.Add(analysis);
                }
            }
            else
            {
                // build layer list
                var            solver = new LayerSolver();
                List <Layer2D> layers = solver.BuildLayers(
                    _packable.OuterDimensions
                    , new Vector2D(_palletProperties.Length + 2.0 * overhang.X, _palletProperties.Width + 2.0 * overhang.Y)
                    , _palletProperties.Height
                    , constraintSetCasePallet
                    , true
                    );
                Solution.SetSolver(solver);
                // loop on layers
                foreach (Layer2D layer in layers)
                {
                    var layerDescs = new List <LayerDesc> {
                        layer.LayerDescriptor
                    };
                    var analysis = new AnalysisCasePallet(_packable, _palletProperties, constraintSet as ConstraintSetCasePallet);
                    analysis.AddSolution(layerDescs);
                    // only add analysis if it has a valid solution
                    if (analysis.Solution.ItemCount > 0)
                    {
                        analyses.Add(analysis);
                    }
                }
            }
            return(analyses);
        }
コード例 #3
0
        public AnalysisLayered BuildAnalysis(LayerDescBox layerDesc)
        {
            SolutionLayered.SetSolver(new LayerSolver());
            AnalysisLayered analysis = new AnalysisCasePallet(Packable, PalletProperties, ConstraintSet);

            analysis.AddSolution(new List <LayerDesc>()
            {
                layerDesc
            });
            return(analysis);
        }
コード例 #4
0
        public void Draw(Graphics3DControl ctrl, Graphics3D graphics)
        {
            Layer2DBrickImp selLayer = SelectedLayer;
            PalletProperties pallet = SelectedPallet;
            Packable packable = SelectedPackable;
            if (null == selLayer || null == packable || null == pallet)
                return;
            var analysis = new AnalysisCasePallet(packable, pallet, BuildConstraintSet(), true /*temporary*/);
            analysis.AddSolution(new List<LayerDesc> { selLayer.LayerDescriptor });

            ViewerSolution sv = new ViewerSolution(analysis.SolutionLay);
            sv.Draw(graphics, Transform3D.Identity);
        }
コード例 #5
0
        public override void OnNext()
        {
            try
            {
                List <LayerDesc> layerDescs = new List <LayerDesc>();
                foreach (Layer2D layer2D in uCtrlLayerList.Selected)
                {
                    layerDescs.Add(layer2D.LayerDescriptor);
                }

                Solution.SetSolver(new LayerSolver());

                AnalysisCasePallet analysis = AnalysisCast;
                if (null == analysis)
                {
                    _item = _document.CreateNewAnalysisCasePallet(
                        ItemName, ItemDescription
                        , SelectedPackable, SelectedPallet
                        , new List <InterlayerProperties>()
                        , null, null, null
                        , BuildConstraintSet()
                        , layerDescs
                        );
                }
                else
                {
                    analysis.ID.SetNameDesc(ItemName, ItemDescription);
                    analysis.Content          = SelectedPackable;
                    analysis.PalletProperties = SelectedPallet;
                    analysis.ConstraintSet    = BuildConstraintSet();
                    analysis.AddSolution(layerDescs);

                    _document.UpdateAnalysis(analysis);
                }
                Close();
            }
            catch (Exception ex)
            {
                _log.Error(ex.ToString());
            }
        }
コード例 #6
0
        public List <Analysis> BuildAnalyses(ConstraintSetAbstract constraintSet)
        {
            var analyses = new List <Analysis>();
            var constraintSetCasePallet = constraintSet as ConstraintSetCasePallet;

            if (null == constraintSetCasePallet)
            {
                return(analyses);
            }
            Vector2D overhang = constraintSetCasePallet.Overhang;
            // build layer list
            var            solver = new LayerSolver();
            List <Layer2D> layers = solver.BuildLayers(
                _packable.OuterDimensions
                , new Vector2D(_palletProperties.Length + 2.0 * overhang.X, _palletProperties.Width + 2.0 * overhang.Y)
                , _palletProperties.Height
                , constraintSetCasePallet
                , true
                );

            Solution.SetSolver(solver);
            // loop on layers
            foreach (Layer2D layer in layers)
            {
                var layerDescs = new List <LayerDesc>();
                layerDescs.Add(layer.LayerDescriptor);
                var analysis = new AnalysisCasePallet(_packable, _palletProperties, constraintSet as ConstraintSetCasePallet);
                analysis.AddSolution(layerDescs);
                // only add analysis if it has a valid solution
                if (analysis.Solution.ItemCount > 0)
                {
                    analyses.Add(analysis);
                }
            }
            return(analyses);
        }
コード例 #7
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[]));
        }
コード例 #8
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);
        }
コード例 #9
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);
        }
コード例 #10
0
        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);
        }
コード例 #11
0
        public static bool GetSolutionByLayer(
            PackableBrick packableProperties, PalletProperties palletProperties, InterlayerProperties interlayerProperties
            , ConstraintSetCasePallet constraintSet
            , LayerDesc layerDesc
            , Vector3D cameraPosition, bool showCotations, float fontSizeRatio, Size sz
            , ref int layerCount, ref int caseCount, ref int interlayerCount
            , ref double weightTotal, ref double weightLoad, ref double?weightNet
            , ref Vector3D bbLoad, ref Vector3D bbGlob
            , ref double volumeEfficency, ref double?weightEfficiency
            , ref string palletMapPhrase
            , ref byte[] imageBytes
            , ref string[] errors
            )
        {
            List <string> lErrors = new List <string>();

            try
            {
                if (!packableProperties.FitsIn(palletProperties, constraintSet))
                {
                    lErrors.Add($"{packableProperties.Name} does not fit in {palletProperties.Name} with given constraint set!");
                    return(false);
                }
                SolutionLayered.SetSolver(new LayerSolver());
                var analysis = new AnalysisCasePallet(packableProperties, palletProperties, constraintSet);
                analysis.AddSolution(new List <LayerDesc>()
                {
                    layerDesc
                });

                layerCount      = analysis.SolutionLay.LayerCount;
                caseCount       = analysis.Solution.ItemCount;
                interlayerCount = analysis.SolutionLay.LayerCount;

                weightLoad  = analysis.Solution.LoadWeight;
                weightTotal = analysis.Solution.Weight;

                OptDouble optNetWeight = analysis.Solution.NetWeight;
                weightNet        = optNetWeight.Activated ? optNetWeight.Value : (double?)null;
                bbGlob           = analysis.Solution.BBoxGlobal.DimensionsVec;
                bbLoad           = analysis.Solution.BBoxLoad.DimensionsVec;
                volumeEfficency  = analysis.Solution.VolumeEfficiency;
                weightEfficiency = null;
                if (analysis.Solution.WeightEfficiency.Activated)
                {
                    weightEfficiency = analysis.Solution.WeightEfficiency.Value;
                }
                // generate image path
                Graphics3DImage graphics = new Graphics3DImage(sz)
                {
                    FontSizeRatio  = fontSizeRatio,
                    CameraPosition = cameraPosition,
                    ShowDimensions = showCotations
                };
                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[]));

                // pallet phrase
                palletMapPhrase = BuildPalletMapPhrase(analysis.SolutionLay);
            }
            catch (Exception ex)
            {
                lErrors.Add(ex.Message);
            }
            errors = lErrors.ToArray();
            return(0 == lErrors.Count);
        }
コード例 #12
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[]));
    }
コード例 #13
0
    public static void GenerateExport(Vector3D caseDim, double caseWeight, Bitmap bmpTexture,
                                      Vector3D palletDim, double palletWeight,
                                      double maxPalletHeight,
                                      List <BoxPosition> boxPositions,
                                      bool mirrorLength, bool mirrorWidth,
                                      bool interlayerBottom, bool interlayerIntermediate, bool interlayerTop,
                                      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.LightYellow));
        analysis.AddSolution(layer2D, mirrorLength, mirrorWidth);
        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;
        // export file
        var exporter = new ExporterGLB();

        exporter.Export(analysis as AnalysisLayered, filePath);
    }