mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 14:37:29 -06:00
Simulation speed made 3X
case where no polygon in layer is also addressed CURA-11289
This commit is contained in:
parent
13540c3ed2
commit
411b40d78c
1 changed files with 29 additions and 28 deletions
|
@ -57,7 +57,7 @@ class SimulationView(CuraView):
|
|||
LAYER_VIEW_TYPE_LINE_TYPE = 1
|
||||
LAYER_VIEW_TYPE_FEEDRATE = 2
|
||||
LAYER_VIEW_TYPE_THICKNESS = 3
|
||||
SIMULATION_FACTOR = 5
|
||||
SIMULATION_FACTOR = 3
|
||||
|
||||
_no_layers_warning_preference = "view/no_layers_warning"
|
||||
|
||||
|
@ -192,17 +192,14 @@ class SimulationView(CuraView):
|
|||
return self._current_path_num
|
||||
|
||||
def setTime(self, time: float) -> None:
|
||||
cumulative_line_duration = self.cumulativeLineDuration()
|
||||
if len(cumulative_line_duration) > 0:
|
||||
self._current_time = time
|
||||
|
||||
left_i = 0
|
||||
right_i = self._max_paths - 1
|
||||
|
||||
cumulative_line_duration = self.cumulativeLineDuration()
|
||||
total_duration = cumulative_line_duration[-1]
|
||||
|
||||
# make an educated guess about where to start
|
||||
i = int(right_i * max(0.0, min(1.0, self._current_time / total_duration)))
|
||||
|
||||
# binary search for the correct path
|
||||
while left_i < right_i:
|
||||
if cumulative_line_duration[i] <= self._current_time:
|
||||
|
@ -227,6 +224,8 @@ class SimulationView(CuraView):
|
|||
:param time_increase: The amount of time to advance (in seconds).
|
||||
:return: True if the time was advanced, False if the end of the simulation was reached.
|
||||
"""
|
||||
total_duration = 0.0
|
||||
if len(self.cumulativeLineDuration()) > 0:
|
||||
total_duration = self.cumulativeLineDuration()[-1]
|
||||
|
||||
if self._current_time + time_increase > total_duration:
|
||||
|
@ -250,7 +249,9 @@ class SimulationView(CuraView):
|
|||
self._cumulative_line_duration = {}
|
||||
self._cumulative_line_duration[self.getCurrentLayer()] = []
|
||||
total_duration = 0.0
|
||||
for polyline in self.getLayerData().polygons:
|
||||
polylines = self.getLayerData()
|
||||
if polylines is not None:
|
||||
for polyline in polylines.polygons:
|
||||
for line_duration in list((polyline.lineLengths / polyline.lineFeedrates)[0]):
|
||||
total_duration += line_duration / SimulationView.SIMULATION_FACTOR
|
||||
self._cumulative_line_duration[self.getCurrentLayer()].append(total_duration)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue