Be robust against faulty data from the engine

We modify the line types that we get from the engine so that it's always within range.

This was a bug I found during development of CURA-3903.
This commit is contained in:
Ghostkeeper 2017-06-02 11:35:11 +02:00
parent a58926263c
commit f719be2484
No known key found for this signature in database
GPG Key ID: C5F96EE2BC0F7E75

View File

@ -1,4 +1,6 @@
from UM.Math.Color import Color # Copyright (c) 2017 Ultimaker B.V.
# Cura is released under the terms of the AGPLv3 or higher.
from UM.Application import Application from UM.Application import Application
from typing import Any from typing import Any
import numpy import numpy
@ -16,8 +18,9 @@ class LayerPolygon:
MoveCombingType = 8 MoveCombingType = 8
MoveRetractionType = 9 MoveRetractionType = 9
SupportInterfaceType = 10 SupportInterfaceType = 10
__number_of_types = 11
__jump_map = numpy.logical_or(numpy.logical_or(numpy.arange(11) == NoneType, numpy.arange(11) == MoveCombingType), numpy.arange(11) == MoveRetractionType) __jump_map = numpy.logical_or(numpy.logical_or(numpy.arange(__number_of_types) == NoneType, numpy.arange(__number_of_types) == MoveCombingType), numpy.arange(__number_of_types) == MoveRetractionType)
## LayerPolygon, used in ProcessSlicedLayersJob ## LayerPolygon, used in ProcessSlicedLayersJob
# \param extruder # \param extruder
@ -28,6 +31,9 @@ class LayerPolygon:
def __init__(self, extruder, line_types, data, line_widths, line_thicknesses): def __init__(self, extruder, line_types, data, line_widths, line_thicknesses):
self._extruder = extruder self._extruder = extruder
self._types = line_types self._types = line_types
for i in range(len(self._types)):
if self._types[i] >= self.__number_of_types: #Got faulty line data from the engine.
self._types[i] = self.NoneType
self._data = data self._data = data
self._line_widths = line_widths self._line_widths = line_widths
self._line_thicknesses = line_thicknesses self._line_thicknesses = line_thicknesses