public void Draw(Graphics3DControl ctrl, Graphics3D graphics)
 {
     if (ctrl == graphCtrlPallet)
     {
         PalletProperties pp = CurrentPallet;
         Pallet pallet = new Pallet(pp);
         pallet.Draw(graphics, Transform3D.Identity);
         DimensionCube dc = new DimensionCube(pp.Length, pp.Width, pp.Height) { FontSize = 6.0f };
         graphics.AddDimensions(dc); 
     }
     else if (ctrl == graphCtrlSolution)
     {
         if (null == CurrentSolution) return;
         CasePalletSolutionViewer sv = new CasePalletSolutionViewer(CurrentSolution);
         sv.Draw(graphics);
     }
 }
Exemplo n.º 2
0
        public void Draw(Graphics3D graphics)
        {
            if (null == _caseDefinition || null == _boxProperties)
            {
                return;
            }

            // get global transformation
            Transform3D transf = Orientation.Transformation;

            // draw case (back faces)
            Case @case = CaseProperties != null ? new Case(CaseProperties, transf) : null;

            if (null != @case)
            {
                // draw case (inside)
                @case.DrawInside(graphics, Transform3D.Identity);
            }
            // add boxes
            uint pickId = 0;

            for (int i = 0; i < _caseDefinition.Arrangement.Length; ++i)
            {
                for (int j = 0; j < _caseDefinition.Arrangement.Width; ++j)
                {
                    for (int k = 0; k < _caseDefinition.Arrangement.Height; ++k)
                    {
                        graphics.AddBox(new Box(pickId++, _boxProperties, GetPosition(i, j, k, _caseDefinition.Dim0, _caseDefinition.Dim1)));
                    }
                }
            }
            if (ShowDimensions)
            {
                // add external dimensions
                Vector3D outerDimensions = _caseDefinition.OuterDimensions(_boxProperties, _caseOptimConstraintSet);
                graphics.AddDimensions(DimensionCube.Transform(new DimensionCube(Vector3D.Zero, outerDimensions.X, outerDimensions.Y, outerDimensions.Z, Color.Black, true), transf));
                // add inner dimensions
                Vector3D innerOffset     = _caseDefinition.InnerOffset(_caseOptimConstraintSet);
                Vector3D innerDimensions = _caseDefinition.InnerDimensions(_boxProperties);
                graphics.AddDimensions(DimensionCube.Transform(new DimensionCube(innerOffset, innerDimensions.X, innerDimensions.Y, innerDimensions.Z, Color.Red, false), transf));
            }
        }
Exemplo n.º 3
0
 public void AddDimensions(DimensionCube dimensionCube)
 {
     _dimensions.Add(dimensionCube);
 }
Exemplo n.º 4
0
 public static DimensionCube Transform(DimensionCube dimCube, Transform3D transform)
 {
     Vector3D pos = transform.transform(dimCube._position);
     Vector3D dim = transform.transformRot(new Vector3D(dimCube._dim) );
     if (dim.X < 0) { pos.X += dim.X; dim.X = -dim.X; }
     if (dim.Y < 0) { pos.Y += dim.Y; dim.Y = -dim.Y; }
     if (dim.Z < 0) { pos.Z += dim.Z; dim.Z = -dim.Z; }
     return new DimensionCube(pos, dim.X, dim.Y, dim.Z, dimCube.Color, dimCube._above);
 }
 public void Draw(Graphics3DControl ctrl, Graphics3D graphics)
 {
     // ### draw pallet
     if (graphCtrlPallet == ctrl)
     {
         PalletProperties pp = SelectedPallet;
         Pallet pallet = new Pallet(pp);
         pallet.Draw(graphics, Transform3D.Identity);
         DimensionCube dc = new DimensionCube(pp.Length, pp.Width, pp.Height) { FontSize = 6.0f };
         graphics.AddDimensions(dc);
     }
     // ### draw case definition
     else if (ctrl == graphCtrlBoxesLayout)
     {
         // ### draw case definition
         try
         {
             // get selected solution
             CaseOptimSolution solution = SelectedSolution;
             if (null == solution) return;
             // instantiate case definition viewer
             CaseDefinitionViewer cdv = new CaseDefinitionViewer(SelectedSolution.CaseDefinition, SelectedBox, BuildCaseOptimConstraintSet());
             cdv.Orientation = SelectedSolution.PalletSolution.FirstCaseOrientation;
             cdv.Draw(graphics);
         }
         catch (Exception ex)
         {
             _log.Error(ex.ToString());
         }
     }
     // ### draw associated pallet solution
     else if (ctrl == graphCtrlPalletLayout)
     {
         try
         {
             // get selected solution
             CaseOptimSolution solution = SelectedSolution;
             // get selected box
             BoxProperties boxProperties = SelectedBox;
             // get selected pallet
             PalletProperties palletProperties = SelectedPallet;
             if (null != solution && null != boxProperties && null != palletProperties)
             {
                 Vector3D outerDim = solution.CaseDefinition.OuterDimensions(boxProperties, BuildCaseOptimConstraintSet());
                 BoxProperties caseProperties = new BoxProperties(null, outerDim.X, outerDim.Y, outerDim.Z);
                 caseProperties.SetColor(Color.Chocolate);
                 CasePalletSolutionViewer.Draw(graphics, solution.PalletSolution, caseProperties, null, palletProperties);
             }
         }
         catch (Exception ex)
         {
             _log.Error(ex.ToString());
         }
     }
 }
Exemplo n.º 6
0
 public void AddDimensions(DimensionCube dimensionCube)
 {
     _dimensions.Add(dimensionCube);
 }
Exemplo n.º 7
0
 public void Draw(Graphics3DControl ctrl, Graphics3D graphics)
 {
     if (graphCtrlPallet == ctrl)
     {
         Pallet pallet = new Pallet(_palletProperties);
         pallet.Draw(graphics, Transform3D.Identity);
         DimensionCube dc = new DimensionCube(_palletProperties.Length, _palletProperties.Width, _palletProperties.Height) { FontSize = 6.0f };
         graphics.AddDimensions(dc);                
     }
 }
Exemplo n.º 8
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");
 }
Exemplo n.º 9
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");             
        }
Exemplo n.º 10
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");
        }
Exemplo n.º 11
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");
 }
Exemplo n.º 12
0
 private void AppendCaseElement(BoxProperties caseProperties, XmlElement elemCaseAnalysis, XmlDocument xmlDoc)
 {
     string ns = xmlDoc.DocumentElement.NamespaceURI;
     // case element
     XmlElement elemCase = CreateElement("caseWithInnerDims", null, elemCaseAnalysis, xmlDoc, ns);
     // name
     CreateElement("name", caseProperties.Name, elemCase, xmlDoc, ns);
     // description
     CreateElement("description", caseProperties.Description, elemCase, xmlDoc, ns);
     // unit width
     // length / width /height
     AppendElementValue(xmlDoc, elemCase, "length", UnitsManager.UnitType.UT_LENGTH, caseProperties.Length);
     AppendElementValue(xmlDoc, elemCase, "width", UnitsManager.UnitType.UT_LENGTH, caseProperties.Width);
     AppendElementValue(xmlDoc, elemCase, "height", UnitsManager.UnitType.UT_LENGTH, caseProperties.Height);
     // innerLength / innerWidth / innerHeight
     AppendElementValue(xmlDoc, elemCase, "innerLength", UnitsManager.UnitType.UT_LENGTH, caseProperties.InsideLength);
     AppendElementValue(xmlDoc, elemCase, "innerWidth", UnitsManager.UnitType.UT_LENGTH, caseProperties.InsideWidth);
     AppendElementValue(xmlDoc, elemCase, "innerHeight", UnitsManager.UnitType.UT_LENGTH, caseProperties.InsideHeight);
     // weight
     AppendElementValue(xmlDoc, elemCase, "weight", UnitsManager.UnitType.UT_MASS, caseProperties.Weight);
     // --- build image
     Graphics3DImage graphics = new Graphics3DImage(new Size(ImageSizeDetail, ImageSizeDetail));
     graphics.CameraPosition = Graphics3D.Corner_0;
     graphics.Target = Vector3D.Zero;
     Box box = new Box(0, caseProperties);
     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");
 }
Exemplo n.º 13
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");
        }