So libnest2d is giving a segfault when it's being triggered without any disallowed areas. This is because we then give a single disallowed area for the border around the build plate, and give this disallowed area 0 vertices. Because libnest2d doesn't do defensive coding here, it's going to crash, taking Cura along with it. The crash is in libnest2d's function 'libnest2d::_Item<ClipperLib::Polygon>::rightmostTopVertex()'.
This segfault started happening recently in Cura. However it only happens when there are no disallowed areas. Steps to reproduce the error are:
- Use Custom FFF Printer.
- Set the Adhesion Type setting to 'None'.
- Load any two models.
I tracked the segfault down to this commit: 74ddbaab4b . That commit by itself is slightly mysterious but looks fine to me. It did give the hint that this segfault might be caused by empty polygons though. So for that reason, I figured that filtering out the empty polygons here in the arranger might fix it; and indeed it does. Passing empty polygons as fixed/disallowed areas is useless and invalid anyway. Apparently libnest2d doesn't deal well with it, but we might as well not send those polygons over then.
These were floats. Rounding numpy-floats still results in floats so I'm just using int(). The result is rounded down instead of nearest, but the difference is at most 50 nanometres anyway.
Contributes to issue CURA-7501.
When multiplying objects or inserting objects in the scene that do not fit in the buildplate, those
objects would correctly end up outside the buildplate, but their Z position would be aligned at the
absolute Z=0 of the buildplate.
This commit fixes that by compensating in the z-axis, properly moving the object outside the
buildplate in the correct z-position so that it's bottom is aligned with the original object.
CURA-7440
Also improve the filtering a bit so that it's no longer dependent on the order. Doesn't really matter in this case but it should be more robust.
Contributes to issue CURA-7754.
Converted doxygen style comments to reStructuredText style in the files found in Cura/cura/Arranging directory recursively using the script dox_2_rst.py (provided in the Uranium repo). Comments were manually checked and changed if needed.
Various missing return types were added to complete Typing support
To do this, I'm giving more power to the NumericTextFieldWithUnit QML element, to allow an arbitrary minimum and maximum. Enforcing this minimum and maximum is fairly simple with a JavaScript hook. This hook is necessary because the DoubleValidator allows intermediary values which defeats the purpose, essentially allowing any number as long as it has the correct number of digits.
Printers larger than 2km would start to give overflow errors in its X and Y coordinates. Z is okay up to about 9 billion kilometres in theory, since we don't need to do any squaring math on those coordinates afaik. In practice I'm doing this because at very high values the Arranger also gives errors because Numpy can't handle those extremely big arrays (since the arranger creates a 2mm grid).
Fixes Sentry issue CURA-CB.