コード例 #1
0
        private static void PlaceUnit(List <Segment> currentSegments, SkuUnit unitToFit, int sheetLength, int sheetWidth)
        {
            var subProblemUnitsToFit = new List <SkuUnit> {
                unitToFit
            };

            BuildSolution(currentSegments, subProblemUnitsToFit, sheetLength, sheetWidth);
        }
コード例 #2
0
 private bool CanFitSkuUnit(SkuUnit skuUnit)
 {
     return(AssignedUnit == null &&
            Right == null &&
            Below == null &&
            Width >= skuUnit.Width + KerfAbove &&
            Length >= skuUnit.Length + KerfLeft);
 }
コード例 #3
0
 private bool CanFitSkuUnitRotated(SkuUnit skuUnit)
 {
     return(skuUnit.CanRotate &&
            AssignedUnit == null &&
            Right == null &&
            Below == null &&
            Width >= skuUnit.Length + KerfAbove &&
            Length >= skuUnit.Width + KerfAbove);
 }
コード例 #4
0
        public bool TryFitSkuUnit(SkuUnit skuUnit, bool canRotate = true)
        {
            bool fitFound = false;

            if (CanFitSkuUnit(skuUnit))
            {
                fitFound = true;
            }
            else if (canRotate && CanFitSkuUnitRotated(skuUnit))
            {
                skuUnit.Rotate();
                fitFound = true;
            }
            if (fitFound)
            {
                AssignedUnit = skuUnit;
                //see if one dimension is a perfect fit, or if an additional split is required
                if (skuUnit.Length < this.Length + KerfWidth)
                {
                    Right = new Segment()
                    {
                        Length = this.Length - skuUnit.Length - KerfWidth, Width = skuUnit.Width, KerfLeft = KerfWidth
                    }
                }
                ;
                if (skuUnit.Width < this.Width + KerfWidth)
                {
                    Below = new Segment()
                    {
                        Length = this.Length, Width = this.Width - skuUnit.Width - KerfWidth, KerfAbove = KerfWidth
                    }
                }
                ;
            }
            else
            {
                fitFound = ((Right != null && Right.TryFitSkuUnit(skuUnit)) || (Below != null && Below.TryFitSkuUnit(skuUnit)));
            }
            return(fitFound);
        }