Esempio n. 1
0
        protected void SplitSubcontainerHorizontallyThenVertically(GuillotineCutSubcontainer3D subcontainer, PlacedObject3D placedObject)
        {
            var topSubcontainerPosition = new Position3D(subcontainer.X, placedObject.Y2, subcontainer.Z);
            var topSubcontainerSize     = new Cuboid(subcontainer.Width, subcontainer.Height - placedObject.Height, subcontainer.Depth);
            var topSubcontainer         = new GuillotineCutSubcontainer3D(topSubcontainerPosition, topSubcontainerSize.Width, topSubcontainerSize.Height, topSubcontainerSize.Depth);

            var rightSubcontainerPosition = new Position3D(placedObject.X2, subcontainer.Y, subcontainer.Z);
            var rightSubcontainerSize     = new Cuboid(subcontainer.Width - placedObject.Width, placedObject.Height, subcontainer.Depth);
            var rightSubcontainer         = new GuillotineCutSubcontainer3D(rightSubcontainerPosition, rightSubcontainerSize.Width, rightSubcontainerSize.Height, rightSubcontainerSize.Depth);

            var behindSubcontainerPosition = new Position3D(subcontainer.X, subcontainer.Y, placedObject.Z2);
            var behindSubcontainerSize     = new Cuboid(placedObject.Width, placedObject.Height, subcontainer.Depth - placedObject.Depth);
            var behindSubcontainer         = new GuillotineCutSubcontainer3D(behindSubcontainerPosition, behindSubcontainerSize.Width, behindSubcontainerSize.Height, behindSubcontainerSize.Depth);


            // No need to add one ore two dimensional container
            if (topSubcontainer.Width != 0 && topSubcontainer.Height != 0 && topSubcontainer.Depth != 0)
            {
                Subcontainers.Add(topSubcontainer);
            }

            if (rightSubcontainer.Width != 0 && rightSubcontainer.Height != 0 && rightSubcontainer.Depth != 0)
            {
                Subcontainers.Add(rightSubcontainer);
            }

            if (behindSubcontainer.Width != 0 && behindSubcontainer.Height != 0 && behindSubcontainer.Depth != 0)
            {
                Subcontainers.Add(behindSubcontainer);
            }

            Subcontainers.Remove(subcontainer);
        }
Esempio n. 2
0
        protected override SubContainer3D CreateSubcontainer(Position3D position, Cuboid size)
        {
            GuillotineCutSubcontainer3D newSubcontainer = new GuillotineCutSubcontainer3D(position.X, position.Y, position.Z, size.Width, size.Height, size.Depth);

            Subcontainers.Add(newSubcontainer);

            return(newSubcontainer);
        }
Esempio n. 3
0
        public override void SplitSubcontainer(GuillotineCutSubcontainer3D subcontainer, PlacedObject3D placedObject)
        {
            var availableVolumeAboveObject        = (subcontainer.Height - placedObject.Height) * placedObject.Width * placedObject.Depth;
            var availableVolumeOnTheRightOfObject = placedObject.Height * (subcontainer.Width - placedObject.Width) * placedObject.Depth;
            var availableVolumeBehindObject       = placedObject.Height * placedObject.Width * (subcontainer.Depth - placedObject.Depth);

            if ((availableVolumeAboveObject >= availableVolumeOnTheRightOfObject) && (availableVolumeAboveObject >= availableVolumeBehindObject))
            {
                if (availableVolumeOnTheRightOfObject >= availableVolumeBehindObject)
                {
                    SplitSubcontainerVerticallyThenHorizontally(subcontainer, placedObject);
                    //Console.WriteLine("{0} {1} {2}", a, b, c);
                }
                else
                {
                    SplitSubcontainerVerticallyThenDepth(subcontainer, placedObject);
                    //Console.WriteLine("{0} {1} {2}", a, c, b);
                }
            }
            else if ((availableVolumeOnTheRightOfObject >= availableVolumeAboveObject) && (availableVolumeOnTheRightOfObject >= availableVolumeBehindObject))
            {
                if (availableVolumeAboveObject >= availableVolumeBehindObject)
                {
                    SplitSubcontainerHorizontallyThenVertically(subcontainer, placedObject);
                    //Console.WriteLine("{0} {1} {2}", b, a, c);
                }
                else
                {
                    SplitSubcontainerHorizontallyThenDepth(subcontainer, placedObject);
                    //Console.WriteLine("{0} {1} {2}", b, c, a);
                }
            }
            else if ((availableVolumeBehindObject >= availableVolumeAboveObject) && (availableVolumeBehindObject >= availableVolumeOnTheRightOfObject))
            {
                if (availableVolumeAboveObject >= availableVolumeOnTheRightOfObject)
                {
                    SplitSubcontainerDepthThenVertically(subcontainer, placedObject);
                    //Console.WriteLine("{0} {1} {2}", c, a, b);
                }
                else
                {
                    SplitSubcontainerDepthThenHorizontally(subcontainer, placedObject);
                    //Console.WriteLine("{0} {1} {2}", c, b, a);
                }
            }
        }
Esempio n. 4
0
        public override void SplitSubcontainer(GuillotineCutSubcontainer3D subcontainer, PlacedObject3D placedObject)
        {
            var leftoverHeight = subcontainer.Height - placedObject.Height;
            var leftoverWidth  = subcontainer.Width - placedObject.Width;
            var leftoverDepth  = subcontainer.Depth - placedObject.Depth;

            if ((leftoverHeight >= leftoverWidth) && (leftoverHeight >= leftoverDepth))
            {
                if (leftoverWidth >= leftoverDepth)
                {
                    SplitSubcontainerVerticallyThenHorizontally(subcontainer, placedObject);
                    //Console.WriteLine("{0} {1} {2}", a, b, c);
                }
                else
                {
                    SplitSubcontainerVerticallyThenDepth(subcontainer, placedObject);
                    //Console.WriteLine("{0} {1} {2}", a, c, b);
                }
            }
            else if ((leftoverWidth >= leftoverHeight) && (leftoverWidth >= leftoverDepth))
            {
                if (leftoverHeight >= leftoverDepth)
                {
                    SplitSubcontainerHorizontallyThenVertically(subcontainer, placedObject);
                    //Console.WriteLine("{0} {1} {2}", b, a, c);
                }
                else
                {
                    SplitSubcontainerHorizontallyThenDepth(subcontainer, placedObject);
                    //Console.WriteLine("{0} {1} {2}", b, c, a);
                }
            }
            else if ((leftoverDepth >= leftoverHeight) && (leftoverDepth >= leftoverWidth))
            {
                if (leftoverHeight >= leftoverWidth)
                {
                    SplitSubcontainerDepthThenVertically(subcontainer, placedObject);
                    //Console.WriteLine("{0} {1} {2}", c, a, b);
                }
                else
                {
                    SplitSubcontainerDepthThenHorizontally(subcontainer, placedObject);
                    //Console.WriteLine("{0} {1} {2}", c, b, a);
                }
            }
        }
Esempio n. 5
0
 public abstract void SplitSubcontainer(GuillotineCutSubcontainer3D subcontainer, PlacedObject3D placedObject);