示例#1
0
        public Bitmap Image(Size s, Vector3D vCamera, Vector3D vTarget, ref Point offset)
        {
            if (
                (
                    null == _bitmap ||
                    ((_vCamera - vCamera).GetLengthSquared() > 1.0E-06 && (_vTarget - vTarget).GetLengthSquared() > 1.0E-06)
                ) &&
                null != _analysis)
            {
                // generate bitmap
                Graphics3DImage graphics = new Graphics3DImage(s);
                graphics.BackgroundColor  = Color.Transparent;
                graphics.CameraPosition   = vCamera;
                graphics.Target           = vTarget;
                graphics.MarginPercentage = 0.0;
                graphics.ShowDimensions   = false;
                using (ViewerSolution viewer = new ViewerSolution(_analysis.Solution))
                { viewer.Draw(graphics, RelativeTransf); }
                graphics.Flush();

                // save bitmap
                _bitmap  = graphics.Bitmap;
                _vCamera = vCamera;
                _vTarget = vTarget;
                _offset  = graphics.Offset;
            }
            offset = _offset;
            return(_bitmap);
        }
        public static void Draw(Packable packable, PictureBox pictureBox)
        {
            // get horizontal angle
            double angle = 45;
            // instantiate graphics
            Graphics3DImage graphics = new Graphics3DImage(pictureBox.Size);

            graphics.CameraPosition = new Vector3D(
                Math.Cos(angle * Math.PI / 180.0) * Math.Sqrt(2.0) * 10000.0
                , Math.Sin(angle * Math.PI / 180.0) * Math.Sqrt(2.0) * 10000.0
                , 10000.0);
            graphics.Target = Vector3D.Zero;
            graphics.SetViewport(-500.0f, -500.0f, 500.0f, 500.0f);

            // ### draw : begin ##############################
            if (packable is PackProperties)
            {
                Box box = new Pack(0, packable as PackProperties);
                graphics.AddBox(box);
            }
            else if (packable is BProperties)
            {
                Box box = new Box(0, packable as PackableBrick);
                graphics.AddBox(box);
            }
            else if (packable is CylinderProperties)
            {
                graphics.AddCylinder(new Cylinder(0, packable as CylinderProperties));
            }
            // ### draw : end #################################

            graphics.Flush();
            // set to picture box
            pictureBox.Image = graphics.Bitmap;
        }
示例#3
0
 public static void Draw(BProperties boxProperties, HalfAxis.HAxis axis, PictureBox pictureBox)
 {
     // get horizontal angle
     double angle = 45;
     // instantiate graphics
     Graphics3DImage graphics = new Graphics3DImage(pictureBox.Size);
     graphics.CameraPosition = new Vector3D(
         Math.Cos(angle * Math.PI / 180.0) * Math.Sqrt(2.0) * 10000.0
         , Math.Sin(angle * Math.PI / 180.0) * Math.Sqrt(2.0) * 10000.0
         , 10000.0);
     graphics.Target = Vector3D.Zero;
     graphics.SetViewport(-500.0f, -500.0f, 500.0f, 500.0f);
     // draw
     Box box = new Box(0, boxProperties);
     // set axes
     HalfAxis.HAxis lengthAxis = HalfAxis.HAxis.AXIS_X_P;
     HalfAxis.HAxis widthAxis = HalfAxis.HAxis.AXIS_Y_P;
     switch (axis)
     {
         case HalfAxis.HAxis.AXIS_X_P: lengthAxis = HalfAxis.HAxis.AXIS_Z_P; widthAxis = HalfAxis.HAxis.AXIS_X_P; break;
         case HalfAxis.HAxis.AXIS_Y_P: lengthAxis = HalfAxis.HAxis.AXIS_X_P; widthAxis = HalfAxis.HAxis.AXIS_Z_N; break;
         case HalfAxis.HAxis.AXIS_Z_P: lengthAxis = HalfAxis.HAxis.AXIS_X_P; widthAxis = HalfAxis.HAxis.AXIS_Y_P; break;
         default: break;
     }
     box.LengthAxis = treeDiM.StackBuilder.Basics.HalfAxis.ToVector3D(lengthAxis);
     box.WidthAxis = treeDiM.StackBuilder.Basics.HalfAxis.ToVector3D(widthAxis);
     // draw box
     graphics.AddBox(box);
     graphics.Flush();
     // set to picture box
     pictureBox.Image = graphics.Bitmap;
 }
示例#4
0
        public Bitmap Image(Size s, Vector3D vCamera, Vector3D vTarget, ref Point offset)
        {
            if
            (
                null == Bitmap ||
                ((VCamera - vCamera).GetLengthSquared() > 1.0E-06 && (VTarget - vTarget).GetLengthSquared() > 1.0E-06)
            )
            {
                // generate bitmap
                Graphics3DImage graphics = new Graphics3DImage(s)
                {
                    BackgroundColor  = Color.Transparent,
                    CameraPosition   = vCamera,
                    Target           = vTarget,
                    MarginPercentage = 0.0,
                    ShowDimensions   = false
                };
                if (null != Content)
                {
                    Content.Draw(graphics, RelativeTransf);
                }
                graphics.Flush();

                // save bitmap
                Bitmap  = graphics.Bitmap;
                VCamera = vCamera;
                VTarget = vTarget;
                Offset  = graphics.Offset;
            }
            offset = Offset;
            return(Bitmap);
        }
        public void ScreenShotToClipboard()
        {
            var graphics = new Graphics3DImage(this.Size);

            try
            {
                double angleHorizRad  = AngleHoriz * Math.PI / 180.0;
                double angleVertRad   = AngleVert * Math.PI / 180.0;
                double cameraDistance = 100000.0;
                graphics.CameraPosition = new Vector3D(
                    cameraDistance * Math.Cos(angleHorizRad) * Math.Cos(angleVertRad)
                    , cameraDistance * Math.Sin(angleHorizRad) * Math.Cos(angleVertRad)
                    , cameraDistance * Math.Sin(angleVertRad));
                // set camera target
                graphics.Target = Vector3D.Zero;
                // set viewport (not actually needed)
                graphics.SetViewport(-500.0f, -500.0f, 500.0f, 500.0f);
                // show images
                graphics.ShowTextures   = true;
                graphics.ShowDimensions = ShowDimensions;
                graphics.FontSizeRatio  = 10.0f / (float)Size.Height;

                if (null != DrawingContainer)
                {
                    try
                    {
                        DrawingContainer.Draw(this, graphics);
                    }
                    catch (Exception ex)
                    {
                        _log.Error(ex.ToString());
                    }
                }
                else if (null != Viewer)
                {
                    try
                    {
                        Viewer.Draw(graphics, Transform3D.Identity);
                    }
                    catch (Exception ex)
                    {
                        graphics.Graphics.DrawString(ex.Message
                                                     , new Font("Arial", 12)
                                                     , new SolidBrush(Color.Red)
                                                     , new Point(0, 0)
                                                     , StringFormat.GenericDefault);
                        _log.Error(ex.Message);
                    }
                }

                graphics.Flush();
            }
            catch (Exception ex)
            {
                _log.Error(ex.ToString());
            }
            Clipboard.SetImage(BitmapHelpers.Crop(graphics.Bitmap));
        }
示例#6
0
        public static void Draw(PackableBrick packable, HalfAxis.HAxis axis, PictureBox pictureBox)
        {
            try
            {
                // get horizontal angle
                double angle          = 45;
                double cameraDistance = 100000;
                // instantiate graphics
                Graphics3DImage graphics = new Graphics3DImage(pictureBox.Size)
                {
                    CameraPosition = new Vector3D(
                        Math.Cos(angle * Math.PI / 180.0) * Math.Sqrt(2.0) * cameraDistance
                        , Math.Sin(angle * Math.PI / 180.0) * Math.Sqrt(2.0) * cameraDistance
                        , cameraDistance),
                    Target = Vector3D.Zero
                };
                graphics.SetViewport(-500.0f, -500.0f, 500.0f, 500.0f);
                // draw
                Box box = null;
                if (packable is PackProperties)
                {
                    box = new Pack(0, packable as PackProperties);
                }
                else
                {
                    box = new Box(0, packable);
                }
                // set axes
                HalfAxis.HAxis lengthAxis = HalfAxis.HAxis.AXIS_X_P;
                HalfAxis.HAxis widthAxis  = HalfAxis.HAxis.AXIS_Y_P;
                switch (axis)
                {
                case HalfAxis.HAxis.AXIS_X_P: lengthAxis = HalfAxis.HAxis.AXIS_Z_P; widthAxis = HalfAxis.HAxis.AXIS_X_P; break;

                case HalfAxis.HAxis.AXIS_Y_P: lengthAxis = HalfAxis.HAxis.AXIS_X_P; widthAxis = HalfAxis.HAxis.AXIS_Z_N; break;

                case HalfAxis.HAxis.AXIS_Z_P: lengthAxis = HalfAxis.HAxis.AXIS_X_P; widthAxis = HalfAxis.HAxis.AXIS_Y_P; break;

                default: break;
                }
                box.HLengthAxis = lengthAxis;
                box.HWidthAxis  = widthAxis;
                // draw box
                graphics.AddBox(box);
                graphics.Flush();
                // set to picture box
                pictureBox.Image = graphics.Bitmap;
            }
            catch (Exception ex)
            {
                Bitmap bmp = new Bitmap(pictureBox.Size.Width, pictureBox.Size.Height);
                System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bmp);
                g.DrawString("Invalid content", new Font("Arial", 8), new SolidBrush(Color.Red), new PointF(5, 10));
                pictureBox.Image = bmp;

                _log.Error(ex.ToString());
            }
        }
示例#7
0
        public static void Draw(Packable packable, HalfAxis.HAxis axis, PictureBox pictureBox)
        {
            // get horizontal angle
            double angle = 45;
            // instantiate graphics
            Graphics3DImage graphics = new Graphics3DImage(pictureBox.Size);

            graphics.CameraPosition = new Vector3D(
                Math.Cos(angle * Math.PI / 180.0) * Math.Sqrt(2.0) * 10000.0
                , Math.Sin(angle * Math.PI / 180.0) * Math.Sqrt(2.0) * 10000.0
                , 10000.0);
            graphics.Target = Vector3D.Zero;
            graphics.SetViewport(-500.0f, -500.0f, 500.0f, 500.0f);
            // draw
            Box box = null;

            if (packable is PackProperties)
            {
                box = new Pack(0, packable as PackProperties);
            }
            else
            {
                box = new Box(0, packable);
            }
            // set axes
            HalfAxis.HAxis lengthAxis = HalfAxis.HAxis.AXIS_X_P;
            HalfAxis.HAxis widthAxis  = HalfAxis.HAxis.AXIS_Y_P;
            switch (axis)
            {
            case HalfAxis.HAxis.AXIS_X_P: lengthAxis = HalfAxis.HAxis.AXIS_Z_P; widthAxis = HalfAxis.HAxis.AXIS_X_P; break;

            case HalfAxis.HAxis.AXIS_Y_P: lengthAxis = HalfAxis.HAxis.AXIS_X_P; widthAxis = HalfAxis.HAxis.AXIS_Z_N; break;

            case HalfAxis.HAxis.AXIS_Z_P: lengthAxis = HalfAxis.HAxis.AXIS_X_P; widthAxis = HalfAxis.HAxis.AXIS_Y_P; break;

            default: break;
            }
            box.LengthAxis = treeDiM.StackBuilder.Basics.HalfAxis.ToVector3D(lengthAxis);
            box.WidthAxis  = treeDiM.StackBuilder.Basics.HalfAxis.ToVector3D(widthAxis);
            // draw box
            graphics.AddBox(box);
            graphics.Flush();
            // set to picture box
            pictureBox.Image = graphics.Bitmap;
        }
示例#8
0
        public Bitmap Image(Size s, Vector3D vCamera, Vector3D vTarget, ref Point offset)
        {
            if (
                (
                    null == _bitmap ||
                    ((_vCamera - vCamera).GetLengthSquared() > 1.0E-06 && (_vTarget - vTarget).GetLengthSquared() > 1.0E-06)
                ) &&
                null != Analysis)
            {
                // generate bitmap
                Graphics3DImage graphics = new Graphics3DImage(s)
                {
                    BackgroundColor  = Color.Transparent,
                    CameraPosition   = vCamera,
                    Target           = vTarget,
                    MarginPercentage = 0.0,
                    ShowDimensions   = false
                };
                if (Analysis is AnalysisLayered analysisLay)
                {
                    using (var viewer = new ViewerSolution(analysisLay.SolutionLay))
                    { viewer.Draw(graphics, RelativeTransf); }
                }
                else if (Analysis is AnalysisHCyl analysisHCyl)
                {
                    using (var viewer = new ViewerSolutionHCyl(analysisHCyl.Solution as SolutionHCyl))
                    { viewer.Draw(graphics, RelativeTransf); }
                }
                graphics.Flush();

                // save bitmap
                _bitmap  = graphics.Bitmap;
                _vCamera = vCamera;
                _vTarget = vTarget;
                Offset   = graphics.Offset;
            }
            offset = Offset;
            return(_bitmap);
        }
示例#9
0
        static int Main(string[] args)
        {
            ILog log = LogManager.GetLogger(typeof(Program));
            XmlConfigurator.Configure();

            try
            {
                bool useSingleColor = false;
                // instantiate document
                Document doc = new Document("Test", "Test", "fga", DateTime.Now, null);

                // define pallet properties
                PalletProperties palletProperties = new PalletProperties(doc, "EUR2", 1200, 1000, 150);
                Console.WriteLine("=== Pallet properties ===");
                Console.WriteLine(palletProperties.ToString());

                bool testCylinder = false;
                if (!testCylinder)
                {
                    // define box properties
                    BoxProperties boxProperties = new BoxProperties(doc, 162, 210, 250);
                    boxProperties.Name = "Box1";
                    boxProperties.Weight = 3.0;
                    if (!useSingleColor)
                    {
                        boxProperties.SetColor(HalfAxis.HAxis.AXIS_X_N, Color.Red);
                        boxProperties.SetColor(HalfAxis.HAxis.AXIS_X_P, Color.Red);
                        boxProperties.SetColor(HalfAxis.HAxis.AXIS_Y_N, Color.Green);
                        boxProperties.SetColor(HalfAxis.HAxis.AXIS_Y_P, Color.Green);
                        boxProperties.SetColor(HalfAxis.HAxis.AXIS_Z_N, Color.Blue);
                        boxProperties.SetColor(HalfAxis.HAxis.AXIS_Z_P, Color.Blue);
                    }
                    else
                        boxProperties.SetColor(Color.Chocolate);

                    Console.WriteLine(boxProperties.ToString());


                    InterlayerProperties interlayerProperties = null;

                    // define constraints
                    CasePalletConstraintSet constraintSet = new CasePalletConstraintSet();
                    constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_X_N, true);
                    constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_X_P, true);
                    constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Y_N, true);
                    constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Y_P, true);
                    constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Z_N, true);
                    constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Z_P, true);

                    constraintSet.SetAllowedPattern("Trilock");

                    constraintSet.AllowAlignedLayers = true;
                    constraintSet.AllowAlternateLayers = false;

                    constraintSet.MaximumPalletWeight = 2000;
                    constraintSet.MaximumNumberOfItems = 2000;
                    constraintSet.MaximumHeight = 2000.0;
                    constraintSet.UseMaximumHeight = true;
                    constraintSet.UseMaximumPalletWeight = true;
                    constraintSet.UseMaximumWeightOnBox = false;
                    constraintSet.AllowLastLayerOrientationChange = true;
                    Console.WriteLine("=== Constraint set ===");
                    Console.WriteLine(constraintSet.ToString());

                    // initialize analysis
                    CasePalletAnalysis analysis = new CasePalletAnalysis(
                        boxProperties, palletProperties, interlayerProperties,
                        null, null, null, null,
                        constraintSet);

                    // initialize solver
                    CasePalletSolver solver = new CasePalletSolver();
                    solver.ProcessAnalysis(analysis);

                    Console.WriteLine("=== Solutions ===");
                    int solIndex = 0;
                    foreach (CasePalletSolution sol in analysis.Solutions)
                    {
                        // instantiate graphics
                        Graphics3DImage graphics = new Graphics3DImage(new Size(1000, 1000));
                        graphics.CameraPosition = new Vector3D(10000.0, 10000.0, 10000.0);
                        graphics.Target = Vector3D.Zero;
                        graphics.SetViewport(-500.0f, -500.0f, 500.0f, 500.0f);
                        // instantiate solution viewer
                        CasePalletSolutionViewer sv = new CasePalletSolutionViewer(sol);
                        sv.Draw(graphics);
                        graphics.Flush();
                        // save
                        string fileName = string.Format("Pallet_{0}.bmp", solIndex++);
                        string filePath = Path.Combine(Path.GetTempPath(), fileName);
                        Console.WriteLine("Saving file " + filePath + "...");
                        graphics.SaveAs(filePath);
                    }
                }
                else
                {
                    // cylinder
                    Console.WriteLine("=== Cylinder properties ===");
                    CylinderProperties cylProperties = new CylinderProperties(doc, "Cylinder", "Default cylinder",
                        90, 45.0, 100, 1.5, Color.Gray, Color.SkyBlue, Color.SkyBlue);
                    Console.WriteLine(cylProperties.ToString());
                    // constraint set
                    Console.WriteLine("=== Constraint set ===");
                    CylinderPalletConstraintSet constraintSet = new CylinderPalletConstraintSet();
                    constraintSet.UseMaximumPalletHeight = true;
                    constraintSet.MaximumPalletHeight = 1200.0;
                    constraintSet.UseMaximumPalletWeight = true;
                    constraintSet.MaximumPalletWeight = 2000;
                    constraintSet.UseMaximumNumberOfItems = true;
                    constraintSet.MaximumNumberOfItems = 2000;
                    Console.WriteLine(constraintSet.ToString());
                    // cylinder analysis
                    CylinderPalletAnalysis analysis = new CylinderPalletAnalysis(cylProperties, palletProperties, null, null, constraintSet);
                    // initialize solver
                    CylinderSolver solver = new CylinderSolver();
                    solver.ProcessAnalysis(analysis);
                    Console.WriteLine("=== Solutions ===");
                    int solIndex = 0;
                    foreach (CylinderPalletSolution sol in analysis.Solutions)
                    {
                        // instantiate graphics
                        Graphics3DImage graphics = new Graphics3DImage(new Size(512, 512));
                        graphics.CameraPosition = new Vector3D(10000.0, 10000.0, 10000.0);
                        graphics.Target = Vector3D.Zero;
                        graphics.SetViewport(-500.0f, -500.0f, 500.0f, 500.0f);
                        // instantiate solution viewer
                        CylinderPalletSolutionViewer sv = new CylinderPalletSolutionViewer(sol);
                        sv.Draw(graphics);
                        string fileName = string.Format("Pallet_{0}.jpg", solIndex++);
                        string filePath = Path.Combine(Path.GetTempPath(), fileName);
                        Console.WriteLine("Saving file " + filePath + "...");
                        graphics.SaveAs(filePath);
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
            }
            return 0;
        }
示例#10
0
 private void AppendPackElement(PackProperties packProperties, XmlElement elemPackAnalysis, XmlDocument xmlDoc)
 {
     string ns = xmlDoc.DocumentElement.NamespaceURI;
     // pack element
     XmlElement elemPack = CreateElement("pack", null, elemPackAnalysis, xmlDoc, ns);
     // name
     CreateElement("name", packProperties.Name, elemPack, xmlDoc, ns);
     // description
     CreateElement("description", packProperties.Description, elemPack, xmlDoc, ns);
     // arrangement
     PackArrangement arrangement = packProperties.Arrangement;
     CreateElement(
         "arrangement"
         , string.Format("{0} * {1} * {2}", arrangement.Length, arrangement.Width, arrangement.Height)
         , elemPack, xmlDoc, ns);
     // length / width /height
     AppendElementValue(xmlDoc, elemPack, "length", UnitsManager.UnitType.UT_LENGTH, packProperties.Length);
     AppendElementValue(xmlDoc, elemPack, "width", UnitsManager.UnitType.UT_LENGTH, packProperties.Width);
     AppendElementValue(xmlDoc, elemPack, "height", UnitsManager.UnitType.UT_LENGTH, packProperties.Height);
     // weight
     AppendElementValue(xmlDoc, elemPack, "netWeight", UnitsManager.UnitType.UT_MASS, packProperties.NetWeight);
     AppendElementValue(xmlDoc, elemPack, "wrapperWeight", UnitsManager.UnitType.UT_MASS, packProperties.Wrap.Weight);
     AppendElementValue(xmlDoc, elemPack, "weight", UnitsManager.UnitType.UT_MASS, packProperties.Weight);
     // --- build image
     Graphics3DImage graphics = new Graphics3DImage(new Size(ImageSizeDetail, ImageSizeDetail));
     graphics.CameraPosition = Graphics3D.Corner_0;
     graphics.Target = Vector3D.Zero;
     Pack pack = new Pack(0, packProperties);
     pack.ForceTransparency = true;
     graphics.AddBox(pack);
     DimensionCube dc = new DimensionCube(pack.Length, pack.Width, pack.Height); dc.FontSize = 6.0f;
     graphics.AddDimensions(dc);
     graphics.Flush();
     // view_pack_iso
     XmlElement elemImage = xmlDoc.CreateElement("view_pack_iso", ns);
     TypeConverter converter = TypeDescriptor.GetConverter(typeof(Bitmap));
     elemImage.InnerText = Convert.ToBase64String((byte[])converter.ConvertTo(graphics.Bitmap, typeof(byte[])));
     XmlAttribute styleAttribute = xmlDoc.CreateAttribute("style");
     styleAttribute.Value = string.Format("width:{0}pt;height:{1}pt", graphics.Bitmap.Width / 4, graphics.Bitmap.Height / 4);
     elemImage.Attributes.Append(styleAttribute);
     elemPack.AppendChild(elemImage);
     // save image
     SaveImageAs(graphics.Bitmap, "view_pack_iso.png");
 }
示例#11
0
 private void AppendBundleElement(BundleProperties bundleProp, XmlElement elemAnalysis, XmlDocument xmlDoc)
 {
     string ns = xmlDoc.DocumentElement.NamespaceURI;
     if (null == bundleProp) return;
     // bundle
     XmlElement elemBundle = CreateElement("bundle", null, elemAnalysis, xmlDoc, ns);
     elemAnalysis.AppendChild(elemBundle);
     // name
     XmlElement elemName = xmlDoc.CreateElement("name", ns);
     elemName.InnerText = bundleProp.Name;
     elemBundle.AppendChild(elemName);
     // description
     XmlElement elemDescription = xmlDoc.CreateElement("description", ns);
     elemDescription.InnerText = bundleProp.Description;
     elemBundle.AppendChild(elemDescription);
     // length / width / number of flats / unit thickness / unit weight / total thickness / total weight
     AppendElementValue(xmlDoc, elemBundle, "length", UnitsManager.UnitType.UT_LENGTH, bundleProp.Length);
     AppendElementValue(xmlDoc, elemBundle, "width", UnitsManager.UnitType.UT_LENGTH, bundleProp.Width);
     AppendElementValue(xmlDoc, elemBundle, "numberOfFlats", bundleProp.NoFlats);
     AppendElementValue(xmlDoc, elemBundle, "unitThickness", UnitsManager.UnitType.UT_LENGTH, bundleProp.UnitThickness);
     AppendElementValue(xmlDoc, elemBundle, "unitWeight", UnitsManager.UnitType.UT_MASS, bundleProp.UnitWeight);
     AppendElementValue(xmlDoc, elemBundle, "totalThickness", UnitsManager.UnitType.UT_LENGTH, bundleProp.UnitThickness * bundleProp.NoFlats);
     AppendElementValue(xmlDoc, elemBundle, "totalWeight", UnitsManager.UnitType.UT_MASS, bundleProp.UnitWeight * bundleProp.NoFlats);
     // --- build image
     Graphics3DImage graphics = new Graphics3DImage(new Size(ImageSizeDetail, ImageSizeDetail));
     graphics.CameraPosition = Graphics3D.Corner_0;
     Box box = new Box(0, bundleProp);
     graphics.AddBox(box);
     DimensionCube dc = new DimensionCube(bundleProp.Length, bundleProp.Width, bundleProp.Height);   dc.FontSize = 6.0f;
     graphics.AddDimensions(dc);
     graphics.Flush();
     // ---
     // view_bundle_iso
     XmlElement elemImage = xmlDoc.CreateElement("view_bundle_iso", ns);
     TypeConverter converter = TypeDescriptor.GetConverter(typeof(Bitmap));
     elemImage.InnerText = Convert.ToBase64String((byte[])converter.ConvertTo(graphics.Bitmap, typeof(byte[])));
     XmlAttribute styleAttribute = xmlDoc.CreateAttribute("style");
     styleAttribute.Value = string.Format("width:{0}pt;height:{1}pt", graphics.Bitmap.Width / 4, graphics.Bitmap.Height / 4);
     elemImage.Attributes.Append(styleAttribute);
     elemBundle.AppendChild(elemImage);
     // save images ?
     SaveImageAs(graphics.Bitmap, "view_bundle_iso.png");
 }
示例#12
0
        private void AppendCaseOfBoxesElement(CasePalletAnalysis analysis, CasePalletSolution sol, XmlElement elemPalletAnalysis, XmlDocument xmlDoc)
        {
            string ns = xmlDoc.DocumentElement.NamespaceURI;
            // get CaseOfBoxProperties
            CaseOfBoxesProperties caseOfBoxes = analysis.BProperties as CaseOfBoxesProperties;
            if (null == caseOfBoxes) return;
            // elemCaseOfBoxes
            XmlElement elemCaseOfBoxes = xmlDoc.CreateElement("caseOfBoxes", ns);
            elemPalletAnalysis.AppendChild(elemCaseOfBoxes);
            // name
            XmlElement elemName = xmlDoc.CreateElement("name", ns);
            elemName.InnerText = caseOfBoxes.Name;
            elemCaseOfBoxes.AppendChild(elemName);
            // description
            XmlElement elemDescription = xmlDoc.CreateElement("description", ns);
            elemDescription.InnerText = caseOfBoxes.Description;
            elemCaseOfBoxes.AppendChild(elemDescription);
            // length
            XmlElement elemNoX = xmlDoc.CreateElement("noX", ns);
            elemNoX.InnerText = string.Format("{0}", caseOfBoxes.CaseDefinition.Arrangement._iLength);
            elemCaseOfBoxes.AppendChild(elemNoX);
            // width
            XmlElement elemNoY = xmlDoc.CreateElement("noY", ns);
            elemNoY.InnerText = string.Format("{0}", caseOfBoxes.CaseDefinition.Arrangement._iWidth);
            elemCaseOfBoxes.AppendChild(elemNoY);
            // height
            XmlElement elemNoZ = xmlDoc.CreateElement("noZ", ns);
            elemNoZ.InnerText = string.Format("{0}", caseOfBoxes.CaseDefinition.Arrangement._iHeight);
            elemCaseOfBoxes.AppendChild(elemNoZ);
            // number of boxes
            XmlElement elemNoBoxes = xmlDoc.CreateElement("numberOfBoxes", ns);
            elemNoBoxes.InnerText = string.Format("{0}", caseOfBoxes.NumberOfBoxes);
            elemCaseOfBoxes.AppendChild(elemNoBoxes);
            // dim0
            XmlElement eltDim0 = xmlDoc.CreateElement("dim0", ns);
            eltDim0.InnerText = string.Format("{0}", caseOfBoxes.CaseDefinition.Dim0);
            elemCaseOfBoxes.AppendChild(eltDim0);
            // dim1
            XmlElement eltDim1 = xmlDoc.CreateElement("dim1", ns);
            eltDim1.InnerText = string.Format("{0}", caseOfBoxes.CaseDefinition.Dim1);
            elemCaseOfBoxes.AppendChild(eltDim1);

            AppendElementValue(xmlDoc, elemCaseOfBoxes, "innerLength", UnitsManager.UnitType.UT_LENGTH, caseOfBoxes.InsideLength);
            AppendElementValue(xmlDoc, elemCaseOfBoxes, "innerWidth", UnitsManager.UnitType.UT_LENGTH, caseOfBoxes.InsideWidth);
            AppendElementValue(xmlDoc, elemCaseOfBoxes, "innerHeight", UnitsManager.UnitType.UT_LENGTH, caseOfBoxes.InsideHeight);
            AppendElementValue(xmlDoc, elemCaseOfBoxes, "innerVolume", UnitsManager.UnitType.UT_VOLUME, caseOfBoxes.InsideVolume * UnitsManager.FactorCubeLengthToVolume);
            AppendElementValue(xmlDoc, elemCaseOfBoxes, "outerLength", UnitsManager.UnitType.UT_LENGTH, caseOfBoxes.Length);
            AppendElementValue(xmlDoc, elemCaseOfBoxes, "outerWidth", UnitsManager.UnitType.UT_LENGTH, caseOfBoxes.Width);
            AppendElementValue(xmlDoc, elemCaseOfBoxes, "outerHeight", UnitsManager.UnitType.UT_LENGTH, caseOfBoxes.Height);
            AppendElementValue(xmlDoc, elemCaseOfBoxes, "outerVolume", UnitsManager.UnitType.UT_VOLUME, caseOfBoxes.Volume * UnitsManager.FactorCubeLengthToVolume);
            AppendElementValue(xmlDoc, elemCaseOfBoxes, "emptyWeight", UnitsManager.UnitType.UT_MASS, caseOfBoxes.WeightEmpty);
            AppendElementValue(xmlDoc, elemCaseOfBoxes, "weight", UnitsManager.UnitType.UT_MASS, caseOfBoxes.Weight);

            // type converter
            TypeConverter converter = TypeDescriptor.GetConverter(typeof(Bitmap));
            // view case of boxes iso1
            Graphics3DImage graphics1 = new Graphics3DImage(new Size(ImageSizeDetail, ImageSizeDetail));
            graphics1.CameraPosition = Graphics3D.Corner_0;
            CaseDefinitionViewer viewer = new CaseDefinitionViewer(caseOfBoxes.CaseDefinition, caseOfBoxes.InsideBoxProperties, caseOfBoxes.CaseOptimConstraintSet);
            viewer.CaseProperties = caseOfBoxes;
            viewer.Orientation = sol.FirstCaseOrientation;
            viewer.Draw(graphics1);
            graphics1.Flush();
            // view case of boxes iso2
            Graphics3DImage graphics2 = new Graphics3DImage(new Size(ImageSizeDetail, ImageSizeDetail));
            graphics2.CameraPosition = Graphics3D.Corner_0;
            Box box = new Box(0, caseOfBoxes);
            graphics2.AddBox(box);
            graphics2.AddDimensions(new DimensionCube(caseOfBoxes.Length, caseOfBoxes.Width, caseOfBoxes.Height));
            graphics2.Flush();
            // view_caseOfBoxes_iso1
            XmlElement elemImage1 = xmlDoc.CreateElement("view_caseOfBoxes_iso1", ns);
            elemImage1.InnerText = Convert.ToBase64String((byte[])converter.ConvertTo(graphics1.Bitmap, typeof(byte[])));
            XmlAttribute styleAttribute1 = xmlDoc.CreateAttribute("style");
            styleAttribute1.Value = string.Format("width:{0}pt;height:{1}pt", graphics1.Bitmap.Width / 3, graphics1.Bitmap.Height / 3);
            elemImage1.Attributes.Append(styleAttribute1);
            elemCaseOfBoxes.AppendChild(elemImage1);
            // save image
            SaveImageAs(graphics1.Bitmap, "view_caseOfBoxes_iso1.png");
            // view_caseOfBoxes_iso2
            XmlElement elemImage2 = xmlDoc.CreateElement("view_caseOfBoxes_iso2", ns);
            elemImage2.InnerText = Convert.ToBase64String((byte[])converter.ConvertTo(graphics2.Bitmap, typeof(byte[])));
            XmlAttribute styleAttribute2 = xmlDoc.CreateAttribute("style");
            styleAttribute2.Value = string.Format("width:{0}pt;height:{1}pt", graphics2.Bitmap.Width / 3, graphics2.Bitmap.Height / 3);
            elemImage2.Attributes.Append(styleAttribute2);
            elemCaseOfBoxes.AppendChild(elemImage2);
            // save image
            SaveImageAs(graphics2.Bitmap, "view_caseOfBoxes_iso2.png");
        }
示例#13
0
        private void AppendCaseElement(CasePalletAnalysis analysis, CasePalletSolution sol, XmlElement elemPalletAnalysis, XmlDocument xmlDoc)
        {
            string ns = xmlDoc.DocumentElement.NamespaceURI;
            // get BoxProperties
            BoxProperties boxProp = analysis.BProperties as BoxProperties;
            if (null == boxProp) return;
            // case
            XmlElement elemCase = xmlDoc.CreateElement("case", ns);
            elemPalletAnalysis.AppendChild(elemCase);
            // name
            XmlElement elemName = xmlDoc.CreateElement("name", ns);
            elemName.InnerText = boxProp.Name;
            elemCase.AppendChild(elemName);
            // description
            XmlElement elemDescription = xmlDoc.CreateElement("description", ns);
            elemDescription.InnerText = boxProp.Description;
            elemCase.AppendChild(elemDescription);

            AppendElementValue(xmlDoc, elemCase, "length", UnitsManager.UnitType.UT_LENGTH, boxProp.Length);
            AppendElementValue(xmlDoc, elemCase, "width", UnitsManager.UnitType.UT_LENGTH, boxProp.Width);
            AppendElementValue(xmlDoc, elemCase, "height", UnitsManager.UnitType.UT_LENGTH, boxProp.Height);
            AppendElementValue(xmlDoc, elemCase, "weight", UnitsManager.UnitType.UT_MASS, boxProp.Weight);
            AppendElementValue(xmlDoc, elemCase, "admissibleLoadOnTop", UnitsManager.UnitType.UT_MASS, 0.0);
            // --- build image
            Graphics3DImage graphics = new Graphics3DImage(new Size(ImageSizeDetail, ImageSizeDetail));
            graphics.CameraPosition = Graphics3D.Corner_0;
            graphics.Target = Vector3D.Zero;
            Box box = new Box(0, boxProp);
            graphics.AddBox(box);
            DimensionCube dc = new DimensionCube(box.Length, box.Width, box.Height);    dc.FontSize = 6.0f;
            graphics.AddDimensions(dc);
            graphics.Flush();
            // ---
            // view_case_iso
            XmlElement elemImage = xmlDoc.CreateElement("view_case_iso", ns);
            TypeConverter converter = TypeDescriptor.GetConverter(typeof(Bitmap));
            elemImage.InnerText = Convert.ToBase64String((byte[])converter.ConvertTo(graphics.Bitmap, typeof(byte[])));
            XmlAttribute styleAttribute = xmlDoc.CreateAttribute("style");
            styleAttribute.Value = string.Format("width:{0}pt;height:{1}pt", graphics.Bitmap.Width / 4, graphics.Bitmap.Height / 4);
            elemImage.Attributes.Append(styleAttribute);
            elemCase.AppendChild(elemImage);
            // save image
            SaveImageAs(graphics.Bitmap, "view_case_iso.png");
        }
示例#14
0
        private void AppendCylinderElement(CylinderProperties cylProperties, XmlElement elemAnalysis, XmlDocument xmlDoc)
        {
            string ns = xmlDoc.DocumentElement.NamespaceURI;
            // get CylinderProperties
            XmlElement elemCylinder = xmlDoc.CreateElement("cylinder", ns);
            elemAnalysis.AppendChild(elemCylinder);
            // name
            XmlElement elemName = xmlDoc.CreateElement("name", ns);
            elemName.InnerText = cylProperties.Name;
            elemCylinder.AppendChild(elemName);
            // description
            XmlElement elemDescription = xmlDoc.CreateElement("description", ns);
            elemDescription.InnerText = cylProperties.Description;
            elemCylinder.AppendChild(elemDescription);

            AppendElementValue(xmlDoc, elemCylinder, "radius", UnitsManager.UnitType.UT_LENGTH, cylProperties.RadiusOuter);
            AppendElementValue(xmlDoc, elemCylinder, "width", UnitsManager.UnitType.UT_LENGTH, cylProperties.Height);
            AppendElementValue(xmlDoc, elemCylinder, "height", UnitsManager.UnitType.UT_MASS, cylProperties.Weight);
            // --- build image
            Graphics3DImage graphics = new Graphics3DImage(new Size(ImageSizeDetail, ImageSizeDetail));
            graphics.CameraPosition = Graphics3D.Corner_0;
            graphics.Target = Vector3D.Zero;
            Cylinder cyl = new Cylinder(0, cylProperties);
            graphics.AddCylinder(cyl);
            DimensionCube dc = new DimensionCube(cyl.DiameterOuter, cyl.DiameterOuter, cyl.Height);   dc.FontSize = 6.0f;
            graphics.AddDimensions(dc);
            graphics.Flush();
            // ---
            // view_case_iso
            XmlElement elemImage = xmlDoc.CreateElement("view_cylinder_iso", ns);
            TypeConverter converter = TypeDescriptor.GetConverter(typeof(Bitmap));
            elemImage.InnerText = Convert.ToBase64String((byte[])converter.ConvertTo(graphics.Bitmap, typeof(byte[])));
            XmlAttribute styleAttribute = xmlDoc.CreateAttribute("style");
            styleAttribute.Value = string.Format("width:{0}pt;height:{1}pt", graphics.Bitmap.Width / 4, graphics.Bitmap.Height / 4);
            elemImage.Attributes.Append(styleAttribute);
            elemCylinder.AppendChild(elemImage);
            // save image
            SaveImageAs(graphics.Bitmap, "view_cylinder_iso.png");             
        }
示例#15
0
        private void AppendPalletCapElement(PalletCapProperties palletCapProp, XmlElement elemPalletAnalysis, XmlDocument xmlDoc)
        {
            // sanity check
            if (null == palletCapProp) return;
            // namespace
            string ns = xmlDoc.DocumentElement.NamespaceURI;
            // interlayer
            XmlElement elemPalletCap = xmlDoc.CreateElement("palletCap", ns);
            elemPalletAnalysis.AppendChild(elemPalletCap);
            // name
            XmlElement elemName = xmlDoc.CreateElement("name", ns);
            elemName.InnerText = palletCapProp.Name;
            elemPalletCap.AppendChild(elemName);
            // description
            XmlElement elemDescription = xmlDoc.CreateElement("description", ns);
            elemDescription.InnerText = palletCapProp.Description;
            elemPalletCap.AppendChild(elemDescription);

            AppendElementValue(xmlDoc, elemPalletCap, "length", UnitsManager.UnitType.UT_LENGTH, palletCapProp.Length);
            AppendElementValue(xmlDoc, elemPalletCap, "width", UnitsManager.UnitType.UT_LENGTH, palletCapProp.Width);
            AppendElementValue(xmlDoc, elemPalletCap, "height", UnitsManager.UnitType.UT_LENGTH, palletCapProp.Height);
            AppendElementValue(xmlDoc, elemPalletCap, "innerLength", UnitsManager.UnitType.UT_LENGTH, palletCapProp.InsideLength);
            AppendElementValue(xmlDoc, elemPalletCap, "innerWidth", UnitsManager.UnitType.UT_LENGTH, palletCapProp.InsideWidth);
            AppendElementValue(xmlDoc, elemPalletCap, "innerHeight", UnitsManager.UnitType.UT_LENGTH, palletCapProp.InsideHeight);
            AppendElementValue(xmlDoc, elemPalletCap, "weight", UnitsManager.UnitType.UT_MASS, palletCapProp.Weight);
            // ---
            // view_palletCap_iso
            // build image
            Graphics3DImage graphics = new Graphics3DImage(new Size(ImageSizeDetail, ImageSizeDetail));
            graphics.CameraPosition = Graphics3D.Corner_0;
            PalletCap palletCap = new PalletCap(0, palletCapProp, Vector3D.Zero);
            palletCap.Draw(graphics);
            graphics.AddDimensions(new DimensionCube(palletCapProp.Length, palletCapProp.Width, palletCapProp.Height));
            graphics.Flush();
            // save image ?
            SaveImageAs(graphics.Bitmap, "view_palletCap_iso.png");
            // ---
            // view_palletCap_iso
            XmlElement elemImage = xmlDoc.CreateElement("view_palletCap_iso", ns);
            TypeConverter converter = TypeDescriptor.GetConverter(typeof(Bitmap));
            elemImage.InnerText = Convert.ToBase64String((byte[])converter.ConvertTo(graphics.Bitmap, typeof(byte[])));
            XmlAttribute styleAttribute = xmlDoc.CreateAttribute("style");
            styleAttribute.Value = string.Format("width:{0}pt;height:{1}pt", graphics.Bitmap.Width / 4, graphics.Bitmap.Height / 4);
            elemImage.Attributes.Append(styleAttribute);
            elemPalletCap.AppendChild(elemImage);
        }
示例#16
0
        private void AppendInterlayerElement(InterlayerProperties interlayerProp, XmlElement elemPalletAnalysis, XmlDocument xmlDoc)
        {
            // sanity check
            if (null == interlayerProp) return;
            // namespace
            string ns = xmlDoc.DocumentElement.NamespaceURI;
            // interlayer
            XmlElement elemInterlayer = xmlDoc.CreateElement("interlayer", ns);
            elemPalletAnalysis.AppendChild(elemInterlayer);
            // name
            XmlElement elemName = xmlDoc.CreateElement("name", ns);
            elemName.InnerText = interlayerProp.Name;
            elemInterlayer.AppendChild(elemName);
            // description
            XmlElement elemDescription = xmlDoc.CreateElement("description", ns);
            elemDescription.InnerText = interlayerProp.Description;
            elemInterlayer.AppendChild(elemDescription);

            AppendElementValue(xmlDoc, elemInterlayer, "length", UnitsManager.UnitType.UT_LENGTH, interlayerProp.Length);
            AppendElementValue(xmlDoc, elemInterlayer, "width", UnitsManager.UnitType.UT_LENGTH, interlayerProp.Width);
            AppendElementValue(xmlDoc, elemInterlayer, "thickness", UnitsManager.UnitType.UT_LENGTH, interlayerProp.Thickness);
            AppendElementValue(xmlDoc, elemInterlayer, "weight", UnitsManager.UnitType.UT_MASS, interlayerProp.Weight);

            // --- build image
            Graphics3DImage graphics = new Graphics3DImage(new Size(ImageSizeDetail, ImageSizeDetail));
            graphics.CameraPosition = Graphics3D.Corner_0;
            Box box = new Box(0, interlayerProp);
            graphics.AddBox(box);
            graphics.Flush();
            // ---
            // view_interlayer_iso
            XmlElement elemImage = xmlDoc.CreateElement("view_interlayer_iso", ns);
            TypeConverter converter = TypeDescriptor.GetConverter(typeof(Bitmap));
            elemImage.InnerText = Convert.ToBase64String((byte[])converter.ConvertTo(graphics.Bitmap, typeof(byte[])));
            XmlAttribute styleAttribute = xmlDoc.CreateAttribute("style");
            styleAttribute.Value = string.Format("width:{0}pt;height:{1}pt", graphics.Bitmap.Width / 4, graphics.Bitmap.Height / 4);
            elemImage.Attributes.Append(styleAttribute);
            elemInterlayer.AppendChild(elemImage);
            // save image ?
            SaveImageAs(graphics.Bitmap, "view_interlayer_iso.png");
        }
示例#17
0
        private void AppendSolutionElement(ReportData inputData, XmlElement elemPalletAnalysis, XmlDocument xmlDoc)
        {
            string ns = xmlDoc.DocumentElement.NamespaceURI;

            SelCasePalletSolution selSolution = inputData.SelSolution;
            CasePalletSolution sol = inputData.CasePalletSolution;

            // solution
            XmlElement elemSolution = xmlDoc.CreateElement("palletSolution", ns);
            elemPalletAnalysis.AppendChild(elemSolution);
            // title
            XmlElement elemTitle = xmlDoc.CreateElement("title", ns);
            elemTitle.InnerText = sol.Title;
            elemSolution.AppendChild(elemTitle);
            // homogeneousLayer
            XmlElement elemHomogeneousLayer = xmlDoc.CreateElement("homogeneousLayer", ns);
            elemHomogeneousLayer.InnerText = sol.HasHomogeneousLayers.ToString();
            elemSolution.AppendChild(elemHomogeneousLayer);
            // efficiency
            XmlElement elemEfficiency = xmlDoc.CreateElement("efficiency", ns);
            elemEfficiency.InnerText = string.Format("{0:F}", sol.VolumeEfficiencyCases);
            elemSolution.AppendChild(elemEfficiency);

            AppendElementValue(xmlDoc, elemSolution, "palletWeight", UnitsManager.UnitType.UT_MASS, inputData.ActualPalletWeight);
            AppendElementValue(xmlDoc, elemSolution, "palletLength", UnitsManager.UnitType.UT_LENGTH, sol.PalletLength);
            AppendElementValue(xmlDoc, elemSolution, "palletWidth", UnitsManager.UnitType.UT_LENGTH, sol.PalletWidth);
            AppendElementValue(xmlDoc, elemSolution, "palletHeight", UnitsManager.UnitType.UT_LENGTH, sol.PalletHeight);

            // caseCount
            XmlElement elemCaseCount = xmlDoc.CreateElement("caseCount", ns);
            elemCaseCount.InnerText = string.Format("{0}", sol.CaseCount);
            elemSolution.AppendChild(elemCaseCount);
            // if case of boxes, add box count + box efficiency
            if (sol.Analysis.BProperties is CaseOfBoxesProperties)
            {
                CaseOfBoxesProperties caseOfBoxes = sol.Analysis.BProperties as CaseOfBoxesProperties;
                XmlElement elemBoxCount = xmlDoc.CreateElement("boxCount", ns);
                elemBoxCount.InnerText = string.Format("{0:F}", caseOfBoxes.NumberOfBoxes);
                elemSolution.AppendChild(elemBoxCount);
                XmlElement elemBoxEfficiency = xmlDoc.CreateElement("boxEfficiency", ns);
                elemBoxEfficiency.InnerText = string.Format("{0:F}", sol.VolumeEfficiencyCases);
            }
            // layerCount
            XmlElement elemLayerCount = xmlDoc.CreateElement("layerCount", ns);
            elemLayerCount.InnerText = string.Format("{0}", sol.CaseLayersCount);
            elemSolution.AppendChild(elemLayerCount);
            // layer1_caseCount / layer2_caseCount
            XmlElement elemLayer1_caseCount = xmlDoc.CreateElement("layer1_caseCount", ns);
            elemLayer1_caseCount.InnerText = string.Format("{0}", sol.CaseLayerFirst.BoxCount);
            elemSolution.AppendChild(elemLayer1_caseCount);
            if (sol.Count > 1 && (sol.CaseLayerFirst.BoxCount != sol.CaseLayerSecond.BoxCount))
            {
                XmlElement elemLayer2_caseCount = xmlDoc.CreateElement("layer2_caseCount", ns);
                elemLayer2_caseCount.InnerText = string.Format("{0}", sol.CaseLayerSecond.BoxCount);
                elemSolution.AppendChild(elemLayer2_caseCount);
            }
            // interlayer count
            if (sol.Analysis.ConstraintSet.HasInterlayer)
            {
                XmlElement elemInterlayerCount = xmlDoc.CreateElement("interlayerCount", ns);
                elemInterlayerCount.InnerText = string.Format("{0}", sol.InterlayerCount);
                elemSolution.AppendChild(elemInterlayerCount);
            }
            // --- layer images
            for (int i = 0; i < Math.Min(sol.Count, (sol.HasHomogeneousLayers ? 1 : 2)); ++i)
            {
                XmlElement elemLayer = xmlDoc.CreateElement("layer", ns);
                // layerId
                XmlElement xmlLayerId = xmlDoc.CreateElement("layerId", ns);
                xmlLayerId.InnerText = string.Format("{0}", i + 1);
                elemLayer.AppendChild(xmlLayerId);
                // --- build layer image
                // instantiate graphics
                Graphics3DImage graphics = new Graphics3DImage(new Size(ImageSizeDetail, ImageSizeDetail));
                // set camera position 
                graphics.CameraPosition = Graphics3D.Top;
                // instantiate solution viewer
                CasePalletSolutionViewer sv = new CasePalletSolutionViewer(sol);
                sv.DrawLayers(graphics, true, i /* layer index*/);
                // ---
                // layerImage
                XmlElement elemLayerImage = xmlDoc.CreateElement("layerImage", ns);
                TypeConverter converter = TypeDescriptor.GetConverter(typeof(Bitmap));
                elemLayerImage.InnerText = Convert.ToBase64String((byte[])converter.ConvertTo(graphics.Bitmap, typeof(byte[])));
                XmlAttribute styleAttribute = xmlDoc.CreateAttribute("style");
                styleAttribute.Value = string.Format("width:{0}pt;height:{1}pt", graphics.Bitmap.Width / 2, graphics.Bitmap.Height / 2);
                elemLayerImage.Attributes.Append(styleAttribute);
                elemLayer.AppendChild(elemLayerImage);
                // layerCaseCount
                XmlElement elemLayerBoxCount = xmlDoc.CreateElement("layerCaseCount", ns);
                elemLayerBoxCount.InnerText = sol[i].BoxCount.ToString();
                elemLayer.AppendChild(elemLayerBoxCount);

                elemSolution.AppendChild(elemLayer);
                // save image
                SaveImageAs(graphics.Bitmap, string.Format("layerImage{0}.png", i + 1));
            }
            // --- pallet images
            for (int i = 0; i < 5; ++i)
            {
                // initialize drawing values
                string viewName = string.Empty;
                Vector3D cameraPos = Vector3D.Zero;
                int imageWidth = ImageSizeDetail;
                bool showDimensions = false;
                switch (i)
                {
                    case 0:
                        viewName = "view_palletsolution_front"; cameraPos = Graphics3D.Front; imageWidth = ImageSizeDetail;
                        break;
                    case 1:
                        viewName = "view_palletsolution_left"; cameraPos = Graphics3D.Left; imageWidth = ImageSizeDetail;
                        break;
                    case 2:
                        viewName = "view_palletsolution_right"; cameraPos = Graphics3D.Right; imageWidth = ImageSizeDetail;
                        break;
                    case 3:
                        viewName = "view_palletsolution_back"; cameraPos = Graphics3D.Back; imageWidth = ImageSizeDetail;
                        break;
                    case 4:
                        viewName = "view_palletsolution_iso"; cameraPos = Graphics3D.Corner_180; imageWidth = ImageSizeWide; showDimensions = true;
                        break;
                    default:
                        break;
                }
                // instantiate graphics
                Graphics3DImage graphics = new Graphics3DImage(new Size(imageWidth, imageWidth));
                // set camera position 
                graphics.CameraPosition = cameraPos;
                // instantiate solution viewer
                CasePalletSolutionViewer sv = new CasePalletSolutionViewer(sol);
                sv.ShowDimensions = showDimensions;
                sv.Draw(graphics);
                graphics.Flush();
                SaveImageAs(graphics.Bitmap, viewName + ".png");
                // ---
                XmlElement elemImage = xmlDoc.CreateElement(viewName, ns);
                TypeConverter converter = TypeDescriptor.GetConverter(typeof(Bitmap));
                elemImage.InnerText = Convert.ToBase64String((byte[])converter.ConvertTo(graphics.Bitmap, typeof(byte[])));
                XmlAttribute styleAttribute = xmlDoc.CreateAttribute("style");
                styleAttribute.Value = string.Format("width:{0}pt;height:{1}pt", graphics.Bitmap.Width / 3, graphics.Bitmap.Height / 3);
                elemImage.Attributes.Append(styleAttribute);
                elemSolution.AppendChild(elemImage);
            }
        }
示例#18
0
        private void AppendPackPalletSolutionElement(ReportData inputData, XmlElement elemPackPalletAnalysis, XmlDocument xmlDoc)
        {
            if (!inputData.IsPackPalletAnalysis) return;

            string ns = xmlDoc.DocumentElement.NamespaceURI;

            SelPackPalletSolution selSolution = inputData.SelPackPalletSolution;
            PackPalletSolution sol = inputData.PackPalletSolution;

            // solution
            XmlElement elemSolution = xmlDoc.CreateElement("packPalletSolution", ns);
            elemPackPalletAnalysis.AppendChild(elemSolution);
            // title
            XmlElement elemTitle = xmlDoc.CreateElement("title", ns);
            elemTitle.InnerText = sol.Title;
            elemSolution.AppendChild(elemTitle);
            // efficiency
            XmlElement elemEfficiency = xmlDoc.CreateElement("efficiency", ns);
            elemEfficiency.InnerText = string.Format( "{0:F}", sol.VolumeEfficiency );
            elemSolution.AppendChild(elemEfficiency);
            // length / width / height
            AppendElementValue(xmlDoc, elemSolution, "length", UnitsManager.UnitType.UT_LENGTH, sol.PalletLength);
            AppendElementValue(xmlDoc, elemSolution, "width", UnitsManager.UnitType.UT_LENGTH, sol.PalletWidth);
            AppendElementValue(xmlDoc, elemSolution, "height", UnitsManager.UnitType.UT_LENGTH, sol.PalletHeight);
            // counts
            AppendElementValue(xmlDoc, elemSolution, "palletPackCount", sol.PackCount);
            AppendElementValue(xmlDoc, elemSolution, "palletCSUCount", sol.CSUCount);
            AppendElementValue(xmlDoc, elemSolution, "palletInterlayerCount", sol.InterlayerCount);
            // 
            AppendElementValue(xmlDoc, elemSolution, "palletWeight", UnitsManager.UnitType.UT_MASS, sol.PalletWeight);
            AppendElementValue(xmlDoc, elemSolution, "palletLoadWeight", UnitsManager.UnitType.UT_MASS, sol.PalletLoadWeight);
            AppendElementValue(xmlDoc, elemSolution, "palletNetWeight", UnitsManager.UnitType.UT_MASS, sol.PalletNetWeight);
            AppendElementValue(xmlDoc, elemSolution, "overhangX", UnitsManager.UnitType.UT_LENGTH, sol.OverhangX);
            AppendElementValue(xmlDoc, elemSolution, "overhangY", UnitsManager.UnitType.UT_LENGTH, sol.OverhangY);
            // --- pallet images
            for (int i = 0; i < 5; ++i)
            {
                // initialize drawing values
                string viewName = string.Empty;
                Vector3D cameraPos = Vector3D.Zero;
                int imageWidth = ImageSizeDetail;
                bool showDimensions = false;
                switch (i)
                {
                    case 0: viewName = "view_palletsolution_front"; cameraPos = Graphics3D.Front; imageWidth = ImageSizeDetail; break;
                    case 1: viewName = "view_palletsolution_left"; cameraPos = Graphics3D.Left; imageWidth = ImageSizeDetail;   break;
                    case 2: viewName = "view_palletsolution_right"; cameraPos = Graphics3D.Right; imageWidth = ImageSizeDetail; break;
                    case 3: viewName = "view_palletsolution_back"; cameraPos = Graphics3D.Back; imageWidth = ImageSizeDetail;   break;
                    case 4: viewName = "view_palletsolution_iso"; cameraPos = Graphics3D.Corner_180; imageWidth = ImageSizeWide; showDimensions = true; break;
                    default:  break;
                }
                // instantiate graphics
                Graphics3DImage graphics = new Graphics3DImage(new Size(imageWidth, imageWidth));
                // set camera position 
                graphics.CameraPosition = cameraPos;
                // instantiate solution viewer
                PackPalletSolutionViewer sv = new PackPalletSolutionViewer(sol);
                sv.ShowDimensions = showDimensions;
                sv.Draw(graphics);
                graphics.Flush();
                SaveImageAs(graphics.Bitmap, viewName + ".png");
                // ---
                XmlElement elemImage = xmlDoc.CreateElement(viewName, ns);
                TypeConverter converter = TypeDescriptor.GetConverter(typeof(Bitmap));
                elemImage.InnerText = Convert.ToBase64String((byte[])converter.ConvertTo(graphics.Bitmap, typeof(byte[])));
                XmlAttribute styleAttribute = xmlDoc.CreateAttribute("style");
                styleAttribute.Value = string.Format("width:{0}pt;height:{1}pt", graphics.Bitmap.Width / 3, graphics.Bitmap.Height / 3);
                elemImage.Attributes.Append(styleAttribute);
                elemSolution.AppendChild(elemImage);
            }

            // --- layers
            for (int i=0; i<sol.NoLayerTypes; ++i)
            {
                XmlElement elemLayerPack = xmlDoc.CreateElement("layerPack", ns);
                elemSolution.AppendChild(elemLayerPack);

                LayerType layerType = sol.GetLayerType(i);
                AppendElementValue(xmlDoc, elemLayerPack, "layerPackCount", layerType.PackCount);
                AppendElementValue(xmlDoc, elemLayerPack, "layerCSUCount", layerType.CSUCount);
                AppendElementValue(xmlDoc, elemLayerPack, "layerWeight", UnitsManager.UnitType.UT_MASS, layerType.LayerWeight);
                AppendElementValue(xmlDoc, elemLayerPack, "layerNetWeight", UnitsManager.UnitType.UT_MASS, layerType.LayerNetWeight);
                AppendElementValue(xmlDoc, elemLayerPack, "layerLength", UnitsManager.UnitType.UT_LENGTH, layerType.Length);
                AppendElementValue(xmlDoc, elemLayerPack, "layerWidth", UnitsManager.UnitType.UT_LENGTH, layerType.Width);
                AppendElementValue(xmlDoc, elemLayerPack, "layerHeight", UnitsManager.UnitType.UT_LENGTH, layerType.Height);
                AppendElementValue(xmlDoc, elemLayerPack, "maximumSpace", UnitsManager.UnitType.UT_LENGTH, layerType.MaximumSpace);
                AppendElementValue(xmlDoc, elemLayerPack, "layerIndexes", layerType.LayerIndexes);

                // instantiate graphics
                Graphics3DImage graphics = new Graphics3DImage(new Size(ImageSizeDetail, ImageSizeDetail));
                // set camera position 
                graphics.CameraPosition = Graphics3D.Corner_180;
                // instantiate solution viewer
                PackPalletSolutionViewer sv = new PackPalletSolutionViewer(sol);
                sv.ShowDimensions = true;
                sv.DrawLayer(graphics, i);
                graphics.Flush();
                string viewName = string.Format("view_layer_iso{0}", i);
                SaveImageAs(graphics.Bitmap, viewName + ".png");
                // ---
                XmlElement elemImage = xmlDoc.CreateElement("imagePackLayer", ns);
                elemImage.InnerText = "images\\" + viewName + ".png";
                elemLayerPack.AppendChild(elemImage);
            }
        }
示例#19
0
 private void FinalizeImageFromViewParameters(viewParameters vParam, Graphics3DImage graphics)
 {
     graphics.Flush();
     // attempt to create directory
     string dirPath = Path.GetDirectoryName(vParam.path);
     try { Directory.CreateDirectory(dirPath); }
     catch (Exception ex) { _log.Error(ex.Message); }
     // check that directory exists
     if (!Directory.Exists(dirPath))
         throw new Exception(string.Format("Directory {0} does not exist!\n Can not generate output file!", Path.GetDirectoryName(vParam.path)));
     // save image
     graphics.SaveAs(vParam.path);
     _log.Info(string.Format("Successfully saved file {0}", vParam.path));
 }
示例#20
0
        private void AppendTruckSolutionElement(ReportData inputData, XmlElement elemTruckAnalysis, XmlDocument xmlDoc)
        {
            string ns = xmlDoc.DocumentElement.NamespaceURI;

            CasePalletSolution palletSolution = inputData.CasePalletSolution;
            TruckAnalysis truckAnalysis = inputData.SelSolution.TruckAnalyses[0];

            // retrieve selected truckSolution
            TruckSolution truckSolution = truckAnalysis.SelectedSolution;
            if (null == truckSolution) return;
            // create "truckSolution" element
            XmlElement elemTruckSolution = xmlDoc.CreateElement("truckSolution", ns);
            elemTruckAnalysis.AppendChild(elemTruckSolution);
            if (!string.IsNullOrEmpty(truckSolution.Title))
            {
                // title
                XmlElement elemTitle = xmlDoc.CreateElement("title", ns);
                elemTitle.InnerText = truckSolution.Title;
                elemTruckSolution.AppendChild(elemTitle);
            }
            // palletCount
            XmlElement elemPalletCount = xmlDoc.CreateElement("palletCount", ns);
            elemPalletCount.InnerText = string.Format("{0}", truckSolution.PalletCount);
            elemTruckSolution.AppendChild(elemPalletCount);
            // boxCount
            XmlElement elemBoxCount = xmlDoc.CreateElement("caseCount", ns);
            elemBoxCount.InnerText = string.Format("{0}", truckSolution.BoxCount);
            elemTruckSolution.AppendChild(elemBoxCount);

            double loadWeight = truckSolution.PalletCount * inputData.ActualPalletWeight;
            AppendElementValue(xmlDoc, elemTruckSolution, "loadWeight", UnitsManager.UnitType.UT_MASS, loadWeight);

            // loadEfficiency
            XmlElement elemLoadEfficiency = xmlDoc.CreateElement("loadEfficiency", ns);
            elemLoadEfficiency.InnerText = string.Format("{0:F}", 100.0 * loadWeight / truckAnalysis.TruckProperties.AdmissibleLoadWeight);
            elemTruckSolution.AppendChild(elemLoadEfficiency);
            // volumeEfficiency
            XmlElement elemVolumeEfficiency = xmlDoc.CreateElement("volumeEfficiency", ns);
            elemVolumeEfficiency.InnerText = string.Format("{0:F}", truckSolution.Efficiency);
            elemTruckSolution.AppendChild(elemVolumeEfficiency);

            // --- truck images
            for (int i = 0; i < 2; ++i)
            {
                // initialize drawing values
                string viewName = string.Empty;
                Vector3D cameraPos = Vector3D.Zero;
                int imageWidth = ImageSizeWide;
                switch (i)
                {
                    case 0: viewName = "view_trucksolution_top"; cameraPos = Graphics3D.Top; imageWidth = ImageSizeWide; break;
                    case 1: viewName = "view_trucksolution_iso"; cameraPos = Graphics3D.Corner_0; imageWidth = ImageSizeWide; break;
                    default: break;
                }
                // instantiate graphics
                Graphics3DImage graphics = new Graphics3DImage(new Size(imageWidth, imageWidth));
                // set camera position 
                graphics.CameraPosition = cameraPos;
                // dimensions
                if (1 == i)
                {
                    TruckProperties truckProp = truckSolution.ParentTruckAnalysis.TruckProperties;
                    graphics.AddDimensions(new DimensionCube(truckSolution.LoadBoundingBox, Color.Red, false));
                    graphics.AddDimensions(new DimensionCube(Vector3D.Zero, truckProp.Length, truckProp.Width, truckProp.Height, Color.Black, true));
                }
                // instantiate solution viewer
                TruckSolutionViewer sv = new TruckSolutionViewer(truckSolution);
                sv.Draw(graphics);
                graphics.Flush();
                // ---
                XmlElement elemImage = xmlDoc.CreateElement(viewName, ns);
                TypeConverter converter = TypeDescriptor.GetConverter(typeof(Bitmap));
                elemImage.InnerText = Convert.ToBase64String((byte[])converter.ConvertTo(graphics.Bitmap, typeof(byte[])));
                XmlAttribute styleAttribute = xmlDoc.CreateAttribute("style");
                styleAttribute.Value = string.Format("width:{0}pt;height:{1}pt", graphics.Bitmap.Width / 3, graphics.Bitmap.Height / 3);
                elemImage.Attributes.Append(styleAttribute);
                elemTruckSolution.AppendChild(elemImage);
                // Save image ?
                SaveImageAs(graphics.Bitmap, viewName + ".png");
            }
        }
示例#21
0
        private void AppendTruckElement(TruckAnalysis truckAnalysis, XmlElement elemTruckAnalysis, XmlDocument xmlDoc)
        {
            string ns = xmlDoc.DocumentElement.NamespaceURI;
            // get PalletProperties
            TruckProperties truckProp = truckAnalysis.TruckProperties;
            if (null == truckProp) return;
            // create "truck" element
            XmlElement elemTruck = xmlDoc.CreateElement("truck", ns);
            elemTruckAnalysis.AppendChild(elemTruck);
            // name
            XmlElement elemName = xmlDoc.CreateElement("name", ns);
            elemName.InnerText = truckProp.Name;
            elemTruck.AppendChild(elemName);
            // description
            XmlElement elemDescription = xmlDoc.CreateElement("description", ns);
            elemDescription.InnerText = truckProp.Description;
            elemTruck.AppendChild(elemDescription);

            AppendElementValue(xmlDoc, elemTruck, "length", UnitsManager.UnitType.UT_LENGTH, truckProp.Length);
            AppendElementValue(xmlDoc, elemTruck, "width", UnitsManager.UnitType.UT_LENGTH, truckProp.Width);
            AppendElementValue(xmlDoc, elemTruck, "height", UnitsManager.UnitType.UT_LENGTH, truckProp.Height);
            AppendElementValue(xmlDoc, elemTruck, "admissibleLoad", UnitsManager.UnitType.UT_MASS, truckProp.AdmissibleLoadWeight);

            // --- build image
            Graphics3DImage graphics = new Graphics3DImage(new Size(ImageSizeDetail, ImageSizeDetail));
            graphics.CameraPosition = Graphics3D.Corner_0;
            Truck truck = new Truck(truckProp);
            truck.DrawBegin(graphics);
            truck.DrawEnd(graphics);
            DimensionCube dc = new DimensionCube(truckProp.Length, truckProp.Width, truckProp.Height);      dc.FontSize = 6.0f;
            graphics.AddDimensions(dc);
            graphics.Flush();
            // ---
            // view_truck_iso
            XmlElement elemImage = xmlDoc.CreateElement("view_truck_iso", ns);
            TypeConverter converter = TypeDescriptor.GetConverter(typeof(Bitmap));
            elemImage.InnerText = Convert.ToBase64String((byte[])converter.ConvertTo(graphics.Bitmap, typeof(byte[])));
            XmlAttribute styleAttribute = xmlDoc.CreateAttribute("style");
            styleAttribute.Value = string.Format("width:{0}pt;height:{1}pt", graphics.Bitmap.Width / 4, graphics.Bitmap.Height / 4);
            elemImage.Attributes.Append(styleAttribute);
            elemTruck.AppendChild(elemImage);
            // Save image ?
            SaveImageAs(graphics.Bitmap, "view_truck_iso.png");
        }
示例#22
0
        private void AppendCaseElement(SelBoxCasePalletSolution caseSolution, XmlElement elemCaseAnalysis, XmlDocument xmlDoc)
        {
            string ns = xmlDoc.DocumentElement.NamespaceURI;
            BoxProperties boxProp = caseSolution.Solution.AttachedPalletSolution.Analysis.BProperties as BoxProperties;
            // case element
            XmlElement elemCase = CreateElement("caseWithInnerDims", null, elemCaseAnalysis, xmlDoc, ns);
            // name
            CreateElement("name", boxProp.Name, elemCase, xmlDoc, ns);
            // description
            CreateElement("description", boxProp.Description, elemCase, xmlDoc, ns);

            AppendElementValue(xmlDoc, elemCase, "length", UnitsManager.UnitType.UT_LENGTH, boxProp.Length);
            AppendElementValue(xmlDoc, elemCase, "width", UnitsManager.UnitType.UT_LENGTH, boxProp.Width);
            AppendElementValue(xmlDoc, elemCase, "height", UnitsManager.UnitType.UT_LENGTH, boxProp.Height);
            AppendElementValue(xmlDoc, elemCase, "innerLength", UnitsManager.UnitType.UT_LENGTH, boxProp.InsideLength);
            AppendElementValue(xmlDoc, elemCase, "innerWidth", UnitsManager.UnitType.UT_LENGTH, boxProp.InsideWidth);
            AppendElementValue(xmlDoc, elemCase, "innerHeight", UnitsManager.UnitType.UT_LENGTH, boxProp.InsideHeight);
            AppendElementValue(xmlDoc, elemCase, "weight", UnitsManager.UnitType.UT_MASS, boxProp.Height);
 
            // --- build image
            Graphics3DImage graphics = new Graphics3DImage(new Size(ImageSizeDetail, ImageSizeDetail));
            graphics.CameraPosition = Graphics3D.Corner_0;
            graphics.Target = Vector3D.Zero;
            Box box = new Box(0, boxProp);
            graphics.AddBox(box);
            graphics.AddDimensions(new DimensionCube(box.Length, box.Width, box.Height));
            graphics.Flush();
            // ---
            // view_case_iso
            XmlElement elemImage = xmlDoc.CreateElement("view_case_iso", ns);
            TypeConverter converter = TypeDescriptor.GetConverter(typeof(Bitmap));
            elemImage.InnerText = Convert.ToBase64String((byte[])converter.ConvertTo(graphics.Bitmap, typeof(byte[])));
            XmlAttribute styleAttribute = xmlDoc.CreateAttribute("style");
            styleAttribute.Value = string.Format("width:{0}pt;height:{1}pt", graphics.Bitmap.Width / 4, graphics.Bitmap.Height / 4);
            elemImage.Attributes.Append(styleAttribute);
            elemCase.AppendChild(elemImage);
            // save image
            SaveImageAs(graphics.Bitmap, "view_case_iso.png");
        }
示例#23
0
 private void AppendBoxCaseSolutionElement(BoxCaseSolution solution, XmlElement elemBoxCaseAnalysis, XmlDocument xmlDoc)
 {
     BoxCaseAnalysis analysis = solution.Analysis;
     string ns = xmlDoc.DocumentElement.NamespaceURI;
     // solution
     XmlElement elemSolution = xmlDoc.CreateElement("boxCaseSolution", ns);
     elemBoxCaseAnalysis.AppendChild(elemSolution);
     // title
     XmlElement elemTitle = xmlDoc.CreateElement("title", ns);
     elemTitle.InnerText = solution.Title;
     elemSolution.AppendChild(elemTitle);
     // boxPerLayerCount
     XmlElement elemBoxPerLayerCount = xmlDoc.CreateElement("boxPerLayerCount", ns);
     elemBoxPerLayerCount.InnerText = solution.BoxPerLayerCount.ToString();
     elemSolution.AppendChild(elemBoxPerLayerCount);
     // boxPerCaseCount
     XmlElement elemBoxPerCaseCount = xmlDoc.CreateElement("boxPerCaseCount", ns);
     elemBoxPerCaseCount.InnerText = solution.BoxPerCaseCount.ToString();
     elemSolution.AppendChild(elemBoxPerCaseCount);
     // BoxLayersCount
     XmlElement elemBoxLayersCount = xmlDoc.CreateElement("boxLayersCount", ns);
     elemBoxLayersCount.InnerText = solution.BoxLayersCount.ToString();
     elemSolution.AppendChild(elemBoxLayersCount);
     // criterions
     // load weight
     AppendElementValue(xmlDoc, elemSolution, "LoadWeight", UnitsManager.UnitType.UT_MASS, solution.BoxPerCaseCount * analysis.BProperties.Weight);
     // case weight
     AppendElementValue(xmlDoc, elemSolution, "CaseWeight", UnitsManager.UnitType.UT_MASS, solution.CaseWeight);
     // EfficiencyWeight
     XmlElement elemEfficiencyWeight = xmlDoc.CreateElement("EfficiencyWeight", ns);
     if (solution.CaseWeight > 0)
         elemEfficiencyWeight.InnerText = string.Format("{0:F}", solution.EfficiencyWeight);
     else
         elemEfficiencyWeight.InnerText = string.Empty;
     elemSolution.AppendChild(elemEfficiencyWeight);
     // EfficiencyVolume
     XmlElement elemEfficiencyVolume = xmlDoc.CreateElement("EfficiencyVolume", ns);
     elemEfficiencyVolume.InnerText = string.Format("{0:F}", solution.EfficiencyVolume);
     elemSolution.AppendChild(elemEfficiencyVolume);
     // LimitReached
     string limitReached = string.Empty;
     switch (solution.LimitReached)
     {
         case BoxCaseSolution.Limit.LIMIT_MAXHEIGHTREACHED: limitReached="Maximum height"; break;
         case BoxCaseSolution.Limit.LIMIT_MAXNUMBERREACHED: limitReached="Maximum number"; break;
         case BoxCaseSolution.Limit.LIMIT_MAXWEIGHTREACHED: limitReached="Maximum weight"; break;
         default: break;
     }
     XmlElement elemLimitReached = xmlDoc.CreateElement("LimitReached", ns);
     elemLimitReached.InnerText = limitReached; 
     elemSolution.AppendChild(elemLimitReached);
     // --- case images
     for (int i = 0; i < 5; ++i)
     {
         // initialize drawing values
         string viewName = string.Empty;
         Vector3D cameraPos = Vector3D.Zero;
         int imageWidth = ImageSizeDetail;
         bool showDimensions = false;
         switch (i)
         {
             case 0: viewName = "view_caseSolution_front"; cameraPos = Graphics3D.Front; imageWidth = ImageSizeDetail; break;
             case 1: viewName = "view_caseSolution_left"; cameraPos = Graphics3D.Left; imageWidth = ImageSizeDetail; break;
             case 2: viewName = "view_caseSolution_right"; cameraPos = Graphics3D.Right; imageWidth = ImageSizeDetail; break;
             case 3: viewName = "view_caseSolution_back"; cameraPos = Graphics3D.Back; imageWidth = ImageSizeDetail; break;
             case 4:  viewName = "view_caseSolution_iso"; cameraPos = Graphics3D.Corner_0; imageWidth = ImageSizeWide; showDimensions = true; break;
             default: break;
         }
         // instantiate graphics
         Graphics3DImage graphics = new Graphics3DImage(new Size(imageWidth, imageWidth));
         // set camera position 
         graphics.CameraPosition = cameraPos;
         // instantiate solution viewer
         BoxCaseSolutionViewer sv = new BoxCaseSolutionViewer(solution);
         sv.ShowDimensions = showDimensions;
         sv.Draw(graphics);
         graphics.Flush();
         // ---
         XmlElement elemImage = xmlDoc.CreateElement(viewName, ns);
         TypeConverter converter = TypeDescriptor.GetConverter(typeof(Bitmap));
         elemImage.InnerText = Convert.ToBase64String((byte[])converter.ConvertTo(graphics.Bitmap, typeof(byte[])));
         XmlAttribute styleAttribute = xmlDoc.CreateAttribute("style");
         styleAttribute.Value = string.Format("width:{0}pt;height:{1}pt", graphics.Bitmap.Width / 3, graphics.Bitmap.Height / 3);
         elemImage.Attributes.Append(styleAttribute);
         elemSolution.AppendChild(elemImage);
         // Save image ?
         SaveImageAs(graphics.Bitmap, viewName + ".png");
     }
 }
        private void Draw()
        {
            try
            {
                // get current descriptor
                PalletSolutionDesc desc = CurrentSolutionDesc;
                // sanity check
                if (null == desc
                    || pictureBoxCase.Size.Width < 1 || pictureBoxCase.Size.Height < 1
                    || pictureBoxSolution.Size.Width < 1 || pictureBoxSolution.Size.Height < 1)
                    return;

                // load document
                Document document = new Document(desc.FullFilePath, null);
                if (document.Analyses.Count == 0) return;
                // get analysis and solution
                CasePalletAnalysis analysis = document.Analyses[0];
                {
                    Graphics3DImage graphics = new Graphics3DImage(pictureBoxCase.Size);
                    graphics.CameraPosition = Graphics3D.Corner_0;
                    graphics.Target = Vector3D.Zero;
                    Box box = new Box(0, analysis.BProperties);
                    graphics.AddBox(box);
                    graphics.AddDimensions(new DimensionCube(box.Length, box.Width, box.Height));
                    graphics.Flush();
                    pictureBoxCase.Image = graphics.Bitmap;
                }

                {
                // instantiate graphics
                Graphics3DImage graphics = new Graphics3DImage(pictureBoxSolution.Size);
                // set camera position 
                graphics.CameraPosition = Graphics3D.Corner_0;
                graphics.Target = Vector3D.Zero;
                // instantiate solution viewer
                CasePalletSolutionViewer sv = new CasePalletSolutionViewer(analysis.Solutions[0]);
                sv.Draw(graphics);
                graphics.Flush();
                // show generated bitmap on picture box control
                pictureBoxSolution.Image = graphics.Bitmap;
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex.ToString());
            }

        }
示例#25
0
        private void AppendCaseSolutionElement(SelBoxCasePalletSolution selSolution, XmlElement elemCaseAnalysis, XmlDocument xmlDoc)
        {
            string ns = xmlDoc.DocumentElement.NamespaceURI;
            BoxCasePalletSolution caseSolution = selSolution.Solution;
            // caseSolution element
            XmlElement elemCaseSolution = CreateElement("boxCasePalletSolution", null, elemCaseAnalysis, xmlDoc, ns);
            // title
            CreateElement("title", caseSolution.Title, elemCaseSolution, xmlDoc, ns);
            // homogeneousLayer
            CreateElement("homogeneousLayer", caseSolution.HasHomogeneousLayers ? "Y" : "N", elemCaseSolution, xmlDoc, ns);
            // casePerPalletCount
            CreateElement("casePerPalletCount", caseSolution.CasePerPalletCount, elemCaseSolution, xmlDoc, ns);
            // boxPerCaseCount
            CreateElement("boxPerCaseCount", caseSolution.BoxPerCaseCount, elemCaseSolution, xmlDoc, ns);
            // boxPerPalletCount
            CreateElement("boxPerPalletCount", caseSolution.BoxPerPalletCount, elemCaseSolution, xmlDoc, ns);
            // caseEfficiency
            CreateElement("caseEfficiency", caseSolution.CaseEfficiency, elemCaseSolution, xmlDoc, ns);
            // palletEfficiency
            CreateElement("palletEfficiency", caseSolution.PalletEfficiency, elemCaseSolution, xmlDoc, ns);

            AppendElementValue(xmlDoc, elemCaseSolution, "caseWeight", UnitsManager.UnitType.UT_MASS, caseSolution.CaseWeight);
            AppendElementValue(xmlDoc, elemCaseSolution, "palletWeight", UnitsManager.UnitType.UT_MASS, caseSolution.PalletWeight);

            // --- build image
            Graphics3DImage graphics = new Graphics3DImage(new Size(512, 512));
            graphics.CameraPosition = Graphics3D.Corner_0;
            graphics.Target = Vector3D.Zero;
            // instantiate solution viewer
            BoxCasePalletSolutionViewer sv = new BoxCasePalletSolutionViewer(caseSolution);
            sv.Draw(graphics);
            graphics.Flush();
            SaveImageAs(graphics.Bitmap, "view_caseSolution_iso.png");
            // ---
            // view_caseSolution_iso
            XmlElement elemImage = xmlDoc.CreateElement("view_caseSolution_iso", ns);
            TypeConverter converter = TypeDescriptor.GetConverter(typeof(Bitmap));
            elemImage.InnerText = Convert.ToBase64String((byte[])converter.ConvertTo(graphics.Bitmap, typeof(byte[])));
            XmlAttribute styleAttribute = xmlDoc.CreateAttribute("style");
            styleAttribute.Value = string.Format("width:{0}pt;height:{1}pt", graphics.Bitmap.Width / 4, graphics.Bitmap.Height / 4);
            elemImage.Attributes.Append(styleAttribute);
            elemCaseSolution.AppendChild(elemImage);
        }
示例#26
0
        static void Main(string[] args)
        {
            ILog log = LogManager.GetLogger(typeof(Program));
            XmlConfigurator.Configure(); 

            try
            {
                // instantiate graphics
                Graphics3DImage graphics = new Graphics3DImage(new Size(512, 512));
                graphics.CameraPosition = new Vector3D(-10000.0, -10000.0, 10000.0);
                graphics.Target = Vector3D.Zero;
                graphics.SetViewport(-500.0f, -500.0f, 500.0f, 500.0f);
                // load Bitmap
                string imageFilePath = @"..\..\Image16.bmp";
                Bitmap bmp = new Bitmap(imageFilePath);
                Texture texture = new Texture(bmp, new Vector2D(100.0, 20.0), new Vector2D(40.0 * bmp.Size.Width / bmp.Size.Height, 40.0), 10.0);
                List<Texture> listTexture= new List<Texture>();
                listTexture.Add(texture);
                // instantiate box and draw
                List<Box> boxList = new List<Box>();
                Box box0 = new Box(0, 200.0, 160.0, 100.0);
                box0.Position = Vector3D.Zero;
                box0.SetAllFacesColor(Color.Chocolate);
                box0.SetFaceTextures(HalfAxis.HAxis.AXIS_X_P, listTexture);
                box0.SetFaceTextures(HalfAxis.HAxis.AXIS_Y_P, listTexture);
                box0.SetFaceTextures(HalfAxis.HAxis.AXIS_Z_P, listTexture);
                box0.SetFaceTextures(HalfAxis.HAxis.AXIS_X_N, listTexture);
                box0.SetFaceTextures(HalfAxis.HAxis.AXIS_Y_N, listTexture);
                box0.SetFaceTextures(HalfAxis.HAxis.AXIS_Z_N, listTexture);
                boxList.Add(box0);
                Box box1 = new Box(1, 200.0, 160.0, 100.0);
                box1.Position = new Vector3D(210.0, 0.0, 0.0);
                box1.SetAllFacesColor(Color.Chocolate);
                box1.SetFaceTextures(HalfAxis.HAxis.AXIS_Y_P, listTexture);
                boxList.Add(box1);

                Box box2 = new Box(2, 200.0, 160.0, 100.0);
                box2.Position = new Vector3D(0.0, 170.0, 0.0);
                box2.SetAllFacesColor(Color.Chocolate);
                boxList.Add(box2);

                Box box3 = new Box(3, 200.0, 160.0, 100.0);
                box3.Position = new Vector3D(0.0, 0.0, 110.0);
                box3.SetAllFacesColor(Color.Chocolate);
                boxList.Add(box3);

                // draw
                foreach (Box box in boxList)
                    graphics.AddBox(box);
                graphics.Flush();
                // Save as %TEMP%\Pallet.jpg
                string filePath = Path.Combine(Path.GetTempPath(), "Pallet.bmp");
                graphics.SaveAs(filePath);

                bmp.Dispose();

                // open file
                using (System.Diagnostics.Process proc = new System.Diagnostics.Process())
                {
                    proc.StartInfo.FileName = "mspaint.exe";
                    proc.StartInfo.Arguments = filePath;
                    proc.Start();
                }
            }
            catch (System.Exception ex)
            {
                log.Error(ex.ToString());
            }
        }
示例#27
0
        private void AppendPalletElement(PalletProperties palletProp, XmlElement elemAnalysis, XmlDocument xmlDoc)
        {
            string ns = xmlDoc.DocumentElement.NamespaceURI;
            if (null == palletProp) return;
            // pallet
            XmlElement elemPallet = xmlDoc.CreateElement("pallet", ns);
            elemAnalysis.AppendChild(elemPallet);
            // name
            XmlElement elemName = xmlDoc.CreateElement("name", ns);
            elemName.InnerText = palletProp.Name;
            elemPallet.AppendChild(elemName);
            // description
            XmlElement elemDescription = xmlDoc.CreateElement("description", ns);
            elemDescription.InnerText = palletProp.Description;
            elemPallet.AppendChild(elemDescription);

            AppendElementValue(xmlDoc, elemPallet, "length", UnitsManager.UnitType.UT_LENGTH, palletProp.Length);
            AppendElementValue(xmlDoc, elemPallet, "width", UnitsManager.UnitType.UT_LENGTH, palletProp.Width);
            AppendElementValue(xmlDoc, elemPallet, "height", UnitsManager.UnitType.UT_LENGTH, palletProp.Height);
            AppendElementValue(xmlDoc, elemPallet, "weight", UnitsManager.UnitType.UT_MASS, palletProp.Weight);
            AppendElementValue(xmlDoc, elemPallet, "admissibleLoad", UnitsManager.UnitType.UT_MASS, palletProp.AdmissibleLoadWeight);

            // type
            XmlElement elemType = xmlDoc.CreateElement("type", ns);
            elemType.InnerText = palletProp.TypeName;
            elemPallet.AppendChild(elemType);
            // --- build image
            Graphics3DImage graphics = new Graphics3DImage(new Size(512, 512));
            graphics.CameraPosition = Graphics3D.Corner_0;
            Pallet pallet = new Pallet(palletProp);
            pallet.Draw(graphics, Transform3D.Identity);
            graphics.AddDimensions(new DimensionCube(palletProp.Length, palletProp.Width, palletProp.Height));
            graphics.Flush();
            // ---
            // view_pallet_iso
            XmlElement elemImage = xmlDoc.CreateElement("view_pallet_iso", ns);
            TypeConverter converter = TypeDescriptor.GetConverter(typeof(Bitmap));
            elemImage.InnerText = Convert.ToBase64String((byte[])converter.ConvertTo(graphics.Bitmap, typeof(byte[])));
            XmlAttribute styleAttribute = xmlDoc.CreateAttribute("style");
            styleAttribute.Value = string.Format("width:{0}pt;height:{1}pt", graphics.Bitmap.Width / 4, graphics.Bitmap.Height / 4);
            elemImage.Attributes.Append(styleAttribute);
            elemPallet.AppendChild(elemImage);
            // save image
            SaveImageAs(graphics.Bitmap, "view_pallet_iso.png");
        }
示例#28
0
        private Bitmap GetBoxBitmapFromDesc(PalletSolutionDesc desc)
        {
            bool showDimensions = false;

            // load document
            Document document = new Document(desc.FullFilePath, null);
            if (document.Analyses.Count != 1)
                throw new Exception("Failed to load analysis.");
            // get analysis and solution
            CasePalletAnalysis analysis = document.Analyses[0];
            Graphics3DImage graphics = new Graphics3DImage(new Size(50,50));
            graphics.CameraPosition = Graphics3D.Corner_0;
            graphics.Target = Vector3D.Zero;
            Box box = new Box(0, analysis.BProperties);
            graphics.AddBox(box);
            if (showDimensions)
                graphics.AddDimensions(new DimensionCube(box.Length, box.Width, box.Height));
            graphics.Flush();
            return graphics.Bitmap;
        }
示例#29
0
 private void DrawBox()
 {
     try
     {
         // get horizontal angle
         double angle = trackBarHorizAngle.Value;
         // instantiate graphics
         Graphics3DImage graphics = new Graphics3DImage(pictureBox.Size);
         graphics.CameraPosition = new Vector3D(
             Math.Cos(angle * Math.PI / 180.0) * Math.Sqrt(2.0) * 10000.0
             , Math.Sin(angle * Math.PI / 180.0) * Math.Sqrt(2.0) * 10000.0
             , 10000.0);
         graphics.Target = Vector3D.Zero;
         graphics.SetViewport(-500.0f, -500.0f, 500.0f, 500.0f);
         // draw
         BoxProperties boxProperties = new BoxProperties(null, _boxProperties.Length, _boxProperties.Width, _boxProperties.Height);
         boxProperties.SetAllColors(_boxProperties.Colors);
         boxProperties.TextureList = _textures;
         Box box = new Box(0, boxProperties);
         graphics.AddBox(box);
         graphics.Flush();
         // set to picture box
         pictureBox.Image = graphics.Bitmap;
     }
     catch (Exception ex)
     {
         _log.Error(ex.ToString());
     }
 }