Exemple #1
0
        private static Tuple <Dimension, Dimension> GetNormalizedShapeDimension(ICutShape shape)
        {
            var shapeArea = shape.Area;

            if (shapeArea.Width >= shapeArea.Height)
            {
                return(new Tuple <Dimension, Dimension>(shapeArea.Width, shapeArea.Height));
            }
            else
            {
                return(new Tuple <Dimension, Dimension>(shapeArea.Height, shapeArea.Width));
            }
        }
Exemple #2
0
        private static ICutShape GetLargestShape(ICollection <ICutShape> shapes)
        {
            Debug.Assert(shapes.Count > 0);

            ICutShape largestShape          = null;
            Dimension largestShapeDimension = new Dimension(0, DimensionUnits.Inch);

            foreach (var shape in shapes)
            {
                var shapeDimension = GetNormalizedShapeDimension(shape).Item1; // First dimension is always largest.
                if (shapeDimension > largestShapeDimension)
                {
                    largestShape          = shape;
                    largestShapeDimension = shapeDimension;
                }
            }

            return(largestShape);
        }
Exemple #3
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);
        }