mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 06:57:28 -06:00
D6: Fixed layers and line widths
This commit is contained in:
parent
f8874bfe21
commit
33cd386556
2 changed files with 33 additions and 14 deletions
|
@ -7,3 +7,6 @@ class SliceableObjectDecorator(SceneNodeDecorator):
|
||||||
|
|
||||||
def isSliceable(self):
|
def isSliceable(self):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def __deepcopy__(self, memo):
|
||||||
|
return type(self)()
|
||||||
|
|
|
@ -100,7 +100,7 @@ class GCodeReader(MeshReader):
|
||||||
line_types = numpy.empty((count - 1, 1), numpy.int32)
|
line_types = numpy.empty((count - 1, 1), numpy.int32)
|
||||||
line_widths = numpy.empty((count - 1, 1), numpy.float32)
|
line_widths = numpy.empty((count - 1, 1), numpy.float32)
|
||||||
# TODO: need to calculate actual line width based on E values
|
# TODO: need to calculate actual line width based on E values
|
||||||
line_widths[:, 0] = 0.5
|
line_widths[:, 0] = 0.4
|
||||||
points = numpy.empty((count, 3), numpy.float32)
|
points = numpy.empty((count, 3), numpy.float32)
|
||||||
i = 0
|
i = 0
|
||||||
for point in path:
|
for point in path:
|
||||||
|
@ -109,6 +109,8 @@ class GCodeReader(MeshReader):
|
||||||
points[i, 2] = -point[1]
|
points[i, 2] = -point[1]
|
||||||
if i > 0:
|
if i > 0:
|
||||||
line_types[i - 1] = point[3]
|
line_types[i - 1] = point[3]
|
||||||
|
if point[3] in [LayerPolygon.MoveCombingType, LayerPolygon.MoveRetractionType]:
|
||||||
|
line_widths[i - 1] = 0.2
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
this_poly = LayerPolygon(self._layer_data_builder, self._extruder, line_types, points, line_widths)
|
this_poly = LayerPolygon(self._layer_data_builder, self._extruder, line_types, points, line_widths)
|
||||||
|
@ -136,7 +138,8 @@ class GCodeReader(MeshReader):
|
||||||
else:
|
else:
|
||||||
path.append([x, y, z, LayerPolygon.MoveCombingType])
|
path.append([x, y, z, LayerPolygon.MoveCombingType])
|
||||||
if z_changed:
|
if z_changed:
|
||||||
if len(path) > 1 and z > 0:
|
if not self._is_layers_in_file:
|
||||||
|
if not self._is_layers_in_file and len(path) > 1 and z > 0:
|
||||||
if self._createPolygon(z, path):
|
if self._createPolygon(z, path):
|
||||||
self._layer += 1
|
self._layer += 1
|
||||||
path.clear()
|
path.clear()
|
||||||
|
@ -179,6 +182,7 @@ class GCodeReader(MeshReader):
|
||||||
self._extruder = T
|
self._extruder = T
|
||||||
if self._extruder + 1 > len(position.e):
|
if self._extruder + 1 > len(position.e):
|
||||||
position.e.extend([0] * (self._extruder - len(position.e) + 1))
|
position.e.extend([0] * (self._extruder - len(position.e) + 1))
|
||||||
|
if not self._is_layers_in_file:
|
||||||
if len(path) > 1 and position[2] > 0:
|
if len(path) > 1 and position[2] > 0:
|
||||||
if self._createPolygon(position[2], path):
|
if self._createPolygon(position[2], path):
|
||||||
self._layer += 1
|
self._layer += 1
|
||||||
|
@ -188,6 +192,7 @@ class GCodeReader(MeshReader):
|
||||||
return position
|
return position
|
||||||
|
|
||||||
_type_keyword = ";TYPE:"
|
_type_keyword = ";TYPE:"
|
||||||
|
_layer_keyword = ";LAYER:"
|
||||||
|
|
||||||
def read(self, file_name):
|
def read(self, file_name):
|
||||||
Logger.log("d", "Preparing to load %s" % file_name)
|
Logger.log("d", "Preparing to load %s" % file_name)
|
||||||
|
@ -197,6 +202,7 @@ class GCodeReader(MeshReader):
|
||||||
scene_node.getBoundingBox = self._getNullBoundingBox # Manually set bounding box, because mesh doesn't have mesh data
|
scene_node.getBoundingBox = self._getNullBoundingBox # Manually set bounding box, because mesh doesn't have mesh data
|
||||||
|
|
||||||
glist = []
|
glist = []
|
||||||
|
self._is_layers_in_file = False
|
||||||
|
|
||||||
|
|
||||||
Logger.log("d", "Opening file %s" % file_name)
|
Logger.log("d", "Opening file %s" % file_name)
|
||||||
|
@ -207,6 +213,8 @@ class GCodeReader(MeshReader):
|
||||||
for line in file:
|
for line in file:
|
||||||
file_lines += 1
|
file_lines += 1
|
||||||
glist.append(line)
|
glist.append(line)
|
||||||
|
if not self._is_layers_in_file and line[:len(self._layer_keyword)] == self._layer_keyword:
|
||||||
|
self._is_layers_in_file = True
|
||||||
file.seek(0)
|
file.seek(0)
|
||||||
|
|
||||||
file_step = max(math.floor(file_lines / 100), 1)
|
file_step = max(math.floor(file_lines / 100), 1)
|
||||||
|
@ -245,6 +253,14 @@ class GCodeReader(MeshReader):
|
||||||
self._layer_type = LayerPolygon.SupportType
|
self._layer_type = LayerPolygon.SupportType
|
||||||
elif type == "FILL":
|
elif type == "FILL":
|
||||||
self._layer_type = LayerPolygon.InfillType
|
self._layer_type = LayerPolygon.InfillType
|
||||||
|
if self._is_layers_in_file and line[:len(self._layer_keyword)] == self._layer_keyword:
|
||||||
|
try:
|
||||||
|
layer_number = int(line[len(self._layer_keyword):])
|
||||||
|
self._createPolygon(current_position[2], current_path)
|
||||||
|
current_path.clear()
|
||||||
|
self._layer = layer_number
|
||||||
|
except:
|
||||||
|
pass
|
||||||
if line[0] == ";":
|
if line[0] == ";":
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -255,7 +271,7 @@ class GCodeReader(MeshReader):
|
||||||
if T is not None:
|
if T is not None:
|
||||||
current_position = self._processTCode(T, line, current_position, current_path)
|
current_position = self._processTCode(T, line, current_position, current_path)
|
||||||
|
|
||||||
if len(current_path) > 1 and current_position[2] > 0:
|
if not self._is_layers_in_file and len(current_path) > 1 and current_position[2] > 0:
|
||||||
if self._createPolygon(current_position[2], current_path):
|
if self._createPolygon(current_position[2], current_path):
|
||||||
self._layer += 1
|
self._layer += 1
|
||||||
current_path.clear()
|
current_path.clear()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue