public BBox3D BoundingBox(PackProperties packProperties)
        {
            BBox3D bbox = new BBox3D();

            foreach (BoxPosition bpos in this)
            {
                Vector3D[] pts = new Vector3D[8];
                Vector3D vI = HalfAxis.ToVector3D(bpos.DirectionLength);
                Vector3D vJ = HalfAxis.ToVector3D(bpos.DirectionWidth);
                Vector3D vK = Vector3D.CrossProduct(vI, vJ);
                pts[0] = bpos.Position;
                pts[1] = bpos.Position + packProperties.Length * vI;
                pts[2] = bpos.Position + packProperties.Width * vJ;
                pts[3] = bpos.Position + packProperties.Length * vI + packProperties.Width * vJ;
                pts[4] = bpos.Position + packProperties.Height * vK;
                pts[5] = bpos.Position + packProperties.Width * vJ + packProperties.Height * vK; ;
                pts[6] = bpos.Position + HalfAxis.ToVector3D(bpos.DirectionWidth) * packProperties.Width;
                pts[7] = bpos.Position + HalfAxis.ToVector3D(bpos.DirectionLength) * packProperties.Length + HalfAxis.ToVector3D(bpos.DirectionWidth) * packProperties.Width;

                foreach (Vector3D pt in pts)
                    bbox.Extend(pt);
            }

            return bbox;       
        }
Exemple #2
0
 public Pack(uint pickId, PackProperties packProperties)
     : base(pickId, packProperties.Length, packProperties.Width, packProperties.Height)
 {
     _packProperties = packProperties;
     _arrangement = _packProperties.Arrangement;
     _innerBox = new Box(0, packProperties.Box);
 }
Exemple #3
0
 public Pack(uint pickId, PackProperties packProperties, BoxPosition position)
     : base(pickId, packProperties, position)
 {
     _packProperties = packProperties;
     _arrangement = _packProperties.Arrangement;
     _innerBox = new Box(0, packProperties.Box);
     _forceTransparency = false;
 }
 public void ProcessAnalysis(PackPalletAnalysis analysis)
 {
     _packProperties = analysis.PackProperties;
     _palletProperties = analysis.PalletProperties;
     _interlayerProperties = analysis.InterlayerProperties;
     _constraintSet = analysis.ConstraintSet;
     analysis.Solutions = GenerateSolutions();
 }
Exemple #5
0
 public static void GetDimensions(
     BoxProperties boxProperties
     , HalfAxis.HAxis boxOrientation
     , PackArrangement arrangement
     , ref double length, ref double width, ref double height)
 {
     if (null == boxProperties)
     {
         return;
     }
     length = arrangement._iLength * boxProperties.Dim(PackProperties.DimIndex0(boxOrientation));
     width  = arrangement._iWidth * boxProperties.Dim(PackProperties.DimIndex1(boxOrientation));
     height = arrangement._iHeight * boxProperties.Dim(3 - PackProperties.DimIndex0(boxOrientation) - PackProperties.DimIndex1(boxOrientation));
 }
 public PackPalletAnalysis(
     PackProperties packProperties,
     PalletProperties palletProperties,
     InterlayerProperties interlayerProperties,
     PackPalletConstraintSet constraintSet)
     : base(packProperties.ParentDocument)
 {
     // sanity checks
     if (palletProperties.ParentDocument != ParentDocument
         || (interlayerProperties != null && interlayerProperties.ParentDocument != ParentDocument))
         throw new Exception("box, pallet, interlayer do not belong to the same document");
     // setting members
     this.PackProperties = packProperties;
     this.PalletProperties = palletProperties;
     this.InterlayerProperties = interlayerProperties;
     this.ConstraintSet = constraintSet;
 }
Exemple #7
0
        // static methods
        static public double EstimateWeight(
            BoxProperties boxProperties, PackArrangement arrangement, HalfAxis.HAxis orientation
            , int[] noWalls, double thickness, double surfacicMass)
        {
            double length = 0.0, width = 0.0, height = 0.0;

            PackProperties.GetDimensions(boxProperties, orientation, arrangement, ref length, ref width, ref height);
            Vector3D vDimensions = new Vector3D(
                length + noWalls[0] * thickness
                , width + noWalls[1] * thickness
                , height + noWalls[2] * thickness);

            double area = (noWalls[0] * vDimensions.Y * vDimensions.Z
                           + noWalls[1] * vDimensions.X * vDimensions.Z
                           + noWalls[2] * vDimensions.X * vDimensions.Y) * UnitsManager.FactorSquareLengthToArea;

            return(area * surfacicMass);
        }
 public PackPalletAnalysis(
     PackProperties packProperties,
     PalletProperties palletProperties,
     InterlayerProperties interlayerProperties,
     PackPalletConstraintSet constraintSet)
     : base(packProperties.ParentDocument)
 {
     // sanity checks
     if (palletProperties.ParentDocument != ParentDocument ||
         (interlayerProperties != null && interlayerProperties.ParentDocument != ParentDocument))
     {
         throw new Exception("box, pallet, interlayer do not belong to the same document");
     }
     // setting members
     this.PackProperties       = packProperties;
     this.PalletProperties     = palletProperties;
     this.InterlayerProperties = interlayerProperties;
     this.ConstraintSet        = constraintSet;
 }
 public FormNewPack(Document doc, PackProperties packProperties)
     : base(doc, packProperties)
 {
     InitializeComponent();
     _packProperties = packProperties;
 }
 public void Draw(Graphics3DControl ctrl, Graphics3D graphics)
 {
     // build pack
     PackProperties packProperties = new PackProperties(null, SelectedBox, Arrangement, BoxOrientation, Wrapper);
     if (uCtrlOuterDimensions.Checked)
         packProperties.ForceOuterDimensions(
             new Vector3D(uCtrlOuterDimensions.X, uCtrlOuterDimensions.Y, uCtrlOuterDimensions.Z) );
     Pack pack = new Pack(0, packProperties);
     pack.ForceTransparency = true;
     graphics.AddBox(pack);
     graphics.AddDimensions(new DimensionCube(Vector3D.Zero, pack.Length, pack.Width, pack.Height, Color.Black, true));
     if (packProperties.Wrap.Transparent)
         graphics.AddDimensions(
             new DimensionCube(
                 packProperties.InnerOffset
                 , packProperties.InnerLength, packProperties.InnerWidth, packProperties.InnerHeight
                 , Color.Red, false));
 }
 public PackPalletAnalysis CreateNewPackPalletAnalysis(
     string name, string description
     , PackProperties pack, PalletProperties pallet
     , InterlayerProperties interlayer
     , PackPalletConstraintSet constraintSet
     , List<PackPalletSolution> solutions)
 {
     PackPalletAnalysis analysis = new PackPalletAnalysis(
         pack
         , pallet
         , interlayer
         , constraintSet);
     analysis.Name = name;
     analysis.Description = description;
     // insert in list
     _packPalletAnalyses.Add(analysis);
     // set solutions
     analysis.Solutions = solutions;
     // notify listeners
     NotifyOnNewPackPalletAnalysisCreated(analysis);
     // set solution selected if it is unique
     if (solutions.Count == 1)
         analysis.SelectSolutionByIndex(0);
     return analysis;
 }
 public PackPalletAnalysis CreateNewPackPalletAnalysis(
     string name, string description
     , PackProperties pack, PalletProperties pallet
     , InterlayerProperties interlayer
     , PackPalletConstraintSet constraintSet
     , IPackPalletAnalysisSolver solver)
 {
     PackPalletAnalysis analysis = new PackPalletAnalysis(
         pack
         , pallet
         , interlayer
         , constraintSet);
     analysis.Name = name;
     analysis.Description = description;
     // insert in list
     _packPalletAnalyses.Add(analysis);
     // compute analysis
     solver.ProcessAnalysis(analysis);
     if (analysis.Solutions.Count < 1)
     {   // remove analysis from list if it has no valid solution
         _packPalletAnalyses.Remove(analysis);
         Modify();
         return null;
     }
     // notify listeners
     NotifyOnNewPackPalletAnalysisCreated(analysis);
     Modify();
     return analysis;
 }
 /// <summary>
 /// Create a new pack
 /// </summary>
 /// <param name="name">Name</param>
 /// <param name="description">Description</param>
 /// <param name="box">Inner box</param>
 /// <param name="arrangement">Arrangement</param>
 /// <param name="axis">Axis</param>
 /// <param name="wrapper">Wrapper</param>
 /// <returns></returns>
 public PackProperties CreateNewPack(
     string name, string description
     , BoxProperties box
     , PackArrangement arrangement
     , HalfAxis.HAxis axis
     , PackWrapper wrapper)
 {
     // instantiate and initialize
     PackProperties packProperties = new PackProperties(this
         , box
         , arrangement
         , axis
         , wrapper);
     packProperties.Name = name;
     packProperties.Description = description;
     // insert in list
     _typeList.Add(packProperties);
     // notify listeners
     NotifyOnNewTypeCreated(packProperties);
     Modify();
     return packProperties;
 }
        public void Save(PackProperties packProperties, XmlElement parentElement, XmlDocument xmlDoc)
        {
            // create xmlPackProperties element
            XmlElement xmlPackProperties = xmlDoc.CreateElement("PackProperties");
            parentElement.AppendChild(xmlPackProperties);
            // Id
            XmlAttribute guidAttribute = xmlDoc.CreateAttribute("Id");
            guidAttribute.Value = packProperties.Guid.ToString();
            xmlPackProperties.Attributes.Append(guidAttribute);
            // name
            XmlAttribute nameAttribute = xmlDoc.CreateAttribute("Name");
            nameAttribute.Value = packProperties.Name;
            xmlPackProperties.Attributes.Append(nameAttribute);
            // description
            XmlAttribute descAttribute = xmlDoc.CreateAttribute("Description");
            descAttribute.Value = packProperties.Description;
            xmlPackProperties.Attributes.Append(descAttribute);
            // boxProperties
            XmlAttribute boxPropAttribute = xmlDoc.CreateAttribute("BoxProperties");
            boxPropAttribute.Value = packProperties.Box.Guid.ToString();
            xmlPackProperties.Attributes.Append(boxPropAttribute);
            // box orientation
            XmlAttribute orientationAttribute = xmlDoc.CreateAttribute("Orientation");
            orientationAttribute.Value = HalfAxis.ToString( packProperties.BoxOrientation );
            xmlPackProperties.Attributes.Append(orientationAttribute);
            // arrangement
            XmlAttribute arrAttribute = xmlDoc.CreateAttribute("Arrangement");
            arrAttribute.Value = packProperties.Arrangement.ToString();
            xmlPackProperties.Attributes.Append(arrAttribute);
            // wrapper
            XmlElement wrapperElt = xmlDoc.CreateElement("Wrapper");
            xmlPackProperties.AppendChild(wrapperElt);

            PackWrapper packWrapper = packProperties.Wrap;
            SaveWrapper(packWrapper as WrapperPolyethilene, wrapperElt, xmlDoc);
            SaveWrapper(packWrapper as WrapperPaper, wrapperElt, xmlDoc);
            SaveWrapper(packWrapper as WrapperCardboard, wrapperElt, xmlDoc);

            // outer dimensions
            if (packProperties.HasForcedOuterDimensions)
            {
                XmlAttribute outerDimAttribute = xmlDoc.CreateAttribute("OuterDimensions");
                outerDimAttribute.Value = packProperties.OuterDimensions.ToString();
                xmlPackProperties.Attributes.Append(outerDimAttribute);
            }
        }
 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");
 }
Exemple #16
0
        public Box(uint pickId, PackProperties packProperties, BoxPosition bPosition)
        {
            if (!bPosition.IsValid)
                throw new GraphicsException("Invalid BoxPosition: can not create box");
            _pickId = pickId;
            _dim[0] = packProperties.Length;
            _dim[1] = packProperties.Width;
            _dim[2] = packProperties.Height;

            _colors = new Color[]
            {
                Color.Chocolate, Color.Chocolate, Color.Chocolate, Color.Chocolate, Color.Chocolate, Color.Chocolate
            };
            // set position
            Position = bPosition.Position;
            // set direction length
            LengthAxis = HalfAxis.ToVector3D(bPosition.DirectionLength);
            // set direction width
            WidthAxis = HalfAxis.ToVector3D(bPosition.DirectionWidth);
        }