66 Commits

Author SHA1 Message Date
Ghostkeeper
83767764db
Slightly increase spacing when arranging models
This is closer to the behaviour in Cura 4.7 and earlier. It makes it easier to pull objects apart, and to break them off from a raft.
2021-04-21 15:56:59 +02:00
Ghostkeeper
9dba4d554f
Fix segfault when arranging without any disallowed areas
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.
2021-04-14 00:32:50 +02:00
Jaime van Kessel
82ffdccac2
Added type ignore since it does accept it 2021-04-07 17:15:22 +02:00
Jaime van Kessel
3432720f7c
Fix mypy issues caused by numpy upgrade 2021-04-07 11:47:52 +02:00
Ghostkeeper
39287264d9
Pynest2d.Point requires integer coordinates
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.
2020-10-30 18:12:18 +01:00
Jaime van Kessel
5109bd3684
Fix crash when duplicating node with support blocker
Suggested & reported by smartavonics.

Fixes #8581
2020-10-20 14:19:33 +02:00
Kostas Karmas
8c1cf89d45 Skip arranging objects that have no convex hull
CURA-7780
2020-10-16 11:31:00 +02:00
Kostas Karmas
148dd26b67 Close "Finding Location" message if arrange crashes
CURA-7780
2020-10-16 11:10:02 +02:00
Kostas Karmas
c54605a134 Transfer deprecated decorator on __init__ of Arrange
As it cannot decorate a class.

Also, the deprecated decorator has to be applied before the @classmethod.

CURA-7440
2020-10-13 18:06:44 +02:00
Kostas Karmas
a0e4e4325d Add missing documentation
CURA-7440
2020-10-12 17:57:00 +02:00
Kostas Karmas
972e2f6716 Fix crash when arranging objects in one-at-a-time mode
Crashing was occuring because node.getPoints() can return None.

CURA-7440
2020-10-12 16:28:28 +02:00
Remco Burema
9f929298d7
Merge pull request #8510 from Ultimaker/CURA-7754_add_disallowed_areas
Mark disallowed areas as disallowed areas
2020-10-09 19:27:26 +02:00
Kostas Karmas
a94ebc6261 Don't arrange locked objects when arrangeAll is called
CURA-7440
2020-10-09 18:09:40 +02:00
Kostas Karmas
d47623d58a Remove duplicate addition of items in the node_items list
CURA-7440
2020-10-09 17:19:53 +02:00
Kostas Karmas
f9bd5e3dcd Modify arrange() to optionally create AddSceneNodeOperations
Then the MultiplyObjectsJob can use the arrange function instead of duplicating the code

CURA-7440
2020-10-09 17:12:59 +02:00
Kostas Karmas
eedbcb6a2d Fix z position of objects that end outside the buildplate
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
2020-10-09 15:59:50 +02:00
Kostas Karmas
8678682d94 Reformat file and remove unused import
CURA-7440
2020-10-08 16:27:36 +02:00
Ghostkeeper
6bfa24686f
Mark disallowed areas as disallowed areas
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.
2020-10-08 11:10:24 +02:00
Jaime van Kessel
a46bf8d6fa
Apply suggestions from code review
CURA-7440

Co-authored-by: Konstantinos Karmas <konskarm@gmail.com>
2020-10-08 09:43:22 +02:00
Jaime van Kessel
d801f9838a
Fix mypy issues
It doesn't seem to like blanket imports

CURA-7440
2020-10-05 14:52:50 +02:00
Jaime van Kessel
a14135be5e
Add some documentation to the arrange nest algorithm
CURA-7440
2020-10-05 14:24:34 +02:00
Jaime van Kessel
9312dc5c07
Add deprecated tag to arranger
CURA-7440
2020-10-05 14:15:49 +02:00
Jaime van Kessel
30966beed2
Let autoplacement also take the existing nodes into account
CURA-7440
2020-10-05 13:37:57 +02:00
Jaime van Kessel
274dc8d06c
Split up arrange
This splits up the finding of new positions with the actual move. This is needed
for when we want to place new nodes on model load.

CURA-7440
2020-10-02 11:21:57 +02:00
Jaime van Kessel
c25351c98a
Remove unused imports
CURA-7440
2020-10-02 10:06:41 +02:00
Jaime van Kessel
8c1985cdb3
Move nest2darrange to it's own function
This makes it a lot easier to re-use it

CURA-7440
2020-10-02 10:06:09 +02:00
Jaime van Kessel
e0e65b91b5
Take disallowed areas into account when arranging
CURA-7440
2020-09-30 10:34:35 +02:00
Jaime van Kessel
73289b2a77
Place objects that we couldn't fit next to the buildplate
CURA-7440
2020-09-28 16:21:47 +02:00
Jaime van Kessel
b0a8a5ccab
Switch out the arranger algorithm for arrange all
CURA-7440
2020-09-28 16:16:47 +02:00
Jaime van Kessel
1505d59f4b
Add extra process events to arrange job
Doesn't actually speed up something, but it does prevent the GUI from
freezing, so it looks less laggy.

CURA-7106
2020-06-23 10:38:21 +02:00
Jaime van Kessel
61def4ba25
Prevent crash when requested polygon is too large
CURA-6P
2020-06-19 16:59:27 +02:00
Nino van Hooff
89f0970a88 Remove trailing whitespace from Python files 2020-05-29 14:30:33 +02:00
Nino van Hooff
176919eee0 Merge branch 'master' into doxygen_to_restructuredtext_comments
# Conflicts:
#	plugins/CuraEngineBackend/CuraEngineBackend.py
#	plugins/CuraEngineBackend/StartSliceJob.py
2020-05-08 15:31:23 +02:00
Jelle Spijker
679739d09d
Applied requested changes proposed by @ninovanhooff
Fixed a couple of missed double quotes, trailing and leading spaces, to long comment lines
2020-04-27 20:09:00 +02:00
Ghostkeeper
09ee9660ea
Don't crash if the build volume is smaller than one arrange cell
Fixes Sentry issue CURA-M6.
2020-04-23 14:42:36 +02:00
Jelle Spijker
9b44ca37ef
Converted comments in dir Cura/cura/Arranging to rst style
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
2020-04-23 12:13:24 +02:00
Jaime van Kessel
d0901c91f7
Update some documentation to the new style 2020-04-10 14:05:17 +02:00
Jaime van Kessel
2e9dca71ce
Remove a number of unused imports 2020-04-10 13:58:10 +02:00
Ghostkeeper
c7e6553dbf
Disallow printers larger than 2km
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.
2020-03-20 11:16:16 +01:00
Jaime van Kessel
7c70ace8f0
Prevent crash when the start_idx could not be found
CURA-59
2020-02-28 17:06:57 +01:00
Jaime van Kessel
290761fccd
Fix arranger crash 2020-01-15 11:29:27 +01:00
Jaime van Kessel
e74f049142
Fix bunch of issues found by pylint 2020-01-10 16:37:46 +01:00
Jaime van Kessel
81b33b8649
Add some missing typing 2020-01-10 14:58:53 +01:00
Jaime van Kessel
5a714f3a24 Fix arranging of nested group nodes causing a crash
CURA-6688
2019-08-06 14:04:45 +02:00
Ghostkeeper
17e86a28b7
Guard against broken import 2019-07-01 10:58:08 +02:00
Ghostkeeper
f86cf06b88
Add typing 2019-07-01 10:57:08 +02:00
Ghostkeeper
2b8a2d0c20
Reduce print output during happy path of automated tests
It should really just not print anything except what pytest prints, so you can easily see what tests have failed and what have not.
2019-03-11 11:10:09 +01:00
Remco Burema
0e329946f8 Small refactor (init set plain instead of with empty list). [CURA-6120] 2019-02-14 11:05:13 +01:00
Remco Burema
a24dc00bc5 Arrange child-nodes (like blocker) with parents. [CURA-6120] 2019-02-12 18:08:17 +01:00
Aleksei S
5be8b2810d Fix: if load a model and scale it up to 0.1mm and then load another model then Cura will crash. It happens because the model 1 does not
have any points for arranging it on the build plate
CURA-5867
2018-11-22 22:10:54 +01:00