Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rotate some rectangles #14

Open
AlexStrNik opened this issue Dec 6, 2017 · 6 comments
Open

Rotate some rectangles #14

AlexStrNik opened this issue Dec 6, 2017 · 6 comments

Comments

@AlexStrNik
Copy link

How to specify which rectangles can rotate for best packing, and what cant?

@secnot
Copy link
Owner

secnot commented Dec 6, 2017

You can enable or disable rotation when the packer is created:

packer = newPacker(rotation=True)

but it is an all or nothing proposition, all the rectangles can be rotated or none can, the algorithm decides which ones to rotate to obtain the best packing. The next release will allow to individually enable or disable rotation for each rectangle.

@geonak
Copy link

geonak commented Aug 10, 2018

Hello,
I find myself needing this functionality as well. Has it been implemented? a quick look through the code tells it still hasn't been. Any ETA on when this might be available?
If this is not in the works, would it be enough to pass a rot parameter per rectangle to _fits_surface and use it in conjunction with the global one? I have looked super quickly so I might be completey off track here.
Cheers,
G

@secnot
Copy link
Owner

secnot commented Aug 10, 2018

Hi

I'm currently working on a polygon packing library, and had planed to refactor and add a few of the missing functionalities to rectpack after that.

Adding per rectangle rotation is easy, the cleaner solution would be to just disable or remove rotation from all the algorithms, and have Packer manage rotation (slower). The other option is to modify the algorithms as you have said.

The problem is all the testing that is required before it can be marked as 'production ready' and then released. So I'm waiting to fix all in one go to pass testing only once.

If there are no delays I expect to start working on rectpack on September, and to finish in a week or two after that.

@geonak
Copy link

geonak commented Aug 10, 2018

Thank you for the reply.
Any more tips for me to apply it quickly to my current project in the meantime would be really appreciated.
Another thing that I noticed just now, is that the global enable/disable rotation is not working properly as far as I can tell , it changes the distribution, but many of the rectangles are still rotated. unless I might be doing something wrong? or is this a known issue?

@secnot
Copy link
Owner

secnot commented Aug 11, 2018

Hi

You could use one of the algorithms directly without all the packer logic, for each bin create an instance of the algorithm with rotation disabled, then when you place a rectangle check its fitness for the normal or the rotated version (when allowed) and place the lower one. If you have several rectangles you can get the fitness for all of them and place the best.

About the global rotation being ignored, if you can provide a code snippet where it happens I will look into it.

@geonak
Copy link

geonak commented Aug 12, 2018

Thank you for the reply secnot. Actually I had discovered a small issue on my inputs which caused the bad rotation behaviour, once that was fixed everything worked well.
I will try using this for now, if I still needed the per rect rotations, I will follow your advice to implement something, if not I will definitely be looking forward to picking it up when you code it in :)
thank you again.
G

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants