diff --git a/src/Packer.php b/src/Packer.php index 657d8ab..a6db759 100644 --- a/src/Packer.php +++ b/src/Packer.php @@ -163,7 +163,7 @@ public function pack(): PackedBoxList */ public function doVolumePacking(bool $singlePassMode = false, bool $enforceSingleBox = false): PackedBoxList { - $packedBoxes = new PackedBoxList(); + $packedBoxes = new PackedBoxList($this->packedBoxSorter); // Keep going until everything packed while ($this->items->count()) { @@ -180,6 +180,7 @@ public function doVolumePacking(bool $singlePassMode = false, bool $enforceSingl // Have we found a single box that contains everything? if ($packedBox->getItems()->count() === $this->items->count()) { + $this->logger->log(LogLevel::DEBUG, "Single box found for remaining {$this->items->count()} items"); break; } } @@ -208,13 +209,17 @@ public function doVolumePacking(bool $singlePassMode = false, bool $enforceSingl * Get a "smart" ordering of the boxes to try packing items into. The initial BoxList is already sorted in order * so that the smallest boxes are evaluated first, but this means that time is spent on boxes that cannot possibly * hold the entire set of items due to volume limitations. These should be evaluated first. + * + * @return iterable */ protected function getBoxList(bool $enforceSingleBox = false): iterable { + $this->logger->log(LogLevel::INFO, 'Determining box search pattern', ['enforceSingleBox' => $enforceSingleBox]); $itemVolume = 0; foreach ($this->items as $item) { $itemVolume += $item->getWidth() * $item->getLength() * $item->getDepth(); } + $this->logger->log(LogLevel::DEBUG, 'Item volume', ['itemVolume' => $itemVolume]); $preferredBoxes = []; $otherBoxes = [];