package grenier
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=622a34f91f2787096f15786901b8d8cff528cada805b018fdbd522c00c6f13e8
sha512=e687e7c9e7b61d876c70570a9b6e4f3a497c8deb334e28532d8c2f9a2a06bff1330431b64ec3e8c4bcfcf2cc9495723339196608c6c4ac5a0699020d0af93e26
doc/grenier.binpacking/Maxrects/index.html
Module Maxrects
val empty : 'bin tmake ~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
val box : ?allow_rotation:bool -> 'tag -> int -> int -> 'tag boxtype ('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).