Exemplo n.º 1
0
        public bool DoesPlacedObjectsOverlap()
        {
            foreach (var container in containers)
            {
                foreach (var object1 in container.PlacedObjects)
                {
                    foreach (var object2 in container.PlacedObjects)
                    {
                        if (object1 != object2)
                        {
                            PlacedObject3D placedObject1 = object1 as PlacedObject3D;
                            PlacedObject3D placedObject2 = object2 as PlacedObject3D;

                            if (placedObject1.Position.X < placedObject2.Position.X + placedObject2.Width &&
                                placedObject1.Position.X + placedObject1.Width > placedObject2.Position.X &&
                                placedObject1.Position.Y > placedObject2.Position.Y + placedObject2.Height &&
                                placedObject1.Position.Y + placedObject1.Height < placedObject2.Position.Y &&
                                placedObject1.Position.Z > placedObject2.Position.Z + placedObject2.Depth &&
                                placedObject1.Position.Z + placedObject1.Depth < placedObject2.Position.Z)
                            {
                                return(true);
                            }
                        }
                    }
                }
            }

            return(false);
        }
Exemplo n.º 2
0
        public IPlacedObject PlaceObject(Object3D objectToPlace, Position3D position)
        {
            PlacedObject3D newObject = new PlacedObject3D(position, objectToPlace.Width, objectToPlace.Height, objectToPlace.Depth);

            PlacedObjects.Add(newObject);

            return(newObject);
        }
 public override void SplitSubcontainer(GuillotineCutSubcontainer3D subcontainer, PlacedObject3D placedObject)
 {
     if ((subcontainer.Height <= subcontainer.Width) && (subcontainer.Height <= subcontainer.Depth))
     {
         if (subcontainer.Width <= subcontainer.Depth)
         {
             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 ((subcontainer.Width <= subcontainer.Height) && (subcontainer.Width <= subcontainer.Depth))
     {
         if (subcontainer.Height <= subcontainer.Depth)
         {
             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 ((subcontainer.Depth <= subcontainer.Height) && (subcontainer.Depth <= subcontainer.Width))
     {
         if (subcontainer.Height <= subcontainer.Width)
         {
             SplitSubcontainerDepthThenVertically(subcontainer, placedObject);
             //Console.WriteLine("{0} {1} {2}", c, a, b);
         }
         else
         {
             SplitSubcontainerDepthThenHorizontally(subcontainer, placedObject);
             //Console.WriteLine("{0} {1} {2}", c, b, a);
         }
     }
 }
Exemplo n.º 4
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);
                }
            }
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
 public abstract void SplitSubcontainer(GuillotineCutSubcontainer3D subcontainer, PlacedObject3D placedObject);
Exemplo n.º 7
0
        public virtual void PlaceObject(Object3D theObject, Position3D position)
        {
            var placedObject = new PlacedObject3D(position, theObject);

            PlacedObjects.Add(placedObject);
        }