Download the PHP package latuconsinafr/3d-bin-packager without Composer
On this page you can find all versions of the php package latuconsinafr/3d-bin-packager. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download latuconsinafr/3d-bin-packager
More information about latuconsinafr/3d-bin-packager
Files in latuconsinafr/3d-bin-packager
Package 3d-bin-packager
Short Description PHP Library for 3D Bin Packing.
License MIT
Informations about the package 3d-bin-packager
3D Bin Packager
This package contains a PHP implementation to solve 3d bin packing problems based on gedex implementation on Go and enzoruiz implementation on Python with some modifications to make it more modular.
Installation
Install by adding the package as a Composer requirement:
Usage
There's an example inside the root project example.php
. Just simply type the command php example.php
in the project's root and it would display the time elapsed and corresponding results with the number of lower bounds and the list of the bins (support for json encode cause every class implements the \JsonSerializable
interface).
First of all, you have to initialize the packager object:
The packager constructor takes two parameters:
- Precision: The number of digits after the decimal point. It will be used for number of digits to round to.
- Sort type: With two types available
SortType::ASCENDING
andSortType::DESCENDING
. This sort type will be used to sort the bins and the items volume inside the packager based on the chosen sort type (whether it is ascending or descending)
After you initialized the packager, you can start to add the bin(s) or the item(s) into the packager with these 4 following methods:
Then to pack all the item(s) to all the bin(s):
To get the result and other details after the packing are listed below:
- To get all the bin(s) after the packing you can use either the
$packager->getBins()
or the$packager->getIterableBins()
to return theArrayIterator
data type. You can see the id, length, height and etc for the bins inside the iterable and also all the fitted items inside thefittedItems
property. - Due to the first fit method, the packing process would try to fit as much items as possible to the first bin and if there's no more space inside the bin, all the remaining items would be listed inside the
unfittedItems
property and move to the next bin. You can also see the total fitted or unfitted volume and weight viagetTotalFittedVolume()
,getTotalFittedWeight()
, etc. - The identifier is used to make every single bin and item unique.
- You can also see the total of all bin(s) and item(s) from the Packager class with
getTotalBinsVolume()
,getTotalBinsWeight()
, etc. - You can get further detailed information about the fitted item inside the bin such as the current rotation type which is applied to fit the item into the bin via
getRotationType()
(you can see theRotationCombinationType::class
for the rotation list). -
You can serialize the resulted bins to see something like this:
- You can also get the corresponding position of any item inside the bin which is represented by the x-axis, y-axis and z-axis using
getPosition()
. In case you want to plot or use it for further analysis. - You can check the phpdoc or the code for further information.
Credits
License
This package is under MIT license.