diff --git a/cura/LayerDataBuilder.py b/cura/LayerDataBuilder.py index dcc3991833..1de2302f77 100644 --- a/cura/LayerDataBuilder.py +++ b/cura/LayerDataBuilder.py @@ -48,8 +48,10 @@ class LayerDataBuilder(MeshBuilder): self._layers[layer].setThickness(thickness) - # material color map: [r, g, b, a] for each extruder row. - # line_type_brightness: compatibility layer view uses line type brightness of 0.5 + ## Return the layer data as LayerData. + # + # \param material_color_map: [r, g, b, a] for each extruder row. + # \param line_type_brightness: compatibility layer view uses line type brightness of 0.5 def build(self, material_color_map, line_type_brightness = 1.0): vertex_count = 0 index_count = 0 @@ -75,9 +77,12 @@ class LayerDataBuilder(MeshBuilder): self.addColors(colors) self.addIndices(indices.flatten()) + # Note: we're using numpy indexing here. + # See also: https://docs.scipy.org/doc/numpy/reference/arrays.indexing.html material_colors = numpy.zeros((line_dimensions.shape[0], 4), dtype=numpy.float32) for extruder_nr in range(material_color_map.shape[0]): material_colors[extruders == extruder_nr] = material_color_map[extruder_nr] + # Set material_colors with indices where line_types (also numpy array) == MoveCombingType material_colors[line_types == LayerPolygon.MoveCombingType] = colors[line_types == LayerPolygon.MoveCombingType] material_colors[line_types == LayerPolygon.MoveRetractionType] = colors[line_types == LayerPolygon.MoveRetractionType] diff --git a/cura/LayerPolygon.py b/cura/LayerPolygon.py index 90bc123548..577de9e40b 100644 --- a/cura/LayerPolygon.py +++ b/cura/LayerPolygon.py @@ -19,10 +19,13 @@ class LayerPolygon: __jump_map = numpy.logical_or(numpy.logical_or(numpy.arange(11) == NoneType, numpy.arange(11) == MoveCombingType), numpy.arange(11) == MoveRetractionType) - ## LayerPolygon - # line_thicknesses: array with type as index and thickness as value - def __init__(self, mesh, extruder, line_types, data, line_widths, line_thicknesses): - self._mesh = mesh + ## LayerPolygon, used in ProcessSlicedLayersJob + # \param extruder + # \param line_types array with line_types + # \param data new_points + # \param line_widths array with line widths + # \param line_thicknesses: array with type as index and thickness as value + def __init__(self, extruder, line_types, data, line_widths, line_thicknesses): self._extruder = extruder self._types = line_types self._data = data diff --git a/plugins/CuraEngineBackend/ProcessSlicedLayersJob.py b/plugins/CuraEngineBackend/ProcessSlicedLayersJob.py index 7648307de5..0f46cc96bf 100644 --- a/plugins/CuraEngineBackend/ProcessSlicedLayersJob.py +++ b/plugins/CuraEngineBackend/ProcessSlicedLayersJob.py @@ -139,7 +139,7 @@ class ProcessSlicedLayersJob(Job): new_points[:, 1] = points[:, 2] new_points[:, 2] = -points[:, 1] - this_poly = LayerPolygon.LayerPolygon(layer_data, extruder, line_types, new_points, line_widths, line_thicknesses) + this_poly = LayerPolygon.LayerPolygon(extruder, line_types, new_points, line_widths, line_thicknesses) this_poly.buildCache() this_layer.polygons.append(this_poly)