using numpy for array calculation

CURA-7647
This commit is contained in:
saumya.jain 2023-11-08 13:29:47 +05:30
parent efda0aaba4
commit 457cecba59
3 changed files with 4 additions and 4 deletions

View file

@ -189,8 +189,8 @@ class LayerPolygon:
@property @property
def lineLengths(self): def lineLengths(self):
return [math.sqrt(sum((b - a) ** 2 for a, b in zip(self._data[i], self._data[i + 1]))) data_array = numpy.array(self._data)
for i in range(len(self._data) - 1)] return numpy.linalg.norm(data_array[1:] - data_array[:-1], axis=1)
@property @property
def data(self): def data(self):

View file

@ -403,7 +403,7 @@ class SimulationView(CuraView):
return self._max_feedrate return self._max_feedrate
def getSimulationTime(self) -> list: def getSimulationTime(self) -> list:
return [length / feedrate for length, feedrate in zip(self._visible_lengths[self._current_layer_num], self._current_feedrates[self._current_layer_num])] return self._visible_lengths[self._current_layer_num] / self._current_feedrates[self._current_layer_num]
def getMinThickness(self) -> float: def getMinThickness(self) -> float:
if abs(self._min_thickness - sys.float_info.max) < 10: # Some lenience due to floating point rounding. if abs(self._min_thickness - sys.float_info.max) < 10: # Some lenience due to floating point rounding.

View file

@ -136,7 +136,7 @@ Item
Timer Timer
{ {
id: simulationTimer id: simulationTimer
interval: parseFloat(UM.SimulationView.getSimulationTime[pathNumber]).toFixed(2) //10 //dont change interval: parseFloat(UM.SimulationView.getSimulationTime[pathNumber]).toFixed(2)
running: false running: false
repeat: true repeat: true
property int pathNumber : 0 property int pathNumber : 0