示例#1
0
        public static HCylLayout BuildLayout(Packable packable
                                             , IContainer container
                                             , ConstraintSetAbstract constraintSet
                                             , string patternName, bool swapped)
        {
            if (!(packable is CylinderProperties cylProperties))
            {
                throw new Exception("Invalid type!");
            }

            // get pattern by name
            var pattern = HCylLoadPattern.PatternByName(patternName);

            if (null == pattern)
            {
                return(null);
            }

            var layout = new HCylLayout(
                cylProperties.Diameter
                , cylProperties.Height
                , container.GetStackingDimensions(constraintSet)
                , pattern.Name
                , swapped)
            {
                Offset = container.GetOffset(constraintSet)
            };

            pattern.GetDimensions(layout, constraintSet.OptGlobMaxNumber(packable), out double actualLength, out double actualWidth);
            pattern.Generate(layout, constraintSet.OptGlobMaxNumber(packable), actualLength, actualWidth, constraintSet.OptMaxHeight.Value);
            return(layout);
        }
示例#2
0
        public override void Generate(HCylLayout layout, OptInt maxCount, double actualLength, double actualWidth, double maxHeight)
        {
            layout.Clear();

            double palletLength = GetStackingLength(layout);
            double palletWidth  = GetStackingWidth(layout);
            double radius       = layout.CylRadius;
            double diameter     = layout.CylDiameter;
            double length       = layout.CylLength;

            int sizeX = Convert.ToInt32(Math.Floor(palletLength / layout.CylLength));
            int sizeY = Convert.ToInt32(Math.Floor(palletWidth / layout.CylDiameter));

            double offsetX = 0.5 * (palletLength - actualLength);
            double offsetY = 0.5 * (palletWidth - actualWidth);
            double offsetZ = radius;

            int iLayer = 0;

            while (true)
            {
                // max height reached ?
                if ((iLayer + 1) * diameter + offsetZ > maxHeight)
                {
                    layout.LimitReached = Limit.MAXHEIGHTREACHED;
                    return;
                }

                for (int j = 0; j < sizeY; ++j)
                {
                    for (int i = 0; i < sizeX; ++i)
                    {
                        AddPosition(
                            layout
                            , new CylPosition(
                                new Vector3D(
                                    offsetX + i * length - 0.5 * length
                                    , offsetY + radius + j * diameter
                                    , offsetZ + iLayer * (diameter + layout.RowSpacing))
                                , HalfAxis.HAxis.AXIS_X_P)
                            );
                        // max number of items reached ?
                        if (maxCount.Activated && layout.Positions.Count >= maxCount.Value)
                        {
                            layout.LimitReached = Limit.MAXNUMBERREACHED;
                            return;
                        }
                    }
                }
                ++iLayer;
            }
        }
示例#3
0
        protected void AddPosition(HCylLayout layout, CylPosition pos)
        {
            Transform3D transfRot = Transform3D.Identity;

            if (layout.Swapped)
            {
                Matrix4D matRot = new Matrix4D(
                    0.0, -1.0, 0.0, 0.0
                    , 1.0, 0.0, 0.0, 0.0
                    , 0.0, 0.0, 1.0, 0.0
                    , 0.0, 0.0, 0.0, 1.0
                    );
                Vector3D vTranslation = new Vector3D(layout.DimContainer.X, 0.0, 0.0);
                matRot.M14 = vTranslation[0];
                matRot.M24 = vTranslation[1];
                matRot.M34 = vTranslation[2];
                transfRot  = new Transform3D(matRot);
            }
            layout.Positions.Add(pos.Transform(Transform3D.Translation(layout.Offset) * transfRot));
        }
示例#4
0
        public virtual void GetDimensions(HCylLayout layout, OptInt maxCount, out double length, out double width)
        {
            // using XP direction
            int noX = Convert.ToInt32(Math.Floor(GetStackingLength(layout) / layout.CylLength)) - 1;
            int noY = Convert.ToInt32(Math.Floor(GetStackingWidth(layout) / (2.0 * layout.CylRadius)));

            if (maxCount.Activated && maxCount.Value < noX * (noY - 1))
            {
                if (maxCount.Value < noX)
                {
                    noX = maxCount.Value;
                    noY = 1;
                }
                else
                {
                    noY = maxCount.Value / noX + 1;
                }
            }
            length = noX * layout.CylLength;
            width  = 2.0 * noY * layout.CylRadius;
        }
示例#5
0
 internal static Bitmap Draw(HCylLayout cylLayout, CylinderProperties cylProperties, Vector3D dimContainer, Size size, bool selected, bool annotate)
 {
     try
     {
         if (null == cylProperties)
         {
             return(Properties.Resources.QuestionMark);
         }
         Graphics3DImage graphics = new Graphics3DImage(size)
         {
             MarginPercentage = 0.05
         };
         using (var solViewer = new ViewerHCylLayout(cylLayout))
         { solViewer.Draw(graphics, cylProperties, dimContainer.Z, selected, annotate); }
         return(graphics.Bitmap);
     }
     catch (Exception ex)
     {
         _log.Error(ex.ToString());
         return(Properties.Resources.QuestionMark);
     }
 }
示例#6
0
        public static List <HCylLayout> BuildLayouts(
            Packable packable
            , IContainer container
            , ConstraintSetAbstract constraintSet)
        {
            var layouts = new List <HCylLayout>();

            if (packable is CylinderProperties cylProperties)
            {
                // loop through patterns
                foreach (var pattern in HCylLoadPattern.Patterns)
                {
                    // loop through directions
                    for (int iDir = 0; iDir < (pattern.CanBeSwapped ? 2 : 1); ++iDir)
                    {
                        var layout = new HCylLayout(
                            cylProperties.Diameter
                            , cylProperties.Height
                            , container.GetStackingDimensions(constraintSet)
                            , pattern.Name
                            , iDir == 1)
                        {
                            Offset = container.GetOffset(constraintSet)
                        };

                        pattern.GetDimensions(layout, constraintSet.OptGlobMaxNumber(packable), out double actualLength, out double actualWidth);
                        pattern.Generate(layout, constraintSet.OptGlobMaxNumber(packable), actualLength, actualWidth, constraintSet.OptMaxHeight.Value);
                        if (layout.Positions.Count > 0)
                        {
                            layouts.Add(layout);
                        }
                    }
                }
            }
            layouts.Sort(new HCylLayoutComparer());
            return(layouts);
        }
示例#7
0
 public ViewerHCylLayout(HCylLayout cylLayout)
 {
     Layout = cylLayout;
 }
示例#8
0
 protected double GetStackingWidth(HCylLayout layout) => !layout.Swapped ? layout.StackingWidth : layout.StackingLength;
示例#9
0
 public abstract void Generate(HCylLayout layout, OptInt maxCount, double actualLength, double actualWidth, double maxHeight);
 public HCylLayoutItem(HCylLayout layout, bool selected)
 {
     Layout = layout; Selected = selected;
 }
 private Image TryGeneratePatternImage(HCylLayout cylLayout, Size szButtons, bool selected)
 {
     return(HCylLayoutToImage.Draw(cylLayout, Packable as CylinderProperties, cylLayout.DimContainer, szButtons, selected, true));
 }