This library is translated from https://github.com/krris/3d-bin-packing.
The coordinates are defined as:
o--------o
/| /|
/ | / |
h o--------o |
e | o-----|--o h
y i | / | / t
g |/ |/ p z
h o--------o e
t | width d
| x
(0, 0, 0)
Example code:
// Define the size of binvarbinWidth=1000;varbinHeight=1000;varbinDepth=1000;// Define the cuboids to packvarparameter=newBinPackParameter(binWidth,binHeight,binDepth,new[]{newCuboid(150,100,150),newCuboid(500,500,500),newCuboid(500,550,700),newCuboid(350,350,350),newCuboid(650,750,850),});// Create a bin packer instance// The default bin packer will test all algorithms and try to find the best result// BinPackerVerifyOption is used to avoid bugs, it will check whether the result is correctvarbinPacker=BinPacker.GetDefault(BinPackerVerifyOption.BestOnly);// The result contains bins which contains packed cuboids whith their coordinatesvarresult=binPacker.Pack(parameter);foreach(varbinsinresult.BestResult){Console.WriteLine("Bin:");foreach(varcuboidinbins){Console.WriteLine(cuboid);}}Outputs:
Bin:
Cuboid(X: 0, Y: 0, Z:0, Width: 750, Height:850, Depth:650)
Cuboid(X: 0, Y: 0, Z:650, Width: 350, Height:350, Depth:350)
Cuboid(X: 750, Y: 0, Z:0, Width: 150, Height:150, Depth:100)
Bin:
Cuboid(X: 0, Y: 0, Z:0, Width: 700, Height:500, Depth:550)
Cuboid(X: 0, Y: 500, Z:0, Width: 500, Height:500, Depth:500)
MIT License
Copyright © 2018 303248153@github
If you have any license issue please contact 303248153@qq.com.