mapbox / shelf-pack

A 2D rectangular bin packing data structure that uses the Shelf Best Height Fit heuristic
ISC License
129 stars 17 forks source link

Features / use case #87

Open waldenbuilds opened 7 years ago

waldenbuilds commented 7 years ago

Im using shelf pack to pack plywood cuts into the min amount of sheets. For example:

image

Yes, there are other packing libs which are designed more for this, but I find them difficult to use - mapbox always puts out high quality stuff. Shelfpack is really close to doing what I need.

What would be great is 2 additional options/ behaviors:

bhousel commented 7 years ago

Interesting usecase and thanks for the kind words!

auto grow in 1 direction (for example height) option to have shelves always created at fixed heights (in my case height of material).

These both sound like good options. Option to have shelves always created at fixed heights could be solved by #5, and option to determine which dimensions allow auto grow would be easy to do.

waldenbuilds commented 7 years ago

Thanks @bhousel for the quick response!

So after a little more hacking I'm not sure the 2 options I suggested are the best way to approach my problem.

I was able to get a better optimization by simply using some trickery in my code:

image

What I do roughly is:

I believe this works for me because my parts tend to be longer but just shy of the material size (I have a lot of 30 inch cuts on 48 wide ply).

bhousel commented 7 years ago

@waldenbuilds This makes a lot of sense! This library was originally intended to pack glyphs into a texture, so you probably want your bins to be aligned vertically like the letters in the alphabet, and it will help to sort them by height (I think longest to shortest might work best, but try other ways too!) good luck..