secnot / rectpack

Python 2D rectangle packing library
Apache License 2.0
457 stars 103 forks source link

grouping bundled rectangles into same bin #26

Open jeremyforan opened 5 years ago

jeremyforan commented 5 years ago

I would like to add some constraints that will let me ensure some rectangles are guaranteed to be in the same bin. bundled_rid = [["100023","100024","100142"],["73732","73785"]] packer.pack(groups=bundled_rid)

This would result in each bundle in the array of bundles being in the same bin.

Do you have any recommendations on how I might accomplish this using the existing code? Does this seem like a valid use case?

secnot commented 5 years ago

Hi

The simplest way to accomplish what you want is to "pre-pack" each bundle into a single rectangle, pack that, and later substitute the rectangle by the rectangles on the bundle.

Other option is to handle each bin individually, start packing boundles until no more fit and then continue with single rectangles. Then continue with the next bin

If neither option is working for you, or the results are not good enough, you could use the algorithms directly dropping all the packing logic, and building something more custom.