libnest2d icon indicating copy to clipboard operation
libnest2d copied to clipboard

Irregular bins

Open samsonsite1 opened this issue 5 years ago • 5 comments

Do you have any plans to support fitting shapes to irregular bins?

You briefly mentioned it here: https://github.com/tamasmeszaros/libnest2d/issues/7

But, you didn't say if you plan to improve it or expand upon it. I would also be interested in seeing something like this. Thanks.

samsonsite1 avatar Dec 06 '19 19:12 samsonsite1

What I can do and surely will in the next few weeks, is make the most out of the current "brain" to handle irregular bins. What you can expect is that you can use a simple polygon as a bin and items will be inside of it -- the boundaries will be respected. But the result can be stupid, I probably won't fix that for a while. You can improve that however with a custom optimization kernel which you can pass as a function object to the nest() function.

tamasmeszaros avatar Dec 07 '19 11:12 tamasmeszaros

Thanks for the reply.

It would be very interesting if we could pack shapes to a circle or n-sided poly bin. I didn't have anything complex in mind like a bin with exclusion zones, so simple polygon bins are fine by me.

samsonsite1 avatar Dec 07 '19 15:12 samsonsite1

I think that this should be possible even with the current code. Go on and try to define a Circle as the bin shape and pass it to the nest function. The App PrusaSlicer for which this library was initially developed, supports circular print beds and it works. Not as polished as for the box shaped bed though.

tamasmeszaros avatar Dec 16 '19 22:12 tamasmeszaros

Thanks, I tried switching the bin to a Circle, but the compiler can't find a matching overload function for it:

//size_t bins = nest(input, Box( s,s, {0,0} ) ); size_t bins = nest(input, Circle( {0,0}, s ) );

cannot convert from 'libnest2d::_Circlelibnest2d::PointImpl' to 'const libnest2d::Box' no instance of overloaded function "nest" matches the argument list

samsonsite1 avatar Dec 20 '19 17:12 samsonsite1

Hey all! What's the status on irregular nesting? If using a polygon as bin shape is supported, I'd appreciate it very much if you could post a code snippet.

EDIT: I managed to "activate" circular placement by modifying libnest2d.hpp. I added a using directive for an NfpPlacer that accepts Circle instead of Box and a defined new nest() function template using the new Placer. Probably not the best way to do it, but it works :D

ItsMeTheBee avatar Apr 07 '22 09:04 ItsMeTheBee