Skip to content

Commit

Permalink
SPE-2201: Fix deretractions (tiny extrusions) when the spiral vase is…
Browse files Browse the repository at this point in the history
… enabled.
  • Loading branch information
hejllukas authored and lukasmatena committed Mar 27, 2024
1 parent 3418a4c commit 9b252b1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/libslic3r/GCode/GCodeWriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ class GCodeFormatter {
{ return { quantize(pt.x(), XYZF_EXPORT_DIGITS), quantize(pt.y(), XYZF_EXPORT_DIGITS) }; }
static Vec3d quantize(const Vec3d &pt)
{ return { quantize(pt.x(), XYZF_EXPORT_DIGITS), quantize(pt.y(), XYZF_EXPORT_DIGITS), quantize(pt.z(), XYZF_EXPORT_DIGITS) }; }
static Vec2d quantize(const Vec2f &pt)
{ return { quantize(double(pt.x()), XYZF_EXPORT_DIGITS), quantize(double(pt.y()), XYZF_EXPORT_DIGITS) }; }

void emit_axis(const char axis, const double v, size_t digits);

Expand Down
11 changes: 10 additions & 1 deletion src/libslic3r/GCode/SpiralVase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,11 @@ std::string SpiralVase::process_layer(const std::string &gcode, bool last_layer)
transition_line.set(reader, E, line.e() * (1.f - factor), 5);
transition_gcode += transition_line.raw() + '\n';
}

// This line is the core of Spiral Vase mode, ramp up the Z smoothly
line.set(reader, Z, z + factor * layer_height);

bool emit_gcode_line = true;
if (smooth_spiral) {
// Now we also need to try to interpolate X and Y
Vec2f p(line.x(), line.y()); // Get current x/y coordinates
Expand All @@ -118,6 +121,10 @@ std::string SpiralVase::process_layer(const std::string &gcode, bool last_layer)
if (nearest_distance < max_xy_smoothing) {
// Interpolate between the point on this layer and the point on the previous layer
Vec2f target = nearest_pt.cast<float>() * (1.f - factor) + p * factor;

// We will emit a new g-code line only when XYZ positions differ from the previous g-code line.
emit_gcode_line = GCodeFormatter::quantize(last_point) != GCodeFormatter::quantize(target);

line.set(reader, X, target.x());
line.set(reader, Y, target.y());
// We need to figure out the distance of this new line!
Expand All @@ -129,7 +136,9 @@ std::string SpiralVase::process_layer(const std::string &gcode, bool last_layer)
last_point = p;
}
}
new_gcode += line.raw() + '\n';

if (emit_gcode_line)
new_gcode += line.raw() + '\n';
}
return;
/* Skip travel moves: the move to first perimeter point will
Expand Down

0 comments on commit 9b252b1

Please sign in to comment.