diff --git a/plugins/CuraEngineBackend/LayerData.py b/plugins/CuraEngineBackend/LayerData.py index 1c4c2a0b9c..15edc16e14 100644 --- a/plugins/CuraEngineBackend/LayerData.py +++ b/plugins/CuraEngineBackend/LayerData.py @@ -98,34 +98,26 @@ class Polygon(): SkinType = 3 SupportType = 4 SkirtType = 5 + InfillType = 6 + SupportInfillType = 7 - def __init__(self, mesh, type, data): + def __init__(self, mesh, type, data, line_width): super().__init__() self._mesh = mesh self._type = type self._data = data + self._line_width = line_width / 1000 def build(self): self._begin = self._mesh._vertex_count self._mesh.addVertices(self._data) self._end = self._begin + len(self._data) - 1 - color = None - if self._type == self.Inset0Type: - color = [1, 0, 0, 1] - elif self._type == self.InsetXType: - color = [0, 1, 0, 1] - elif self._type == self.SkinType: - color = [1, 1, 0, 1] - elif self._type == self.SupportType: - color = [0, 1, 1, 1] - elif self._type == self.SkirtType: - color = [0, 1, 1, 1] - else: - color = [1, 1, 1, 1] + color = self.getColor() + color[3] = 2.0 colors = [color for i in range(len(self._data))] - self._mesh.addColors(numpy.array(colors, dtype=numpy.float32)) + self._mesh.addColors(numpy.array(colors, dtype=numpy.float32) * 0.5) indices = [] for i in range(self._begin, self._end): @@ -136,6 +128,24 @@ class Polygon(): indices.append(self._begin) self._mesh.addIndices(numpy.array(indices, dtype=numpy.int32)) + def getColor(self): + if self._type == self.Inset0Type: + return [1.0, 0.0, 0.0, 1.0] + elif self._type == self.InsetXType: + return [0.0, 1.0, 0.0, 1.0] + elif self._type == self.SkinType: + return [1.0, 1.0, 0.0, 1.0] + elif self._type == self.SupportType: + return [0.0, 1.0, 1.0, 1.0] + elif self._type == self.SkirtType: + return [0.0, 1.0, 1.0, 1.0] + elif self._type == self.InfillType: + return [1.0, 1.0, 0.0, 1.0] + elif self._type == self.SupportInfillType: + return [0.0, 1.0, 1.0, 1.0] + else: + return [1.0, 1.0, 1.0, 1.0] + @property def type(self): return self._type @@ -146,4 +156,8 @@ class Polygon(): @property def elementCount(self): - return (self._end - self._begin) * 2 #The range of vertices multiplied by 2 since each vertex is used twice + return ((self._end - self._begin) + 1) * 2 #The range of vertices multiplied by 2 since each vertex is used twice + + @property + def lineWidth(self): + return self._line_width diff --git a/plugins/CuraEngineBackend/ProcessSlicedObjectListJob.py b/plugins/CuraEngineBackend/ProcessSlicedObjectListJob.py index cef8ff754f..6113da78a0 100644 --- a/plugins/CuraEngineBackend/ProcessSlicedObjectListJob.py +++ b/plugins/CuraEngineBackend/ProcessSlicedObjectListJob.py @@ -57,8 +57,8 @@ class ProcessSlicedObjectListJob(Job): center = [settings.getSettingValueByKey("machine_width") / 2, 0.0, -settings.getSettingValueByKey("machine_depth") / 2] points -= numpy.array(center) + layerData.addPolygon(layer.id, polygon.type, points, polygon.line_width) - layerData.addPolygon(layer.id, polygon.type, points) # We are done processing all the layers we got from the engine, now create a mesh out of the data layerData.build() mesh.layerData = layerData