public override void GenerateLayer(ILayer2D layer, double actualLength, double actualWidth) { layer.Clear(); double palletLength = GetPalletLength(layer); double palletWidth = GetPalletWidth(layer); double boxLength = GetBoxLength(layer); double boxWidth = GetBoxWidth(layer); int sizeX = (int)Math.Floor(palletLength / boxLength); int sizeY = (int)Math.Floor(palletWidth / boxWidth); double offsetX = 0.5 * (palletLength - actualLength); double offsetY = 0.5 * (palletWidth - actualWidth); double spaceX = sizeX > 1 ? (actualLength - sizeX * boxLength) / (sizeX - 1) : 0.0; double spaceY = sizeY > 1 ? (actualWidth - sizeY * boxWidth) / (sizeY - 1) : 0.0; for (int i = 0; i < sizeX; ++i) { for (int j = 0; j < sizeY; ++j) { AddPosition(layer , new Vector2D( offsetX + i * (boxLength + spaceX) , offsetY + j * (boxWidth + spaceY) ) , HalfAxis.HAxis.AXIS_X_P, HalfAxis.HAxis.AXIS_Y_P); } } // set spacing to ZERO i.e. no spacing with column layout layer.UpdateMaxSpace(spaceX, Name); layer.UpdateMaxSpace(spaceY, Name); }
public override void GenerateLayer(ILayer2D layer, double actualLength, double actualWidth) { layer.Clear(); double palletLength = GetPalletLength(layer); double palletWidth = GetPalletWidth(layer); double boxLength = GetBoxLength(layer); double boxWidth = GetBoxWidth(layer); int maxSizeXLength = 0, maxSizeXWidth = 0, maxSizeYLength = 0, maxSizeYWidth = 0; GetSizeXY(boxLength, boxWidth, palletLength, palletWidth , out maxSizeXLength, out maxSizeXWidth, out maxSizeYLength, out maxSizeYWidth); double offsetX = 0.5 * (palletLength - actualLength); double offsetY = 0.5 * (palletWidth - actualWidth); double spaceX = maxSizeXLength + maxSizeXWidth > 1 ? (actualLength - (maxSizeXLength * boxLength + maxSizeXWidth * boxWidth)) / (maxSizeXLength + maxSizeXWidth - 1) : 0.0; double spaceYLength = maxSizeYLength > 1 ? (actualWidth - maxSizeYLength * boxWidth) / (maxSizeYLength - 1) : 0.0; double spaceYWidth = maxSizeYWidth > 1 ? (actualWidth - maxSizeYWidth * boxLength) / (maxSizeYWidth - 1) : 0.0; for (int i = 0; i < maxSizeXLength / 2; ++i) { for (int j = 0; j < maxSizeYLength; ++j) { AddPosition( layer , new Vector2D( offsetX + i * (boxLength + spaceX) , offsetY + j * (boxWidth + spaceYLength)) , HalfAxis.HAxis.AXIS_X_P, HalfAxis.HAxis.AXIS_Y_P); AddPosition( layer , new Vector2D( palletLength - offsetX - i * (boxLength + spaceX) , palletWidth - offsetY - j * (boxWidth + spaceYLength)) , HalfAxis.HAxis.AXIS_X_N, HalfAxis.HAxis.AXIS_Y_N); } } for (int i = 0; i < maxSizeXWidth; ++i) { for (int j = 0; j < maxSizeYWidth; ++j) { AddPosition( layer , new Vector2D( offsetX + maxSizeXLength / 2 * (boxLength + spaceX) + i * (boxWidth + spaceX) + boxWidth , offsetY + j * (boxLength + spaceYWidth)) , HalfAxis.HAxis.AXIS_Y_P, HalfAxis.HAxis.AXIS_X_N); } } layer.UpdateMaxSpace(spaceX, Name); layer.UpdateMaxSpace(spaceYLength, Name); layer.UpdateMaxSpace(spaceYWidth, Name); }
public override void GenerateLayer(ILayer2D layer, double actualLength, double actualWidth) { // initialization layer.Clear(); double palletLength = GetPalletLength(layer); double palletWidth = GetPalletWidth(layer); double boxLength = GetBoxLength(layer); double boxWidth = GetBoxWidth(layer); // compute optimal layout by evaluating all spirale configurations int sizeX_area1 = 0, sizeY_area1 = 0, sizeX_area2 = 0, sizeY_area2 = 0; GetOptimalSizesXY(boxLength, boxWidth, palletLength, palletWidth , out sizeX_area1, out sizeY_area1, out sizeX_area2, out sizeY_area2); // compute offsets double offsetX = 0.5 * (palletLength - actualLength); double offsetY = 0.5 * (palletWidth - actualWidth); // area1 for (int i = 0; i < sizeX_area1; ++i) { for (int j = 0; j < sizeY_area1; ++j) { AddPosition(layer , new Vector2D(offsetX + i * boxLength, offsetY + j * boxWidth) , HalfAxis.HAxis.AXIS_X_P, HalfAxis.HAxis.AXIS_Y_P); AddPosition(layer , new Vector2D(palletLength - offsetX - i * boxLength, palletWidth - offsetY - j * boxWidth) , HalfAxis.HAxis.AXIS_X_N, HalfAxis.HAxis.AXIS_Y_N); } } double spaceX_Area1 = actualLength - 2.0 * sizeX_area1 * boxLength; double spaceY_Area1 = actualWidth - 2.0 * sizeY_area1 * boxWidth; // area2 for (int i = 0; i < sizeX_area2; ++i) { for (int j = 0; j < sizeY_area2; ++j) { AddPosition(layer , new Vector2D(palletLength - offsetX - i * boxWidth, offsetY + j * boxLength) , HalfAxis.HAxis.AXIS_Y_P, HalfAxis.HAxis.AXIS_X_N); AddPosition(layer , new Vector2D(offsetX + i * boxWidth, palletWidth - offsetY - j * boxLength) , HalfAxis.HAxis.AXIS_Y_N, HalfAxis.HAxis.AXIS_X_P); } } double spaceX_Area2 = actualLength - 2.0 * sizeX_area2 * boxWidth; double spaceY_Area2 = actualWidth - 2.0 * sizeY_area2 * boxLength; double spaceX = spaceX_Area1 > 0 ? spaceX_Area1 : spaceX_Area2; double spaceY = spaceY_Area1 > 0 ? spaceY_Area1 : spaceY_Area2; layer.UpdateMaxSpace(Math.Min(spaceX, spaceY), Name); }
public override void GenerateLayer(ILayer2D layer, double actualLength, double actualWidth) { layer.Clear(); double palletLength = GetPalletLength(layer); double palletWidth = GetPalletWidth(layer); double boxLength = GetBoxLength(layer); double boxWidth = GetBoxWidth(layer); int maxSizeXLength = 0, maxSizeXWidth = 0, maxSizeYLength = 0, maxSizeYWidth = 0; int fillSizeXLength = 0, fillSizeYLength = 0, fillSizeXWidth = 0, fillSizeYWidth = 0; GetSizeXY(boxLength, boxWidth, palletLength, palletWidth , out maxSizeXLength, out maxSizeYLength, out maxSizeXWidth, out maxSizeYWidth , out fillSizeXLength, out fillSizeYLength, out fillSizeXWidth, out fillSizeYWidth); double offsetX = 0.5 * (palletLength - actualLength); double offsetY = 0.5 * (palletWidth - actualWidth); double l1 = Math.Max(maxSizeXLength * boxLength, fillSizeXLength * boxWidth); double l2 = Math.Max(maxSizeXWidth * boxWidth, fillSizeXWidth * boxLength); double remainingSpaceX = actualLength - l1 - l2; l1 = l1 + 0.5 * remainingSpaceX; l2 = l2 + 0.5 * remainingSpaceX; double spaceXLength = (l1 - maxSizeXLength * boxLength) / ((double)maxSizeXLength - 0.5); double spaceXWidth = (l2 - maxSizeXWidth * boxWidth) / ((double)maxSizeXWidth - 0.5); double spaceYLength = maxSizeYLength > 1 ? (actualWidth - maxSizeYLength * boxWidth - fillSizeYLength * boxLength) / (maxSizeYLength + fillSizeYLength - 1) : 0.0; double spaceYWidth = maxSizeYWidth > 1 ? (actualWidth - maxSizeYWidth * boxLength - fillSizeYWidth * boxWidth) / (maxSizeYWidth + fillSizeYWidth - 1) : 0.0; if (1 == maxSizeYLength % 2) { // LENGTH for (int i = 0; i < maxSizeXLength; ++i) { for (int j = 0; j < maxSizeYLength; ++j) { AddPosition( layer , new Vector2D( offsetX + i * (boxLength + spaceXLength) , offsetY + j * (boxWidth + spaceYLength)) , HalfAxis.HAxis.AXIS_X_P, HalfAxis.HAxis.AXIS_Y_P); } } } else { // LENGTH for (int i = 0; i < maxSizeXLength; ++i) { for (int j = 0; j < maxSizeYLength / 2; ++j) { AddPosition( layer , new Vector2D( offsetX + i * (boxLength + spaceXLength) , offsetY + j * (boxWidth + spaceYLength)) , HalfAxis.HAxis.AXIS_X_P, HalfAxis.HAxis.AXIS_Y_P); } } for (int i = 0; i < maxSizeXLength; ++i) { for (int j = maxSizeYLength / 2; j < maxSizeYLength; ++j) { AddPosition( layer , new Vector2D( offsetX + i * (boxLength + spaceXLength) , offsetY + j * (boxWidth + spaceYLength) + (fillSizeYLength > 0 ? fillSizeYLength * (spaceYLength + boxLength) : 0.0)) , HalfAxis.HAxis.AXIS_X_P, HalfAxis.HAxis.AXIS_Y_P); } } double spaceXFill = fillSizeXLength > 1 ? (l1 - fillSizeXLength * boxWidth) / ((double)fillSizeXLength - 0.5) : 0; layer.UpdateMaxSpace(spaceXFill, Name); for (int i = 0; i < fillSizeXLength; ++i) { for (int j = 0; j < fillSizeYLength; ++j) { AddPosition( layer , new Vector2D( offsetX + boxWidth + i * (boxWidth + spaceXFill) , offsetY + (maxSizeYLength / 2) * (boxWidth + spaceYLength) + j * boxLength) , HalfAxis.HAxis.AXIS_Y_P, HalfAxis.HAxis.AXIS_X_N ); } } } // WIDTH if (1 == maxSizeYWidth % 2) { for (int i = 0; i < maxSizeXWidth; ++i) { for (int j = 0; j < maxSizeYWidth; ++j) { AddPosition( layer , new Vector2D( offsetX + maxSizeXLength * (boxLength + spaceXLength) + i * (boxWidth + spaceXWidth) + boxWidth , offsetY + j * (boxLength + spaceYWidth)) , HalfAxis.HAxis.AXIS_Y_P, HalfAxis.HAxis.AXIS_X_N); } } } else { for (int i = 0; i < maxSizeXWidth; ++i) { for (int j = 0; j < maxSizeYWidth / 2; ++j) { AddPosition( layer , new Vector2D( offsetX + actualLength - (i) * (boxWidth + spaceXWidth) /*- boxWidth*/ , offsetY + j * (boxLength + spaceYWidth)) , HalfAxis.HAxis.AXIS_Y_P, HalfAxis.HAxis.AXIS_X_N); } } for (int i = 0; i < maxSizeXWidth; ++i) { for (int j = maxSizeYWidth / 2; j < maxSizeYWidth; ++j) { AddPosition( layer , new Vector2D( offsetX + actualLength - (i) * (boxWidth + spaceXWidth) /*- boxWidth*/ , offsetY + j * (boxLength + spaceYWidth) + (fillSizeYWidth > 0 ? fillSizeYWidth * (boxWidth + spaceYWidth) : 0.0)) , HalfAxis.HAxis.AXIS_Y_P, HalfAxis.HAxis.AXIS_X_N); } } double spaceXFill = fillSizeXWidth > 1 ? (l2 - fillSizeXWidth * boxLength) / ((double)fillSizeXWidth - 0.5) : 0.0; layer.UpdateMaxSpace(spaceXFill, Name); for (int i = 0; i < fillSizeXWidth; ++i) { for (int j = 0; j < fillSizeYWidth; ++j) { AddPosition( layer , new Vector2D( offsetX + actualLength - (i + 1) * (boxLength + spaceXFill) , offsetY + (maxSizeYWidth / 2) * (boxLength + spaceYWidth) + j * boxWidth) , HalfAxis.HAxis.AXIS_X_P, HalfAxis.HAxis.AXIS_Y_P ); } } } // maximum space layer.UpdateMaxSpace(spaceYLength, Name); layer.UpdateMaxSpace(spaceYWidth, Name); }
public override void GenerateLayer(ILayer2D layer, double actualLength, double actualWidth) { layer.Clear(); double palletLength = GetPalletLength(layer); double palletWidth = GetPalletWidth(layer); double boxLength = GetBoxLength(layer); double boxWidth = GetBoxWidth(layer); GetSizeXY(boxLength, boxWidth, palletLength, palletWidth , out int iStep, out int maxSizeXLength, out int maxSizeXWidth, out int maxSizeYLength, out int maxSizeYWidth); double offsetX = 0.5 * (palletLength - actualLength); double offsetY = 0.5 * (palletWidth - actualWidth); for (int i = 0; i < iStep; ++i) { double spaceX = maxSizeXLength + maxSizeXWidth > 1 ? (actualLength - maxSizeXLength * boxLength - maxSizeXWidth * boxWidth) / (maxSizeXLength + maxSizeXWidth - 1) : 0.0; double spaceY = maxSizeYLength + maxSizeYWidth > 1 ? (actualWidth - maxSizeYWidth * boxWidth - maxSizeYLength * boxLength) / (maxSizeYLength + maxSizeYWidth - 1) : 0.0; double xBase = offsetX + i * (boxLength + spaceX); double yBase = offsetY + i * (boxWidth + spaceY); // first box AddPosition( layer , new Vector2D(xBase + boxWidth, yBase) , HalfAxis.HAxis.AXIS_Y_P, HalfAxis.HAxis.AXIS_X_N); // along X for (int ix = 0; ix < iStep - 1 - i; ++ix) { AddPosition( layer , new Vector2D( xBase + boxWidth + spaceX + ix * (boxLength + spaceX) , yBase) , HalfAxis.HAxis.AXIS_X_P, HalfAxis.HAxis.AXIS_Y_P); } int maxY = (int)Math.Floor(actualWidth / boxWidth); double ySpaceNew = maxY > 1 ? (actualWidth - boxWidth * maxY) / (maxY - 1) : 0; for (int ix = iStep - 1 - i; ix < maxSizeXLength - i && i < iStep - 1; ++ix) { AddPosition( layer , new Vector2D( xBase + boxWidth + spaceX + ix * (boxLength + spaceX) , offsetY + i * (boxWidth + ySpaceNew)) , HalfAxis.HAxis.AXIS_X_P, HalfAxis.HAxis.AXIS_Y_P); } // along Y for (int iy = 0; iy < iStep - 1 - i; ++iy) { AddPosition( layer , new Vector2D( xBase , yBase + boxLength + spaceY + iy * (boxWidth + spaceY)) , HalfAxis.HAxis.AXIS_X_P, HalfAxis.HAxis.AXIS_Y_P); } int maxX = (int)Math.Floor(actualLength / boxLength); double xSpaceNew = maxX > 1 ? (actualLength - boxLength * maxX) / (maxX - 1) : 0; for (int iy = iStep - 1 - i; iy < maxSizeYWidth - i && i < iStep - 1; ++iy) { AddPosition( layer , new Vector2D( offsetX + i * (boxLength + xSpaceNew) , yBase + boxLength + spaceY + iy * (boxWidth + spaceY)) , HalfAxis.HAxis.AXIS_X_P, HalfAxis.HAxis.AXIS_Y_P); } // set spacing layer.UpdateMaxSpace(spaceX, Name); layer.UpdateMaxSpace(spaceY, Name); layer.UpdateMaxSpace(Math.Abs(boxLength - boxWidth), Name); } }
public override void GenerateLayer(ILayer2D layer, double actualLength, double actualWidth) { layer.Clear(); double palletLength = GetPalletLength(layer); double palletWidth = GetPalletWidth(layer); double boxLength = GetBoxLength(layer); double boxWidth = GetBoxWidth(layer); double spiraleLength = boxLength + boxWidth; GetSizeXY(boxLength, boxWidth, palletLength, palletWidth , out int noSpiraleX, out int noSpiraleY , out int noArea2X, out int noArea2Y, out bool area2LengthAligned , out int noArea3X, out int noArea3Y, out bool area3LengthAligned , out bool area2First); Vector2D offset = GetOffset(layer, actualLength, actualWidth); // spirale for (int i = 0; i < noSpiraleX; ++i) { for (int j = 0; j < noSpiraleY; ++j) { double xBase = i * spiraleLength; double yBase = j * spiraleLength; AddPosition( layer , new Vector2D(xBase, yBase) + offset , HalfAxis.HAxis.AXIS_X_P, HalfAxis.HAxis.AXIS_Y_P); AddPosition( layer , new Vector2D(xBase + boxLength + boxWidth, yBase) + offset , HalfAxis.HAxis.AXIS_Y_P, HalfAxis.HAxis.AXIS_X_N); AddPosition( layer , new Vector2D(xBase + boxLength + boxWidth, yBase + boxLength + boxWidth) + offset , HalfAxis.HAxis.AXIS_X_N, HalfAxis.HAxis.AXIS_Y_N); AddPosition( layer , new Vector2D(xBase, yBase + boxLength + boxWidth) + offset , HalfAxis.HAxis.AXIS_Y_N, HalfAxis.HAxis.AXIS_X_P); } } layer.UpdateMaxSpace(Math.Abs(boxLength - boxWidth), Name); if (area2First) { // area 2 double width = Math.Max(noArea2Y * (area2LengthAligned ? boxWidth : boxLength), noSpiraleY * spiraleLength + noArea3Y * (area3LengthAligned ? boxWidth : boxLength)); double ySpace = 0.0; if (noArea2Y > 1) { ySpace = Math.Floor((width - noArea2Y * (area2LengthAligned ? boxWidth : boxLength)) / (noArea2Y - 1)); } double xStart = Math.Max( noSpiraleX * spiraleLength , noArea3X * (area3LengthAligned ? boxLength : boxWidth)); GenerateRectanglePositions(layer, offset, boxLength, boxWidth , noArea2X, noArea2Y , xStart, 0.0, 0.0, ySpace, area2LengthAligned); // area 3 GenerateRectanglePositions(layer, offset, boxLength, boxWidth, noArea3X, noArea3Y , 0.0, noSpiraleY * spiraleLength, 0.0, 0.0, area3LengthAligned); } else { // area 3 double length = Math.Max(noArea3X * (area3LengthAligned ? boxLength : boxWidth), noSpiraleX * spiraleLength + noArea2X * (area2LengthAligned ? boxLength : boxWidth)); double xSpace = 0.0; if (noArea3X > 1) { xSpace = Math.Floor((length - noArea3X * (area3LengthAligned ? boxLength : boxWidth)) / (noArea3X - 1)); } double yStart = Math.Max( noSpiraleY * spiraleLength , noArea2Y * (area2LengthAligned ? boxWidth : boxLength)); GenerateRectanglePositions(layer, offset, boxLength, boxWidth, noArea3X, noArea3Y , 0.0, yStart, xSpace, 0.0, area3LengthAligned); // area 2 GenerateRectanglePositions(layer, offset, boxLength, boxWidth, noArea2X, noArea2Y , noSpiraleX * spiraleLength, 0.0, 0.0, 0.0, area2LengthAligned); } }
public override void GenerateLayer(ILayer2D layer, double actualLength, double actualWidth) { layer.Clear(); double palletLength = GetPalletLength(layer); double palletWidth = GetPalletWidth(layer); double boxLength = GetBoxLength(layer); double boxWidth = GetBoxWidth(layer); GetOptimalSizeArea1(boxLength, boxWidth, palletLength, palletWidth, out int sizeX_area1, out int sizeY_area1); GetSizeXY(boxLength, boxWidth, palletLength, palletWidth, sizeX_area1, sizeY_area1 , out int sizeX_area2, out int sizeY_area2, out int sizeX_area3, out int sizeY_area3); // compute offsets double offsetX = 0.5 * (palletLength - actualLength); double offsetY = 0.5 * (palletWidth - actualWidth); // compute spaces double spaceX_area1 = (actualLength - (boxWidth * sizeX_area1 + boxLength * sizeX_area3)) / (sizeX_area1 + sizeX_area3 > 1 ? (sizeX_area1 + sizeX_area3 - 1) : 1.0); double spaceX_area2 = (actualLength - sizeX_area2 * boxLength) / (sizeX_area2 > 1 ?(sizeX_area2 - 1) : 1.0); double spaceX_area3 = spaceX_area1; double spaceY_area1 = 0.0, spaceY_area2 = 0.0, spaceY_area3 = 0.0; if (sizeY_area1 * boxLength > sizeY_area3 * boxWidth) { spaceY_area1 = (actualWidth - sizeY_area1 * boxLength - sizeY_area2 * boxWidth) / (sizeY_area1 + sizeY_area2 > 1 ?(sizeY_area1 + sizeY_area2 - 1) : 1.0); spaceY_area2 = spaceY_area1; spaceY_area3 = (sizeY_area1 * (boxLength + spaceY_area1) - sizeY_area3 * boxWidth) / (0 != sizeY_area3 ? sizeY_area3 : 1.0); } else { spaceY_area3 = (actualWidth - (sizeY_area2 + sizeY_area3) * boxWidth) / (sizeY_area2 + sizeY_area3 > 1 ? (sizeY_area2 + sizeY_area3 - 1) : 1.0); spaceY_area2 = spaceY_area3; spaceY_area1 = (sizeY_area3 * (boxWidth + spaceY_area3) - sizeY_area1 * boxLength) / (sizeY_area1 > 0 ? sizeY_area1 : 1.0); } // area1 for (int i = 0; i < sizeX_area1; ++i) { for (int j = 0; j < sizeY_area1; ++j) { AddPosition(layer , new Vector2D( offsetX + boxWidth + i * (boxWidth + spaceX_area1) , offsetY + j * (boxLength + spaceY_area1)) , HalfAxis.HAxis.AXIS_Y_P, HalfAxis.HAxis.AXIS_X_N); } } // area2 for (int i = 0; i < sizeX_area2; ++i) { for (int j = 0; j < sizeY_area2; ++j) { AddPosition(layer , new Vector2D( offsetX + i * (boxLength + spaceX_area2) , actualWidth + offsetY - (j + 1) * boxWidth - j * spaceY_area2) , HalfAxis.HAxis.AXIS_X_P, HalfAxis.HAxis.AXIS_Y_P); } } // area3 for (int i = 0; i < sizeX_area3; ++i) { for (int j = 0; j < sizeY_area3; ++j) { AddPosition(layer , new Vector2D( offsetX + sizeX_area1 * (boxWidth + spaceX_area1) + i * (boxLength + spaceX_area3) , offsetY + j * (boxWidth + spaceY_area3)) , HalfAxis.HAxis.AXIS_X_P, HalfAxis.HAxis.AXIS_Y_P); } } layer.UpdateMaxSpace(spaceX_area1, Name); layer.UpdateMaxSpace(spaceY_area1, Name); layer.UpdateMaxSpace(spaceX_area2, Name); layer.UpdateMaxSpace(spaceY_area2, Name); layer.UpdateMaxSpace(spaceX_area3, Name); layer.UpdateMaxSpace(spaceY_area3, Name); }
public override void GenerateLayer(ILayer2D layer, double actualLength, double actualWidth) { // initialization layer.Clear(); double palletLength = GetPalletLength(layer); double palletWidth = GetPalletWidth(layer); double boxLength = GetBoxLength(layer); double boxWidth = GetBoxWidth(layer); GetOptimalSizesXY( boxLength, boxWidth, palletLength, palletWidth , out int sizeX_area1, out int sizeY_area1 , out int sizeX_area2, out int sizeY_area2 , out int sizeX_area3, out int sizeY_area3 , out int dir_area3); // compute offsets double offsetX = 0.5 * (palletLength - actualLength); double offsetY = 0.5 * (palletWidth - actualWidth); // area1 for (int i = 0; i < sizeX_area1; ++i) { for (int j = 0; j < sizeY_area1; ++j) { AddPosition(layer , new Vector2D(offsetX + i * boxLength, offsetY + j * boxWidth) , HalfAxis.HAxis.AXIS_X_P, HalfAxis.HAxis.AXIS_Y_P); AddPosition(layer , new Vector2D(palletLength - offsetX - i * boxLength, palletWidth - offsetY - j * boxWidth) , HalfAxis.HAxis.AXIS_X_N, HalfAxis.HAxis.AXIS_Y_N); } } double spaceX_area1 = actualLength - 2 * sizeX_area1 * boxLength; double spaceY_area1 = actualWidth - 2 * sizeY_area1 * boxWidth; // area2 for (int i = 0; i < sizeX_area2; ++i) { for (int j = 0; j < sizeY_area2; ++j) { AddPosition(layer , new Vector2D(palletLength - offsetX - i * boxWidth, offsetY + j * boxLength) , HalfAxis.HAxis.AXIS_Y_P, HalfAxis.HAxis.AXIS_X_N); AddPosition(layer , new Vector2D(offsetX + i * boxWidth, palletWidth - offsetY - j * boxLength) , HalfAxis.HAxis.AXIS_Y_N, HalfAxis.HAxis.AXIS_X_P); } } double spaceX_area2 = actualLength - 2 * sizeX_area2 * boxWidth; double spaceY_area2 = actualWidth - 2 * sizeY_area2 * boxLength; // area3 for (int i = 0; i < sizeX_area3; ++i) { for (int j = 0; j < sizeY_area3; ++j) { if (dir_area3 == 0) { AddPosition(layer , new Vector2D( offsetX + 0.5 * (actualLength - sizeX_area3 * boxLength) + i * boxLength , offsetY + 0.5 * (actualWidth - sizeY_area3 * boxWidth) + j * boxWidth ) , HalfAxis.HAxis.AXIS_X_P, HalfAxis.HAxis.AXIS_Y_P); } else { AddPosition(layer , new Vector2D( offsetX + 0.5 * (actualLength - sizeX_area3 * boxWidth) + (i + 1) * boxWidth , offsetY + 0.5 * (actualWidth - sizeY_area3 * boxLength) + j * boxLength ) , HalfAxis.HAxis.AXIS_Y_P, HalfAxis.HAxis.AXIS_X_N); } } } double spaceX_area3 = 0.0, spaceY_area3 = 0.0; if (dir_area3 == 0) { spaceX_area3 = 0.5 * (actualLength - sizeX_area3 * boxLength - 2.0 * (spaceX_area1 > 0 ? sizeX_area1 * boxLength : sizeX_area2 * boxWidth)); spaceY_area3 = 0.5 * (actualWidth - sizeY_area3 * boxWidth - 2.0 * (spaceY_area1 > 0 ? sizeY_area1 * boxWidth : sizeY_area2 * boxLength)); } else { spaceX_area3 = 0.5 * (actualLength - sizeX_area3 * boxWidth - 2.0 * (spaceX_area1 > 0 ? sizeX_area1 * boxLength : sizeX_area2 * boxWidth)); spaceY_area3 = 0.5 * (actualWidth - sizeY_area3 * boxLength - 2.0 * (spaceY_area1 > 0 ? sizeY_area1 * boxWidth : sizeY_area2 * boxLength)); } // set spacing layer.UpdateMaxSpace(spaceX_area3, Name); layer.UpdateMaxSpace(spaceY_area3, Name); }
public override void GenerateLayer(ILayer2D layer, double actualLength, double actualWidth) { layer.Clear(); double palletLength = GetPalletLength(layer); double palletWidth = GetPalletWidth(layer); double boxLength = GetBoxLength(layer); double boxWidth = GetBoxWidth(layer); GetOptimalSizeXY(boxLength, boxWidth, palletLength, palletWidth, out int sizeX_area1, out int sizeY_area1, out int sizeX_area2, out int sizeY_area2, out int sizeX_area3, out int sizeY_area3, out int sizeX_area4, out int sizeY_area4); Vector2D offset = GetOffset(layer, actualLength, actualWidth); double spaceX12 = (actualLength - sizeX_area1 * boxLength - sizeX_area2 * boxWidth) / (sizeX_area1 + sizeX_area2 - 1); double spaceX34 = (actualLength - sizeX_area3 * boxLength - sizeX_area4 * boxWidth) / (sizeX_area3 + sizeX_area4 - 1); double spaceY14 = (actualWidth - sizeY_area1 * boxWidth - sizeY_area4 * boxLength) / (sizeY_area1 + sizeY_area4 - 1); double spaceY23 = (actualWidth - sizeY_area2 * boxLength - sizeY_area3 * boxWidth) / (sizeY_area2 + sizeY_area3 - 1); // area 1 for (int i = 0; i < sizeX_area1; ++i) { for (int j = 0; j < sizeY_area1; ++j) { LogPosition(new Vector2D( offset.X + i * boxLength, offset.Y + j * boxWidth) , HalfAxis.HAxis.AXIS_X_P, HalfAxis.HAxis.AXIS_Y_P); AddPosition( layer , new Vector2D( offset.X + i * boxLength, offset.Y + j * boxWidth) , HalfAxis.HAxis.AXIS_X_P, HalfAxis.HAxis.AXIS_Y_P); } } // area 2 for (int i = 0; i < sizeX_area2; ++i) { for (int j = 0; j < sizeY_area2; ++j) { LogPosition(new Vector2D( offset.X + actualLength - i * boxWidth, offset.Y + j * boxLength) , HalfAxis.HAxis.AXIS_Y_P, HalfAxis.HAxis.AXIS_X_N); AddPosition( layer , new Vector2D( offset.X + actualLength - i * boxWidth, offset.Y + j * boxLength) , HalfAxis.HAxis.AXIS_Y_P, HalfAxis.HAxis.AXIS_X_N); } } // area 3 for (int i = 0; i < sizeX_area3; ++i) { for (int j = 0; j < sizeY_area3; ++j) { LogPosition(new Vector2D( actualLength + offset.X - boxLength - i * boxLength, actualWidth + offset.Y - boxWidth - j * boxWidth) , HalfAxis.HAxis.AXIS_X_P, HalfAxis.HAxis.AXIS_Y_P); AddPosition( layer , new Vector2D( actualLength + offset.X - boxLength - i * boxLength, actualWidth + offset.Y - boxWidth - j * boxWidth) , HalfAxis.HAxis.AXIS_X_P, HalfAxis.HAxis.AXIS_Y_P); } } // area 4 for (int i = 0; i < sizeX_area4; ++i) { for (int j = 0; j < sizeY_area4; ++j) { LogPosition(new Vector2D( offset.X + boxWidth + i * boxWidth, actualWidth + offset.Y - boxLength - j * boxLength) , HalfAxis.HAxis.AXIS_Y_P, HalfAxis.HAxis.AXIS_X_N); AddPosition( layer , new Vector2D( offset.X + boxWidth + i * boxWidth, actualWidth + offset.Y - boxLength - j * boxLength) , HalfAxis.HAxis.AXIS_Y_P, HalfAxis.HAxis.AXIS_X_N); } } layer.UpdateMaxSpace(spaceX12, Name); layer.UpdateMaxSpace(spaceX34, Name); layer.UpdateMaxSpace(spaceY14, Name); layer.UpdateMaxSpace(spaceY23, Name); }