Is there a c++ source/lib to solve 2D Bin Packing with a rectangular bin (not square) and rotation? [closed]

こ雲淡風輕ζ 提交于 2019-12-02 18:36:49
Lalaland

http://clb.demon.fi/files/RectangleBinPack.pdf is key. That is the reference on 2d bin packing.

You might be able to modify one of the algorithms in there to satisfy your need. I doubt the rotation is needed, the algorithms are pretty advanced as they are.

This (https://github.com/Lalaland/PixelPacker/blob/master/src/algoMaxRects.cpp) is an example of how to implement the MaxRects algorithm.

The modification you would probably have to make is at the top of the algorithm, when selecting the next rectangle to use. Simply have it also look at the different orientation of the rectangles along with cycling through the whole list.

I found this thread a few weeks ago, after skim reading the PDF in the answer, and toying around with the authors code, I did a re-write which more suited my needs ( texture atlas packing )

If anyone else is interested... https://github.com/chris-stones/BinPack2D

  • Allow user to bundle a data-structure with submitted rectangles ( orig file name, etc )
  • Pack multiple bins ( for 2d texture atlas array - GL_EXT_texture_array )

Also, Instead of tracking splitting and joining free rectangles, I track and sort free top left corners. I found it much simpler to implement, with equally good results.

There is no documentation, See ExampleProgram() at the top of the header file.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!