-
Notifications
You must be signed in to change notification settings - Fork 102
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
Add disallowed areas #18
base: master
Are you sure you want to change the base?
Add disallowed areas #18
Conversation
Disallowed areas have slightly different behaviour from fixed items: Other items won't get packed closely around them. Implementation of that pending. Contributes to issue CURA-7754.
If you set the bin to -1 or set the item to be a simple fixed item afterwards, it'll no longer be a disallowed area. Contributes to issue CURA-7754.
…owed We shouldn't align items to disallowed areas. So place them in the starting position according to the alignment property. Lot of work to investigate. But very little code changes! Contributes to issue CURA-7754.
It seems the tests failed because the CI server couldn't download Clipper:
This has nothing to do with these code changes. May just be a hiccup in the CI system. |
Should mention that we've also made Python bindings for this library here: https://github.com/Ultimaker/pynest2d/ These Python bindings have some documentation on the public functions that goes beyond the documentation of libnest2d itself. The bindings are a bit more extensive than the previously existing bindings of nest2d. |
Many thanks! I will need to find some time to deal with the PR and also to review the tests, they might not be up to date. |
Hello @Ghostkeeper! So I've looked closely and I've found some problems: What if the first object being arranged collides with some disallowed area in the initial position. This is a deeper problem. The initial position is already a bit of an inconsistent feature if you take into account an irregular bin. Naturally, the disallowed areas would be the holes in a bin. You can see the issue in Cura as well if you enlarge some object enough to touch a disallowed area if placed in the center, the arrange will ignore the collision. The nesting could still snap to a disallowed area if it was not somewhere at the edge of the bin but closer to the center. Don't get me wrong, this is a reasonable workaround especially in Cura's use-case. It's just not robust for all the cases. I think if you where to center the first object manually and then add that and all the disallowed areas as fixed objects, it would have the same effect. |
This is impossible from outside the library though (as far as I could find) since it's unknown which object is placed first. |
It only depends on the selection algorithm, which is the one called "first fit" by default. It sorts items by the area in descending order. So in case you use the default selection algorithm, you can just center the biggest item and mark it as fixed. There is a catch, that if you want to have multiple merged piles, then you really can't no in advance, which items will be placed first on any of the bins with ID > 0. Let's just say that the library has many missing parts, one of which is the support for irregular bins. I will try to add that as soon as I can, but I can't make any time estimations on that. |
BTW, you can influence the selection order with the |
Hi! We've made some changes to this library to fit the needs of Cura. These changes are to fix a particular issue we've had with using the library in Cura because we seem to have a different way of dealing with the prime tower and bed clips than the application this library was originally designed for (PrusaSlicer). See also the pull request being reviewed by my colleagues: Ultimaker#1
This change adds a new concept to libnest2d: Disallowed areas.
There are several places in the bin where no objects can be placed. This includes places where objects have been placed before (pre-loaded items) but also some places where there are no objects at all, but objects that should still be avoided. In Cura's case this includes the prime tower and bed clips and a few other printer-defined places. In libnest2d these are currently all "fixed" items.
The problem we faced: We want objects to group together, but we don't want to group them together with disallowed areas that are not actual printed objects. Previously placed objects and disallowed areas need to be marked as "fixed" in order to prevent the nester from moving them. However newly placed items are then still packed close together with all fixed items. In our case, we want to pack them close together with normal fixed objects, but not with non-objects such as the bed clips.
This change allows the consumer of the library to set some items to be disallowed areas. Those items are fixed, but other items won't try to pack closely together with them. In effect, just the first item doesn't need to get packed closely together since other items will then pack with the first item.
Before this change, items get placed down by the side which is a disallowed area due to the difference between nozzle positions in this case:
After this change, items get placed down in the middle as the
NfpPConfig::alignment
indicates:I don't know if this is something you'd like to add upstream as well. Maybe it's not useful for you or not considered in scope of this library. Even if it's not useful, take it as a sign of goodwill.