문제

Is the algorithm for packing rectangles without rotation?

Maybe implementation in C++?

I found this

and

  • GuillotineBinPack
  • ShelfBinPack
  • SkylineBinPack

But they rotate rectangles.

도움이 되었습니까?

해결책

You can sort the boxes by width and then place it into a node of a tree. Then split the tree along the 2 axis. For the next box look for the best fit, I.e. least waste and place the box into the free node. Rinse and repeat until no boxes or node is left. You can look into packing lightmaps with a kd-tree by blackpawn.

다른 팁

You can make your boxes square and ignore rotation after packing. This will waste some space but requires no changes to Guillotine library.

You can use this small code to pack rectangles:

http://www.flipcode.com/archives/Rectangle_Placement.shtml

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top