tamasmeszaros/libnest2d

How to control the rotation Angle?

mc373906408 opened this issue · 4 comments

I want to disable the rotation Angle, and I can use up, down, left and right mirror flipping. What should I do?

If you're using the NfpPlacer, the NfpPConfig class has a field for the possible rotations it's allowed to do. By default this initialises to the 4 cardinal directions (0, 90, 180, 270 degrees). If you want to disable rotation, set that to contain just 0.

As far as I know, this library will not do mirroring of your items. You would have to try packing all combinations of all items being mirrored in every direction if you'd like to to that, and measure the packing density yourself (i.e. minimise the area of the convex hull).

Can you give me an example of how to use the NfpPConfig class? Thanks.

NfpPConfig is a placer configuration. The main nest function has a parameter that accepts a NestConfig which is a combination of the placer and selector configuration. From the top of my head, adjusting the placer configuration would look something like this then.

//(Assuming you have input vec, bin and dist...)

NfpPConfig placer_config;
placer_config.rotations = {0};
const NestConfig configs(placer_config);

const size_t result = nest(vec.begin(), vec.end(), bin, dist, configs);

I didn't try this. That's all just from looking at the interface. Use at your own risk.

But I think this is then not an issue, as in, already implemented.

This example is great