Example #1
0
        private void PlaceTheSameBox(BoxQunatityPair boxQuantityPair, int destinationXPos, int destinationYPos, ref int destinationZPos)
        {
            var box = boxQuantityPair.Box;

            _rowOfBoxes.Add(new Box(box.Name, length: box.Length, width: box.Width, height: box.Height,
                                    x: destinationXPos, y: destinationYPos, z: destinationZPos));

            boxQuantityPair.Quantity--;
            destinationZPos           += box.Height;
            _distanceLeftToTheCeiling -= box.Height;
        }
Example #2
0
        private void AddSecondRowBox(BoxQunatityPair boxQuantityPair, Box platform)
        {
            var box = boxQuantityPair.Box;

            _rowOfBoxes.Add(new Box(box.Name, length: box.Length, width: box.Width, height: box.Height,
                                    x: platform.XPos, y: platform.YPos, z: platform.ZPos));

            _distanceLeftToTheCeiling = platform.Height - box.Height;

            boxQuantityPair.Quantity--;

            PutTheSameBoxOnTheTop(boxQuantityPair, platform.XPos, platform.YPos, platform.ZPos + box.Height);
        }
Example #3
0
        private void PutTheSameBoxOnTheTop(BoxQunatityPair boxQuantityPair, int destinationXPos, int destinationYPos, int destinationZPos)
        {
            var isPossibleToPutAnotherOne = true;

            while (isPossibleToPutAnotherOne)
            {
                if (_distanceLeftToTheCeiling > boxQuantityPair.Box.Height &&
                    boxQuantityPair.Quantity > 0 &&
                    boxQuantityPair.Box.Height < boxQuantityPair.Box.Height + destinationZPos)
                {
                    PlaceTheSameBox(boxQuantityPair, destinationXPos, destinationYPos, ref destinationZPos);
                }
                else
                {
                    isPossibleToPutAnotherOne = false;
                }
            }
        }
Example #4
0
        private void PlaceFirstLevelOfBoxes(BoxQunatityPair boxQuantityPair, Container container)
        {
            var box = boxQuantityPair.Box;

            while (box.Length <= FindDistanceLeftToTheWallOfContainer(container) &&
                   boxQuantityPair.Quantity > 0)
            {
                RotateBoxToMatchRowsWidth(box);

                _rowOfBoxes.Add(new Box(box.Name, length: box.Length, width: box.Width, height: box.Height, x: _xo, y: _yo, z: _zo));

                boxQuantityPair.Quantity--;

                _zo += box.Height;
                _distanceLeftToTheCeiling = container.Height - box.Height;

                PutTheSameBoxOnTheTop(boxQuantityPair, _xo, _yo, _zo);

                _xo += box.Length;
                _zo  = 0;
            }
        }
        public PlacingPlanManagerTest()
        {
            boxA = new BoxQunatityPair {
                Box = new Box("A", length: 60, width: 60, height: 200), Quantity = 15
            };
            boxB = new BoxQunatityPair {
                Box = new Box("B", length: 55, width: 60, height: 80), Quantity = 20
            };
            boxC = new BoxQunatityPair {
                Box = new Box("C", length: 20, width: 20, height: 30), Quantity = 40
            };

            containerA = new Container("Name1", length: 400, width: 300, height: 400);

            boxesSet = new List <BoxQunatityPair> {
                boxA, boxB, boxC
            };
            containersSet = new List <Container> {
                containerA
            };

            _PackagingLogicManager = new PlacingPlanManager();
        }
Example #6
0
        private BoxQunatityPair FindTheMostSuitableBoxForThePlatform(List <BoxQunatityPair> boxesSet, Box platform)
        {
            // Box is the most suitable if after its placing, the distance left to the ceiling is minimum

            var             heightLeft         = 100000000000D;
            BoxQunatityPair theMostSuitableBox = null;

            foreach (var boxQuantityPair in boxesSet.Where(b => b.Quantity != 0))
            {
                var boxesInStackQuantity = Math.Floor((double)platform.Height / boxQuantityPair.Box.Height);

                var heightWillBeLeft = Math.Abs(platform.Height - boxesInStackQuantity * boxQuantityPair.Box.Height);

                if (heightWillBeLeft < heightLeft &&
                    boxQuantityPair.Box.Length <= platform.Length - platform.XPos && boxQuantityPair.Box.Width <= platform.Length - platform.XPos &&
                    boxQuantityPair.Box.Length <= platform.Width - platform.YPos + Delta && boxQuantityPair.Box.Width <= platform.Width - platform.YPos + Delta)
                {
                    heightLeft         = heightWillBeLeft;
                    theMostSuitableBox = boxQuantityPair;
                }
            }

            return(theMostSuitableBox);
        }