package grenier
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=658e1ad6fc5fdce0871975b3ebcb3ec760248be63cdb9ea965e3121cc7478d77
sha512=d9ff83f1b025f34c22af5921444993df219761dcee8d8cb5a940f266df8677278967434b22314c5c82d5d983e4c94c04cd52c4717d5c1f22fbd3a022631fae1c
doc/grenier.binpacking/Maxrects/index.html
Module Maxrects
Source
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 list
Online 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).