예제 #1
0
        private void GenerateResult(
            string name, string description
            , double length, double width, double height
            , double?weight
            , PalletProperties palletProperties
            , ref int stackCount
            , ref int layerCount, ref int byLayerCount
            , ref double loadWeight, ref double totalWeight
            , ref double stackEfficiency
            , ref string stackImagePath)
        {
            stackCount     = 0;
            totalWeight    = 0.0;
            stackImagePath = string.Empty;

            // generate case
            var bProperties = new BoxProperties(null, length, width, height);

            bProperties.ID.SetNameDesc(name, description);
            if (weight.HasValue)
            {
                bProperties.SetWeight(weight.Value);
            }
            bProperties.SetColor(Color.Chocolate);
            bProperties.TapeWidth = new OptDouble(true, Math.Min(UnitsManager.ConvertLengthFrom(50.0, UnitsManager.UnitSystem.UNIT_METRIC1), 0.5 * width));
            bProperties.TapeColor = Color.Beige;

            // generate image path
            if (GenerateImage)
            {
                stackImagePath = Path.Combine(Path.ChangeExtension(Path.GetTempFileName(), "png"));
            }
            else if (GenerateImageInFolder)
            {
                stackImagePath = Path.ChangeExtension(Path.Combine(DirectoryPathImages, name), "png");
            }

            Graphics3DImage graphics = null;

            if (GenerateImage || GenerateImageInFolder)
            {
                graphics = new Graphics3DImage(new Size(ImageSize, ImageSize))
                {
                    FontSizeRatio  = Settings.Default.FontSizeRatio,
                    CameraPosition = Graphics3D.Corner_0
                };
            }

            // compute analysis
            ConstraintSetCasePallet constraintSet = new ConstraintSetCasePallet();

            constraintSet.SetAllowedOrientations(new[] { !AllowOnlyZOrientation, !AllowOnlyZOrientation, true });
            constraintSet.SetMaxHeight(new OptDouble(true, PalletMaximumHeight));
            constraintSet.Overhang = Overhang;

            SolverCasePallet       solver   = new SolverCasePallet(bProperties, palletProperties, constraintSet);
            List <AnalysisLayered> analyzes = solver.BuildAnalyses(false);

            if (analyzes.Count > 0)
            {
                var analysis = analyzes[0];
                stackCount      = analysis.Solution.ItemCount;
                loadWeight      = analysis.Solution.LoadWeight;
                totalWeight     = analysis.Solution.Weight;
                stackEfficiency = analysis.Solution.VolumeEfficiency;

                if (analysis.Solution is SolutionLayered solutionLayered)
                {
                    layerCount = solutionLayered.LayerCount;
                    if (solutionLayered.Layers.Count > 0)
                    {
                        byLayerCount = solutionLayered.Layers[0].BoxCount;
                    }
                }

                if (stackCount <= StackCountMax)
                {
                    if (GenerateImage || GenerateImageInFolder)
                    {
                        var sv = new ViewerSolution(analysis.SolutionLay);
                        sv.Draw(graphics, Transform3D.Identity);
                        graphics.Flush();
                    }
                    if (GenerateReport)
                    {
                        var    inputData      = new ReportDataAnalysis(analysis);
                        string outputFilePath = Path.ChangeExtension(Path.Combine(DirectoryPathReports,
                                                                                  $"Report_{analysis.Content.Name}_on_{analysis.Container.Name}"), "pdf");

                        var rnRoot  = new ReportNode(Resources.ID_REPORT);
                        var margins = new Margins();
                        //Reporter reporter = new ReporterMSWord(inputData, ref rnRoot, Settings.Default.ReportTemplatePath/*Reporter.TemplatePath*/, outputFilePath, margins);
                        Reporter.SetFontSizeRatios(0.015F, 0.05F);
                        Reporter reporter = new ReporterPDF(inputData, ref rnRoot, Settings.Default.ReportTemplatePath, outputFilePath);
                    }
                }
            }
            if (GenerateImage || GenerateImageInFolder)
            {
                var bmp = graphics.Bitmap;
                bmp.Save(stackImagePath, System.Drawing.Imaging.ImageFormat.Png);
            }
        }
예제 #2
0
        private void GenerateResult(
            string name
            , double length, double width, double height
            , double?weight
            , ref int stackCount, ref double stackWeight, ref double stackEfficiency
            , ref string stackImagePath)
        {
            stackCount     = 0;
            stackWeight    = 0.0;
            stackImagePath = string.Empty;

            // generate case
            BoxProperties bProperties = new BoxProperties(null, length, width, height);

            if (weight.HasValue)
            {
                bProperties.SetWeight(weight.Value);
            }
            bProperties.SetColor(Color.Chocolate);
            bProperties.TapeWidth = new OptDouble(true, Math.Min(50.0, 0.5 * width));
            bProperties.TapeColor = Color.Beige;

            Graphics3DImage graphics = null;

            if (GenerateImage || GenerateImageInFolder)
            {
                // generate image path
                stackImagePath = Path.Combine(Path.ChangeExtension(Path.GetTempFileName(), "png"));

                if (GenerateImageInFolder)
                {
                    stackImagePath = Path.ChangeExtension(Path.Combine(Path.Combine(DirectoryPathImages, name)), "png");
                }

                graphics = new Graphics3DImage(new Size(ImageSize, ImageSize))
                {
                    FontSizeRatio  = this.FontSizeRatio,
                    CameraPosition = Graphics3D.Corner_0
                };
            }

            // compute analysis
            if (0 == Mode)
            {
                ConstraintSetCasePallet constraintSet = new ConstraintSetCasePallet();
                constraintSet.SetAllowedOrientations(new bool[] { !AllowOnlyZOrientation, !AllowOnlyZOrientation, true });
                constraintSet.SetMaxHeight(new OptDouble(true, PalletMaximumHeight));

                SolverCasePallet       solver   = new SolverCasePallet(bProperties, PalletProperties, constraintSet);
                List <AnalysisLayered> analyses = solver.BuildAnalyses(false);
                if (analyses.Count > 0)
                {
                    AnalysisLayered analysis = analyses[0];
                    stackCount      = analysis.Solution.ItemCount;
                    stackWeight     = analysis.Solution.Weight;
                    stackEfficiency = analysis.Solution.VolumeEfficiency;

                    if (stackCount <= StackCountMax)
                    {
                        if (GenerateImage || GenerateImageInFolder)
                        {
                            ViewerSolution sv = new ViewerSolution(analysis.Solution as SolutionLayered);
                            sv.Draw(graphics, Transform3D.Identity);
                            graphics.Flush();
                        }
                        if (GenerateReport)
                        {
                            ReportDataAnalysis inputData      = new ReportDataAnalysis(analysis);
                            string             outputFilePath = Path.ChangeExtension(Path.Combine(Path.GetDirectoryName(OutputFilePath), string.Format("Report_{0}_on_{1}", analysis.Content.Name, analysis.Container.Name)), "doc");

                            ReportNode rnRoot   = null;
                            Margins    margins  = new Margins();
                            Reporter   reporter = new ReporterMSWord(inputData, ref rnRoot, Reporter.TemplatePath, outputFilePath, margins);
                        }
                    }
                }
            }
            else
            {
                BoxProperties container = new BoxProperties(null, TruckLength, TruckWidth, TruckHeight, TruckLength, TruckWidth, TruckHeight);
                Color         lblue     = Color.LightBlue;
                container.SetAllColors(new Color[] { lblue, lblue, lblue, lblue, lblue, lblue });
                container.SetWeight(0.0);
                ConstraintSetBoxCase constraintSet = new ConstraintSetBoxCase(container);
                constraintSet.SetAllowedOrientations(new bool[] { !AllowOnlyZOrientation, !AllowOnlyZOrientation, true });

                SolverBoxCase          solver   = new SolverBoxCase(bProperties, container, constraintSet);
                List <AnalysisLayered> analyses = solver.BuildAnalyses(false);
                if (analyses.Count > 0)
                {
                    AnalysisLayered analysis = analyses[0];
                    stackCount  = analysis.Solution.ItemCount;
                    stackWeight = analysis.Solution.Weight;

                    if ((GenerateImage || GenerateImageInFolder) && stackCount <= StackCountMax)
                    {
                        ViewerSolution sv = new ViewerSolution(analysis.Solution as SolutionLayered);
                        sv.Draw(graphics, Transform3D.Identity);
                        graphics.Flush();
                    }
                }
            }
            if (GenerateImage)
            {
                Bitmap bmp = graphics.Bitmap;
                bmp.Save(stackImagePath, System.Drawing.Imaging.ImageFormat.Png);
            }
        }