diff options
-rw-r--r-- | cura/Layer.py | 16 | ||||
-rw-r--r-- | cura/LayerData.py | 3 | ||||
-rwxr-xr-x | cura/LayerDataBuilder.py | 1 |
3 files changed, 10 insertions, 10 deletions
diff --git a/cura/Layer.py b/cura/Layer.py index 869b84ed90..d5ef5c9bb4 100644 --- a/cura/Layer.py +++ b/cura/Layer.py @@ -1,10 +1,8 @@ -from .LayerPolygon import LayerPolygon - -from UM.Math.Vector import Vector from UM.Mesh.MeshBuilder import MeshBuilder import numpy + class Layer: def __init__(self, layer_id): self._id = layer_id @@ -80,8 +78,7 @@ class Layer: else: for polygon in self._polygons: line_count += polygon.jumpCount - - + # Reserve the neccesary space for the data upfront builder.reserveFaceAndVertexCount(2 * line_count, 4 * line_count) @@ -94,7 +91,7 @@ class Layer: # Line types of the points we want to draw line_types = polygon.types[index_mask] - # Shift the z-axis according to previous implementation. + # Shift the z-axis according to previous implementation. if make_mesh: points[polygon.isInfillOrSkinType(line_types), 1::3] -= 0.01 else: @@ -106,13 +103,14 @@ class Layer: # Scale all normals by the line width of the current line so we can easily offset. normals *= (polygon.lineWidths[index_mask.ravel()] / 2) - # Create 4 points to draw each line segment, points +- normals results in 2 points each. Reshape to one point per line + # Create 4 points to draw each line segment, points +- normals results in 2 points each. + # After this we reshape to one point per line. f_points = numpy.concatenate((points-normals, points+normals), 1).reshape((-1, 3)) - # __index_pattern defines which points to use to draw the two faces for each lines egment, the following linesegment is offset by 4 + + # __index_pattern defines which points to use to draw the two faces for each lines egment, the following linesegment is offset by 4 f_indices = ( self.__index_pattern + numpy.arange(0, 4 * len(normals), 4, dtype=numpy.int32).reshape((-1, 1)) ).reshape((-1, 3)) f_colors = numpy.repeat(polygon.mapLineTypeToColor(line_types), 4, 0) builder.addFacesWithColor(f_points, f_indices, f_colors) - return builder.build()
\ No newline at end of file diff --git a/cura/LayerData.py b/cura/LayerData.py index 3fe550c297..03dc6da45f 100644 --- a/cura/LayerData.py +++ b/cura/LayerData.py @@ -2,11 +2,12 @@ # Cura is released under the terms of the AGPLv3 or higher. from UM.Mesh.MeshData import MeshData + ## Class to holds the layer mesh and information about the layers. # Immutable, use LayerDataBuilder to create one of these. class LayerData(MeshData): def __init__(self, vertices = None, normals = None, indices = None, colors = None, uvs = None, file_name = None, - center_position = None, layers=None, element_counts=None, attributes=None): + center_position = None, layers=None, element_counts=None, attributes=None): super().__init__(vertices=vertices, normals=normals, indices=indices, colors=colors, uvs=uvs, file_name=file_name, center_position=center_position, attributes=attributes) self._layers = layers diff --git a/cura/LayerDataBuilder.py b/cura/LayerDataBuilder.py index df4b9e3218..2051d3a761 100755 --- a/cura/LayerDataBuilder.py +++ b/cura/LayerDataBuilder.py @@ -8,6 +8,7 @@ from .LayerData import LayerData import numpy + ## Builder class for constructing a LayerData object class LayerDataBuilder(MeshBuilder): def __init__(self): |