package grenier
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=b08e4c774ef72fc53c4fcee477e739d1beac9702079300daddf51ced9fa9cd26
sha512=984d92c51dac7b3f169cad595969a4fdbeb2be7b420ed1a85618d6adbb64af855cf2618d9bd0834e84d6734b99196944cab04435e1aeacad8cdfbc9a7f73d6d4
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).