Cache result of getEdgeDisallowedSize

CURA-7106
This commit is contained in:
Jaime van Kessel 2020-06-23 11:01:43 +02:00
parent ea568f4ad5
commit 9014fa79e2
No known key found for this signature in database
GPG key ID: 3710727397403C91

View file

@ -92,6 +92,8 @@ class BuildVolume(SceneNode):
self._adhesion_type = None # type: Any
self._platform = Platform(self)
self._edge_disallowed_size = None
self._build_volume_message = Message(catalog.i18nc("@info:status",
"The build volume height has been reduced due to the value of the"
" \"Print Sequence\" setting to prevent the gantry from colliding"
@ -745,6 +747,7 @@ class BuildVolume(SceneNode):
self._error_areas = []
used_extruders = ExtruderManager.getInstance().getUsedExtruderStacks()
self._edge_disallowed_size = None # Force a recalculation
disallowed_border_size = self.getEdgeDisallowedSize()
result_areas = self._computeDisallowedAreasStatic(disallowed_border_size, used_extruders) # Normal machine disallowed areas can always be added.
@ -1122,6 +1125,9 @@ class BuildVolume(SceneNode):
if not self._global_container_stack or not self._global_container_stack.extruderList:
return 0
if self._edge_disallowed_size is not None:
return self._edge_disallowed_size
container_stack = self._global_container_stack
used_extruders = ExtruderManager.getInstance().getUsedExtruderStacks()
@ -1137,8 +1143,8 @@ class BuildVolume(SceneNode):
# Now combine our different pieces of data to get the final border size.
# Support expansion is added to the bed adhesion, since the bed adhesion goes around support.
# Support expansion is added to farthest shield distance, since the shields go around support.
border_size = max(move_from_wall_radius, support_expansion + farthest_shield_distance, support_expansion + bed_adhesion_size)
return border_size
self._edge_disallowed_size = max(move_from_wall_radius, support_expansion + farthest_shield_distance, support_expansion + bed_adhesion_size)
return self._edge_disallowed_size
def _clamp(self, value, min_value, max_value):
return max(min(value, max_value), min_value)