Skip to content

Commit

Permalink
Completely skip items that don't meet non dimension criteria, no poin…
Browse files Browse the repository at this point in the history
…t iterating over them later
  • Loading branch information
dvdoug committed Apr 18, 2020
1 parent 2e254f9 commit 40661ee
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/LayerPacker.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function packLayer(ItemList &$items, PackedItemList $packedItemList, arra
while ($items->count() > 0) {
$itemToPack = $items->extract();

//skip items that are simply too heavy or too large
//skip items that will never fit e.g. too heavy
if (!$this->checkNonDimensionalConstraints($itemToPack, $remainingWeightAllowed, $packedItemList)) {
continue;
}
Expand Down Expand Up @@ -163,8 +163,14 @@ private function packVerticallyInsideItemFootprint(PackedLayer $layer, PackedIte
$stackedItem = $packedItem->toOrientatedItem();
while ($stackableDepth > 0 && $items->count() > 0) {
$itemToTryStacking = $items->extract();

//skip items that will never fit
if (!$this->checkNonDimensionalConstraints($itemToTryStacking, $remainingWeightAllowed, $packedItemList)) {
continue;
}

$stackedItem = $this->orientatedItemFactory->getBestOrientation($itemToTryStacking, $stackedItem, $items, $packedItem->getWidth(), $packedItem->getLength(), $stackableDepth, $rowLength, $x, $y, $stackedZ, $packedItemList);
if ($stackedItem && $this->checkNonDimensionalConstraints($itemToTryStacking, $remainingWeightAllowed, $packedItemList)) {
if ($stackedItem) {
$layer->insert(PackedItem::fromOrientatedItem($stackedItem, $x, $y, $stackedZ));
$remainingWeightAllowed -= $itemToTryStacking->getWeight();
$packedItemList->insert($packedItem);
Expand Down

0 comments on commit 40661ee

Please sign in to comment.