Exemple #1
0
        public Tuple <CutRegion, CutRegion> CutHorizontal(Dimension distance)
        {
            if (CutShape != null)
            {
                throw new InvalidOperationException("Cannot cut region with assigned shape.");
            }

            var top    = new CutRegion(CutStock, Top, Left, Width, distance);
            var bottom = new CutRegion(CutStock, Top + distance, Left, Width, Height - distance);

            return(new Tuple <CutRegion, CutRegion>(top, bottom));
        }
Exemple #2
0
        public Tuple <CutRegion, CutRegion> CutVertical(Dimension distance)
        {
            if (CutShape != null)
            {
                throw new InvalidOperationException("Cannot cut region with assigned shape.");
            }

            var left  = new CutRegion(CutStock, Top, Left, distance, Height);
            var right = new CutRegion(CutStock, Top, Left + distance, Width - distance, Height);

            return(new Tuple <CutRegion, CutRegion>(left, right));
        }
Exemple #3
0
#pragma warning disable IDE0051 // Remove unused private members
        private static Tuple <Dimension, Dimension> GetNormalizedRegionDimension(CutRegion region)
#pragma warning restore IDE0051 // Remove unused private members
        {
            if (region.Width >= region.Height)
            {
                return(new Tuple <Dimension, Dimension>(region.Width, region.Height));
            }
            else
            {
                return(new Tuple <Dimension, Dimension>(region.Height, region.Width));
            }
        }
Exemple #4
0
        private static CutRegion GetSmallestContainingCutRegion(ICollection <CutRegion> cutRegions, ICutShape cutShape)
        {
            CutRegion currentCutRegion = null;

            var dimension = GetNormalizedShapeDimension(cutShape);

            foreach (var cutRegion in cutRegions)
            {
                if (cutRegion.Contains(dimension.Item1, dimension.Item2))
                {
                    if (currentCutRegion == null || cutRegion.Area < currentCutRegion.Area)
                    {
                        currentCutRegion = cutRegion;
                    }
                }
            }

            return(currentCutRegion);
        }