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)); } }
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); }
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); }