Skip to content

Commit

Permalink
- Increasing E to 5 decimal digits (I observed uneven flow with less …
Browse files Browse the repository at this point in the history
…than that)

- Excluding all travel moves (I saw a bug where somehow we ended up with travel moves within the print so excluding all travel moves)
  • Loading branch information
aboktor committed Dec 13, 2023
1 parent fea308e commit 1749ac8
Showing 1 changed file with 46 additions and 49 deletions.
95 changes: 46 additions & 49 deletions src/libslic3r/GCode/SpiralVase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,59 +136,56 @@ std::string SpiralVase::process_layer(const std::string &gcode, bool last_layer)
return;
} else {
float dist_XY = line.dist_XY(reader);
if (dist_XY > 0) {
// horizontal move
if (line.extruding(reader)) { // We need this to exclude retract and wipe moves!
len += dist_XY;
float factor = len / total_layer_length;
if (transition_in)
// Transition layer, interpolate the amount of extrusion from zero to the final value.
line.set(reader, E, line.e() * factor);
else if (transition_out) {
// We want the last layer to ramp down extrusion, but without changing z height!
// So clone the line before we mess with its Z and duplicate it into a new layer that ramps down E
// We add this new layer at the very end
GCodeReader::GCodeLine transitionLine(line);
transitionLine.set(reader, E, line.e() * (1 - factor));
transition_gcode += transitionLine.raw() + '\n';
}
// This line is the core of Spiral Vase mode, ramp up the Z smoothly
line.set(reader, Z, z + factor * layer_height);
if (smooth_spiral) {
// Now we also need to try to interpolate X and Y
SpiralPoint p(line.x(), line.y()); // Get current x/y coordinates
current_layer->push_back(p); // Store that point for later use on the next layer

if (previous_layer != NULL) {
bool found = false;
float dist = 0;
SpiralPoint nearestp = nearest_point_on_polygon(p, previous_layer, found, dist);
if (found && dist < max_xy_dist_for_smoothing) {
// Interpolate between the point on this layer and the point on the previous layer
SpiralPoint target = add(scale(nearestp, 1 - factor), scale(p, factor));
line.set(reader, X, target.x);
line.set(reader, Y, target.y);
// We need to figure out the distance of this new line!
float modified_dist_XY = distance(last_point, target);
line.set(reader, E,
line.e() * modified_dist_XY / dist_XY); // Scale the extrusion amount according to change in length
last_point = target;
} else {
last_point = p;
}
// horizontal move that is not retract or wipe
if (dist_XY > 0 && line.extruding(reader)) {
len += dist_XY;
float factor = len / total_layer_length;
if (transition_in)
// Transition layer, interpolate the amount of extrusion from zero to the final value.
line.set(reader, E, line.e() * factor, 5 /*decimal_digits*/);
else if (transition_out) {
// We want the last layer to ramp down extrusion, but without changing z height!
// So clone the line before we mess with its Z and duplicate it into a new layer that ramps down E
// We add this new layer at the very end
GCodeReader::GCodeLine transitionLine(line);
transitionLine.set(reader, E, line.e() * (1 - factor), 5 /*decimal_digits*/);
transition_gcode += transitionLine.raw() + '\n';
}
// This line is the core of Spiral Vase mode, ramp up the Z smoothly
line.set(reader, Z, z + factor * layer_height);
if (smooth_spiral) {
// Now we also need to try to interpolate X and Y
SpiralPoint p(line.x(), line.y()); // Get current x/y coordinates
current_layer->push_back(p); // Store that point for later use on the next layer
if (previous_layer != NULL) {
bool found = false;
float dist = 0;
SpiralPoint nearestp = nearest_point_on_polygon(p, previous_layer, found, dist);
if (found && dist < max_xy_dist_for_smoothing) {
// Interpolate between the point on this layer and the point on the previous layer
SpiralPoint target = add(scale(nearestp, 1 - factor), scale(p, factor));
line.set(reader, X, target.x);
line.set(reader, Y, target.y);
// We need to figure out the distance of this new line!
float modified_dist_XY = distance(last_point, target);
// Scale the extrusion amount according to change in length
line.set(reader, E, line.e() * modified_dist_XY / dist_XY, 5 /*decimal_digits*/);
last_point = target;
} else {
last_point = p;
}
}
new_gcode += line.raw() + '\n';
}
return;
/* Skip travel moves: the move to first perimeter point will
cause a visible seam when loops are not aligned in XY; by skipping
it we blend the first loop move in the XY plane (although the smoothness
of such blend depend on how long the first segment is; maybe we should
enforce some minimum length?).
When smooth_spiral is enabled, we're gonna end up exactly where the next layer should
start anyway, so we don't need the travel move */
new_gcode += line.raw() + '\n';
}
return;
/* Skip travel moves: the move to first perimeter point will
cause a visible seam when loops are not aligned in XY; by skipping
it we blend the first loop move in the XY plane (although the smoothness
of such blend depend on how long the first segment is; maybe we should
enforce some minimum length?).
When smooth_spiral is enabled, we're gonna end up exactly where the next layer should
start anyway, so we don't need the travel move */
}
}
new_gcode += line.raw() + '\n';
Expand Down

0 comments on commit 1749ac8

Please sign in to comment.