package grenier
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=8fd22abf9f4589c206008654fa9eebb1cf4a58737ebb34138c6709520f36b75f
sha512=f60315eccfecaec9cb4c3bd020ef6f94d05ed6b13038109b904ead6e4e5662f4ed95415855b3c763293b762b696f1962045393fd592742d54cf5607d0ef2961a
doc/grenier.binpacking/Maxrects/index.html
Module MaxrectsSource
make ~width ~height return a packer ready to place stuff in a width * height area
type 'tag box = {tag : 'tag;width : int;height : int;allow_rotation : bool;(*can the box be rotated to optimize packing
*)
}Input to packing is a box
type ('bin, 'tag) rect = {x : int;y : int;w : int;h : int;rotated : bool;(*True iff the input box was rotated. If true, w = box.height && h = box.width Otherwise, w = box.width && h = box.height
*)bin : 'bin;box : 'tag box;
}Output of packing is an optional rectangle
type heuristic = [ | `Short_side_fit(*BSSF. Positions the rectangle against the short side of a free rectangle into which it fits the best.
*)| `Long_side_fit(*BLSF: Positions the rectangle against the long side of a free rectangle into which it fits the best.
*)| `Area_fit(*BAF: Positions the rectangle into the smallest free rect into which it fits.
*)| `Bottom_left(*BL: Does the Tetris placement.
*)
]Online insertion of one item. Efficient but the packing is not very good.
Worst-case: O(n^3) (n is total number of items inserted).
val insert_batch :
'bin t ->
?heuristic:heuristic ->
'tag box list ->
'bin t * ('bin, 'tag) rect option listOnline insertion of a batch of items. Runtime is roughly the cost of inserting each item independently, but order of insertion is chosen to give a better packing.
Worst-case: O(n^4) (n is total number of items inserted).