diff options
author | kliment <kliment.yanev@gmail.com> | 2021-01-28 23:39:59 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-28 23:39:59 +0300 |
commit | 567f06d3899d2e0cf2a2e9bd1ddaad8b0906e8b9 (patch) | |
tree | 723c5d48ea38882fce9791f24bf329a668037ab9 | |
parent | bd66baed82cceb1ec17135cca527edb31c8e9c0a (diff) | |
parent | e99dac2f7a319f57ab1232e703e54ef6c911a5e7 (diff) |
Merge pull request #1131 from IgorYeremin/arc-rendering-fixes
Minor arc interpolation fixes
-rw-r--r-- | printrun/gl/libtatlin/actors.py | 20 | ||||
-rw-r--r-- | printrun/utils.py | 2 |
2 files changed, 14 insertions, 8 deletions
diff --git a/printrun/gl/libtatlin/actors.py b/printrun/gl/libtatlin/actors.py index 3f510e6..4571c21 100644 --- a/printrun/gl/libtatlin/actors.py +++ b/printrun/gl/libtatlin/actors.py @@ -346,14 +346,14 @@ def interpolate_arcs(gline, prev_gline): for t in range(segments): a = t / segments * a_delta + a_start - mid = ( + mid = (( cx + math.cos(a) * r, cy + math.sin(a) * r, z0 + t / segments * dz - ) + ), True) yield mid - yield (gline.current_x, gline.current_y, gline.current_z) + yield ((gline.current_x, gline.current_y, gline.current_z), False) # last segment of this line class GcodeModel(Model): @@ -444,6 +444,7 @@ class GcodeModel(Model): prev_move_angle = None prev_pos = (0, 0, 0) prev_gline = None + prev_extruding = False layer_idx = 0 self.printed_until = 0 @@ -473,10 +474,10 @@ class GcodeModel(Model): for gline_idx, gline in enumerate(layer): if not gline.is_move: continue - if gline.x is None and gline.y is None and gline.z is None: + if gline.x is None and gline.y is None and gline.z is None and gline.j is None and gline.i is None: continue has_movement = True - for current_pos in interpolate_arcs(gline, prev_gline): + for (current_pos, interpolated) in interpolate_arcs(gline, prev_gline): if not gline.extruding: if self.travels.size < (travel_vertex_k + 100 * 6): # arc interpolation extra points allocation @@ -507,7 +508,7 @@ class GcodeModel(Model): new_indices = [] new_vertices = [] new_normals = [] - if prev_gline and prev_gline.extruding: + if prev_gline and prev_gline.extruding or prev_extruding: # Store previous vertices indices prev_id = vertex_k // 3 - 4 avg_move_normal_x = (prev_move_normal_x + move_normal_x) / 2 @@ -605,7 +606,7 @@ class GcodeModel(Model): first + 2, first + 3) next_move = get_next_move(model_data, layer_idx, gline_idx) - next_is_extruding = next_move and next_move.extruding + next_is_extruding = interpolated or next_move and next_move.extruding if not next_is_extruding: # Compute caps and link everything p1x = current_pos[0] - path_halfwidth * move_normal_x @@ -658,7 +659,10 @@ class GcodeModel(Model): prev_move_angle = move_angle prev_pos = current_pos + prev_extruding = gline.extruding + prev_gline = gline + prev_extruding = gline.extruding count_travel_indices.append(travel_vertex_k // 3) count_print_indices.append(index_k) count_print_vertices.append(vertex_k // 3) @@ -954,7 +958,7 @@ class GcodeModelLight(Model): continue has_movement = True - for current_pos in interpolate_arcs(gline, prev_gline): + for (current_pos, interpolated) in interpolate_arcs(gline, prev_gline): if self.vertices.size < (vertex_k + 100 * 6): # arc interpolation extra points allocation diff --git a/printrun/utils.py b/printrun/utils.py index 27fb351..1a245b6 100644 --- a/printrun/utils.py +++ b/printrun/utils.py @@ -186,6 +186,8 @@ class RemainingTimeEstimator: return (0, 0) if idx == self.last_idx: return self.last_estimate + if idx >= len(self.gcode.layer_idxs): + return self.last_estimate layer, line = self.gcode.idxs(idx) layer_progress = (1 - (float(line + 1) / self.current_layer_lines)) remaining = layer_progress * self.current_layer_estimate + self.remaining_layers_estimate |