Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdoug committed Jul 26, 2023
1 parent 535e167 commit 1703b9b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Packer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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<Box>
*/
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 = [];
Expand Down

0 comments on commit 1703b9b

Please sign in to comment.