Skip to content

Commit

Permalink
Fix #538
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdoug committed Jul 23, 2023
1 parent fdf1219 commit 3bafcc3
Show file tree
Hide file tree
Showing 3 changed files with 266 additions and 250 deletions.
2 changes: 1 addition & 1 deletion src/LayerPacker.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function packLayer(ItemList &$items, PackedItemList $packedItemList, int
$skippedItems = [];
}
// might be space available lengthwise across the width of this item, up to the current layer length
$layer->merge($this->packLayer($items, $packedItemList, $x - $packedItem->getWidth(), $y + $packedItem->getLength(), $z, $x, $rowLength, $depthForLayer, $layer->getDepth(), $considerStability));
$layer->merge($this->packLayer($items, $packedItemList, $x - $packedItem->getWidth(), $y + $packedItem->getLength(), $z, $x, $y + $rowLength, $depthForLayer, $layer->getDepth(), $considerStability));

continue;
}
Expand Down
16 changes: 16 additions & 0 deletions tests/PackerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1207,6 +1207,22 @@ public function testIssue275D(): void
self::assertCount(1, $packedBoxes);
}

public function testIssue538(): void
{
$packer = new Packer();
$packer->setMaxBoxesToBalanceWeight(0);
$packer->addBox(new TestBox('Stock 5 Single Wall', 30, 45, 30, 0, 30, 45, 30, 15000));
$packer->addItem(new TestItem('Whatsanamie', 5, 5, 30, 100, Rotation::BestFit), 3);
$packer->addItem(new TestItem('Whatzit', 8, 5, 1, 100, Rotation::BestFit), 4);
$packer->addItem(new TestItem('Widget', 1, 3, 3, 100, Rotation::BestFit), 50);
$packer->addItem(new TestItem('Kajigger', 30, 25, 25, 100, Rotation::KeepFlat), 1);
$packer->addItem(new TestItem('Doohickey', 8, 10, 20, 100, Rotation::KeepFlat), 1);
$packer->addItem(new TestItem('Gadget', 15, 20, 5, 100, Rotation::KeepFlat), 8);
$packedBoxes = $packer->pack();

self::assertCount(1, $packedBoxes);
}

public function testCustomPackedBoxSorterIsUsed(): void
{
PackedBoxByReferenceSorter::$reference = 'Box #1';
Expand Down
Loading

0 comments on commit 3bafcc3

Please sign in to comment.