PHP Class DVDoug\BoxPacker\VolumePacker

Author: Doug Wright
Inheritance: implements Psr\Log\LoggerAwareInterface, use trait Psr\Log\LoggerAwareTrait
Datei anzeigen Open project: dvdoug/boxpacker Class Usage Examples

Protected Properties

Property Type Description
$box DVDoug\BoxPacker\Box Box to pack items into
$depthLeft integer Remaining depth of the box to pack items into
$items ItemList List of items to be packed
$lengthLeft integer Remaining length of the box to pack items into
$remainingWeight integer Remaining weight capacity of the box
$widthLeft integer Remaining width of the box to pack items into

Public Methods

Method Description
__construct ( DVDoug\BoxPacker\Box $box, ItemList $items ) Constructor
pack ( ) : DVDoug\BoxPacker\PackedBox Pack as many items as possible into specific given box

Protected Methods

Method Description
findBestOrientation ( DVDoug\BoxPacker\Item $item, OrientatedItem $prevItem = null, DVDoug\BoxPacker\Item $nextItem = null, integer $widthLeft, integer $lengthLeft, integer $depthLeft ) : OrientatedItem | false Get the best orientation for an item
findPossibleOrientations ( DVDoug\BoxPacker\Item $item, OrientatedItem $prevItem = null, integer $widthLeft, integer $lengthLeft, integer $depthLeft ) : OrientatedItem[] Find all possible orientations for an item
isLayerStarted ( integer $layerWidth, integer $layerLength, integer $layerDepth ) : boolean
tryAndStackItemsIntoSpace ( ItemList $packedItems, integer $maxWidth, integer $maxLength, integer $maxDepth ) Figure out if we can stack the next item vertically on top of this rather than side by side Used when we've packed a tall item, and have just put a shorter one next to it

Method Details

__construct() public method

Constructor
public __construct ( DVDoug\BoxPacker\Box $box, ItemList $items )
$box DVDoug\BoxPacker\Box
$items ItemList

findBestOrientation() protected method

Get the best orientation for an item
protected findBestOrientation ( DVDoug\BoxPacker\Item $item, OrientatedItem $prevItem = null, DVDoug\BoxPacker\Item $nextItem = null, integer $widthLeft, integer $lengthLeft, integer $depthLeft ) : OrientatedItem | false
$item DVDoug\BoxPacker\Item
$prevItem OrientatedItem
$nextItem DVDoug\BoxPacker\Item
$widthLeft integer
$lengthLeft integer
$depthLeft integer
return OrientatedItem | false

findPossibleOrientations() protected method

Find all possible orientations for an item
protected findPossibleOrientations ( DVDoug\BoxPacker\Item $item, OrientatedItem $prevItem = null, integer $widthLeft, integer $lengthLeft, integer $depthLeft ) : OrientatedItem[]
$item DVDoug\BoxPacker\Item
$prevItem OrientatedItem
$widthLeft integer
$lengthLeft integer
$depthLeft integer
return OrientatedItem[]

isLayerStarted() protected method

protected isLayerStarted ( integer $layerWidth, integer $layerLength, integer $layerDepth ) : boolean
$layerWidth integer
$layerLength integer
$layerDepth integer
return boolean

pack() public method

Pack as many items as possible into specific given box
public pack ( ) : DVDoug\BoxPacker\PackedBox
return DVDoug\BoxPacker\PackedBox packed box

tryAndStackItemsIntoSpace() protected method

Figure out if we can stack the next item vertically on top of this rather than side by side Used when we've packed a tall item, and have just put a shorter one next to it
protected tryAndStackItemsIntoSpace ( ItemList $packedItems, integer $maxWidth, integer $maxLength, integer $maxDepth )
$packedItems ItemList
$maxWidth integer
$maxLength integer
$maxDepth integer

Property Details

$box protected_oe property

Box to pack items into
protected Box,DVDoug\BoxPacker $box
return DVDoug\BoxPacker\Box

$depthLeft protected_oe property

Remaining depth of the box to pack items into
protected int $depthLeft
return integer

$items protected_oe property

List of items to be packed
protected ItemList,DVDoug\BoxPacker $items
return ItemList

$lengthLeft protected_oe property

Remaining length of the box to pack items into
protected int $lengthLeft
return integer

$remainingWeight protected_oe property

Remaining weight capacity of the box
protected int $remainingWeight
return integer

$widthLeft protected_oe property

Remaining width of the box to pack items into
protected int $widthLeft
return integer