protected override SubContainer2D CreateSubcontainer(Position2D position, Rectangle size) { GuillotineCutSubcontainer2D newSubcontainer = new GuillotineCutSubcontainer2D(position.X, position.Y, size.Width, size.Height); Subcontainers.Add(newSubcontainer); return(newSubcontainer); }
public override void SplitSubcontainer(GuillotineCutSubcontainer2D subcontainer, PlacedObject2D placedObject) { if (subcontainer.Height > subcontainer.Width) { SplitSubcontainerVertically(subcontainer, placedObject); } else { SplitSubcontainerHorizontally(subcontainer, placedObject); } }
public override void SplitSubcontainer(GuillotineCutSubcontainer2D subcontainer, PlacedObject2D placedObject) { var leftoverHeight = subcontainer.Height - placedObject.Height; var leftoverWidth = subcontainer.Width - placedObject.Width; if (leftoverHeight > leftoverWidth) { SplitSubcontainerVertically(subcontainer, placedObject); } else { SplitSubcontainerHorizontally(subcontainer, placedObject); } }
public override void SplitSubcontainer(GuillotineCutSubcontainer2D subcontainer, PlacedObject2D placedObject) { var availableAreaAboveObject = (subcontainer.Height - placedObject.Height) * placedObject.Width; var availableAreaOnTheRightOfObject = placedObject.Height * (subcontainer.Width - placedObject.Width); if (availableAreaAboveObject > availableAreaOnTheRightOfObject) { SplitSubcontainerVertically(subcontainer, placedObject); } else { SplitSubcontainerHorizontally(subcontainer, placedObject); } }
protected void SplitSubcontainerHorizontally(GuillotineCutSubcontainer2D subcontainer, PlacedObject2D placedObject) { var topSubcontainerPosition = new Position2D(subcontainer.X, placedObject.Y2); var topSubcontainerSize = new Rectangle(subcontainer.Width, subcontainer.Height - placedObject.Height); var topSubcontainer = new GuillotineCutSubcontainer2D(topSubcontainerPosition, topSubcontainerSize.Width, topSubcontainerSize.Height); var rightSubcontainerPosition = new Position2D(placedObject.X2, subcontainer.Y); var rightSubcontainerSize = new Rectangle(subcontainer.Width - placedObject.Width, placedObject.Height); var rightSubcontainer = new GuillotineCutSubcontainer2D(rightSubcontainerPosition, rightSubcontainerSize.Width, rightSubcontainerSize.Height); // No need to add one dimensional container if (topSubcontainer.Width != 0 && topSubcontainer.Height != 0) { Subcontainers.Add(topSubcontainer); } if (rightSubcontainer.Width != 0 && rightSubcontainer.Height != 0) { Subcontainers.Add(rightSubcontainer); } Subcontainers.Remove(subcontainer); }
public abstract void SplitSubcontainer(GuillotineCutSubcontainer2D subcontainer, PlacedObject2D placedObject);