Penlect / rectangle-packer

Rectangle packing program
MIT License
63 stars 18 forks source link

Pack not fitting in max_height #12

Open Kuluum opened 3 years ago

Kuluum commented 3 years ago

I have faced a problem with one concrete sizes list and max_height. After packing the result container's height is bigger than max_height, but its enough width space to make packing the correct height.

Python 3.8.6

rpack.__version__ 2.0.0


import rpack

sizes = [[54, 36], [122, 56], [162, 144], [158, 202], [141, 159], [71, 60], [66, 71], [157, 211], [38, 38], [37, 40], [39, 41], [96, 124], [105, 132], [95, 132], [50, 34], [66, 53], [72, 54], [38, 50], [86, 83], [238, 137], [389, 214], [266, 138], [275, 226], [228, 175], [125, 121], [177, 219], [255, 145], [599, 221], [399, 187], [342, 226]]

max_height = 960
max_width = 3860

positions = rpack.pack(sizes, max_height=max_height, max_width=max_width)

print(rpack.bbox_size(sizes, positions))                                     

### (1017, 1005)  but max_height was 960
Kuluum commented 3 years ago

it looks like max_width parameter matters too. If I remove , max_width=max_width in provided code result fits in max_height.

positions = rpack.pack(sizes, max_height=max_height)

print(rpack.bbox_size(sizes, positions))

### (1008, 853) even better packing
Penlect commented 3 years ago

Thank you @Kuluum for reporting this bug. I have released a bugfix release, 2.0.1, and deployed new wheels to PyPI.

arncode90 commented 2 years ago

SO do

Thank you @Kuluum for reporting this bug. I have released a bugfix release, 2.0.1, and deployed new wheels to PyPI.

Hi,

  1. Can we set width and height of bounding box? if yes, how?
  2. can it be rotatable?

I checked that the max_width / max_height is for the rectangle sizes.