Beispiel #1
0
 public Cylinder(uint pickId, CylinderProperties cylProperties)
 {
     _pickId = pickId;
     _radiusOuter = cylProperties.RadiusOuter;
     _radiusInner = cylProperties.RadiusInner;
     _height = cylProperties.Height;
     _colorTop = cylProperties.ColorTop;
     _colorWallOuter = cylProperties.ColorWallOuter;
     _colorWallInner = cylProperties.ColorWallInner;
 }
Beispiel #2
0
        public void ProcessAnalysis(CylinderPalletAnalysis analysis)
        {
            _cylProperties = analysis.CylinderProperties;
            _palletProperties = analysis.PalletProperties;
            _interlayerProperties = analysis.InterlayerProperties;
            _interlayerPropertiesAntiSlip = analysis.InterlayerPropertiesAntiSlip;
            _constraintSet = analysis.ConstraintSet;
            if (!_constraintSet.IsValid)
                throw new EngineException("Constraint set is invalid!");

            analysis.Solutions = GenerateSolutions();
        }
 public CylinderPalletAnalysis(
     CylinderProperties cylProperties
     , PalletProperties palletProperties
     , InterlayerProperties interlayerProperties
     , InterlayerProperties interlayerPropertiesAntiSlip
     , CylinderPalletConstraintSet constraintSet)
     : base(cylProperties.ParentDocument)
 {
     // setting members
     CylinderProperties = cylProperties;
     PalletProperties = palletProperties;
     InterlayerProperties = interlayerProperties;
     InterlayerPropertiesAntiSlip = interlayerPropertiesAntiSlip;
     _constraintSet = constraintSet;
     // has interlayer ?
     _constraintSet.HasInterlayer = null != interlayerProperties;
     _constraintSet.HasInterlayerAntiSlip = null != interlayerPropertiesAntiSlip;
 }
 public FormNewCylinder(Document document, CylinderProperties cylinder)
 {
     InitializeComponent();
     // set unit labels
     UnitsManager.AdaptUnitLabels(this);
     // save document reference
     _document = document;
     _cylProperties = cylinder;
     // properties
     tbName.Text = cylinder.Name;
     tbDescription.Text = cylinder.Description;
     nudDiameterOuter.Value = 2.0M * (decimal)cylinder.RadiusOuter;
     nudDiameterInner.Value = 2.0M * (decimal)cylinder.RadiusInner;
     nudHeight.Value = (decimal)cylinder.Height;
     cbColorWallOuter.Color = cylinder.ColorWallOuter;
     cbColorWallInner.Color = cylinder.ColorWallInner;
     cbColorTop.Color = cylinder.ColorTop;
     nudWeight.Value = (decimal)cylinder.Weight;
     // disable Ok button
     UpdateButtonOkStatus();        
 }
Beispiel #5
0
 /// <summary>
 /// Creates a new cylinder/pallet analysis without generating solutions
 /// </summary>
 /// <param name="name">Name</param>
 /// <param name="description">Description</param>
 /// <param name="cylinder">Cylinder</param>
 /// <param name="pallet">Pallet</param>
 /// <param name="interlayer">Interlayer or null</param>
 /// <param name="constraintSet">Cylinder/pallet analysis constraint set</param>
 /// <param name="solutions">Solutions</param>
 /// <returns>Cylinder/pallet analysis</returns>
 public HCylinderPalletAnalysis CreateNewHCylinderPalletAnalysis(
     string name, string description
     , CylinderProperties cylinder, PalletProperties pallet
     , HCylinderPalletConstraintSet constraintSet
     , List<HCylinderPalletSolution> solutions)
 {
     HCylinderPalletAnalysis analysis = new HCylinderPalletAnalysis(cylinder, pallet, constraintSet);
     analysis.Name = name;
     analysis.Description = description;
     // insert in list
     _hCylinderPalletAnalyses.Add(analysis);
     // set solutions
     analysis.Solutions = solutions;
     // notify listeners
     NotifyOnNewHCylinderPalletAnalysisCreated(analysis);
     // set solution selected if its unique
     if (solutions.Count == 1)
         analysis.SelectSolutionByIndex(0);
     return analysis;
 }
Beispiel #6
0
 public HCylinderPalletAnalysis CreateNewHCylinderPalletAnalysis(
     string name, string description,
     CylinderProperties cylinder, PalletProperties pallet,
     HCylinderPalletConstraintSet constraintSet,
     IHCylinderAnalysisSolver solver)
 {
     HCylinderPalletAnalysis analysis = new HCylinderPalletAnalysis(cylinder, pallet, constraintSet);
     analysis.Name = name;
     analysis.Description = description;
     // insert in list
     _hCylinderPalletAnalyses.Add(analysis);
     // compute analysis
     solver.ProcessAnalysis(analysis);
     if (analysis.Solutions.Count < 1)
     {   // remove analysis from list if it has no valid solution
         _hCylinderPalletAnalyses.Remove(analysis);
         return null;
     }
     // notify listeners
     NotifyOnNewHCylinderPalletAnalysisCreated(analysis);
     Modify();
     return analysis;
 }
Beispiel #7
0
 public CylinderProperties CreateNewCylinder(
     string name, string description
     , double radiusOuter, double radiusInner, double height
     , double weight
     , Color colorTop, Color colorWallOuter, Color colorWallInner)
 {
     CylinderProperties cylinder = new CylinderProperties(this, name, description
         , radiusOuter, radiusInner, height, weight
         , colorTop, colorWallOuter, colorWallInner);
     // insert in list
     _typeList.Add(cylinder);
     // notify listeners
     NotifyOnNewTypeCreated(cylinder);
     Modify();
     return cylinder;        
 }
Beispiel #8
0
 public CylinderProperties CreateNewCylinder(CylinderProperties cyl)
 {
     // cylinder
     CylinderProperties cylinder = new CylinderProperties(this
         , cyl.Name, cyl.Description
         , cyl.RadiusOuter, cyl.RadiusInner, cyl.Height
         , cyl.Weight
         , cyl.ColorTop, cyl.ColorWallOuter, cyl.ColorWallInner);
     // insert in list
     _typeList.Add(cylinder);
     // notify listeners
     NotifyOnNewTypeCreated(cylinder);
     Modify();
     return cylinder;
 }
Beispiel #9
0
 public void Save(CylinderProperties cylinderProperties, XmlElement parentElement, XmlDocument xmlDoc)
 {
     // create xmlBoxProperties element
     XmlElement xmlBoxProperties = xmlDoc.CreateElement("CylinderProperties");
     parentElement.AppendChild(xmlBoxProperties);
     // Id
     XmlAttribute guidAttribute = xmlDoc.CreateAttribute("Id");
     guidAttribute.Value = cylinderProperties.Guid.ToString();
     xmlBoxProperties.Attributes.Append(guidAttribute);
     // name
     XmlAttribute nameAttribute = xmlDoc.CreateAttribute("Name");
     nameAttribute.Value = cylinderProperties.Name;
     xmlBoxProperties.Attributes.Append(nameAttribute);
     // description
     XmlAttribute descAttribute = xmlDoc.CreateAttribute("Description");
     descAttribute.Value = cylinderProperties.Description;
     xmlBoxProperties.Attributes.Append(descAttribute);
     // radius outer
     XmlAttribute radiusOuterAttribute = xmlDoc.CreateAttribute("RadiusOuter");
     radiusOuterAttribute.Value = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", cylinderProperties.RadiusOuter);
     xmlBoxProperties.Attributes.Append(radiusOuterAttribute);
     // radius inner
     XmlAttribute radiusInnerAttribute = xmlDoc.CreateAttribute("RadiusInner");
     radiusInnerAttribute.Value = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", cylinderProperties.RadiusInner);
     xmlBoxProperties.Attributes.Append(radiusInnerAttribute);
     // height
     XmlAttribute heightAttribute = xmlDoc.CreateAttribute("Height");
     heightAttribute.Value = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", cylinderProperties.Height);
     xmlBoxProperties.Attributes.Append(heightAttribute);
     // weight
     XmlAttribute weightAttribute = xmlDoc.CreateAttribute("Weight");
     weightAttribute.Value = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", cylinderProperties.Weight);
     xmlBoxProperties.Attributes.Append(weightAttribute);
     // colorTop
     XmlAttribute topAttribute = xmlDoc.CreateAttribute("ColorTop");
     topAttribute.Value = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", cylinderProperties.ColorTop.ToArgb());
     xmlBoxProperties.Attributes.Append(topAttribute);
     // colorWall
     XmlAttribute outerWallAttribute = xmlDoc.CreateAttribute("ColorWallOuter");
     outerWallAttribute.Value = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", cylinderProperties.ColorWallOuter.ToArgb());
     xmlBoxProperties.Attributes.Append(outerWallAttribute);
     // color inner wall
     XmlAttribute innerWallAttribute = xmlDoc.CreateAttribute("ColorWallInner");
     innerWallAttribute.Value = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", cylinderProperties.ColorWallInner.ToArgb());
     xmlBoxProperties.Attributes.Append(innerWallAttribute);
 }
 public HCylinderPalletAnalysis(
     CylinderProperties cylProperties,
     PalletProperties palletProperties,
     HCylinderPalletConstraintSet constraintSet)
     : base(cylProperties.ParentDocument)
 {
     CylinderProperties = cylProperties;
     PalletProperties = palletProperties;
     _constraintSet = constraintSet;
 }
Beispiel #11
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;
        }
Beispiel #12
0
 public CylinderItem(CylinderProperties cylinderProperties)
 {
     _cylinderProperties = cylinderProperties;
 }
Beispiel #13
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");             
        }
Beispiel #14
0
 public void Draw(Graphics3DControl ctrl, Graphics3D graphics)
 {
     CylinderProperties cylProperties = new CylinderProperties(
         null, CylinderName, Description
         , RadiusOuter, RadiusInner, CylinderHeight, Weight
         , ColorTop, ColorWallOuter, ColorWallInner);
     Cylinder cyl = new Cylinder(0, cylProperties);
     graphics.AddCylinder(cyl);
 }