From b40cf28a839d4152bbc8dedef0b7fc5d4a3ea4cf Mon Sep 17 00:00:00 2001 From: "qing.zhang" Date: Tue, 9 Apr 2024 14:58:52 +0800 Subject: [PATCH] FIX: seam and unretarct pos error on smooth vase Jira: none casused by invalid path of smooth vase mode Signed-off-by: qing.zhang Change-Id: Ib597e8c05760886aae2c42e42e8d46e82b844578 --- src/libslic3r/GCode/SpiralVase.cpp | 16 +++++++++++----- src/libslic3r/GCodeReader.hpp | 1 + 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/libslic3r/GCode/SpiralVase.cpp b/src/libslic3r/GCode/SpiralVase.cpp index 5f0e77300..cb3e01d72 100644 --- a/src/libslic3r/GCode/SpiralVase.cpp +++ b/src/libslic3r/GCode/SpiralVase.cpp @@ -173,13 +173,19 @@ std::string SpiralVase::process_layer(const std::string &gcode, bool last_layer) if (found && dist < max_xy_dist_for_smoothing) { // Interpolate between the point on this layer and the point on the previous layer SpiralVase::SpiralPoint target = SpiralVaseHelpers::add(SpiralVaseHelpers::scale(nearestp, 1 - factor), SpiralVaseHelpers::scale(p, factor)); - line.set(reader, X, target.x); - line.set(reader, Y, target.y); + + // BBS: remove too short movement // We need to figure out the distance of this new line! float modified_dist_XY = SpiralVaseHelpers::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; + if (modified_dist_XY < 0.001) + line.clear(); + else { + line.set(reader, X, target.x); + line.set(reader, Y, target.y); + // 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; } diff --git a/src/libslic3r/GCodeReader.hpp b/src/libslic3r/GCodeReader.hpp index ea0df3dd7..52a37dde5 100644 --- a/src/libslic3r/GCodeReader.hpp +++ b/src/libslic3r/GCodeReader.hpp @@ -26,6 +26,7 @@ public: const std::string_view comment() const { size_t pos = m_raw.find(';'); return (pos == std::string::npos) ? std::string_view() : std::string_view(m_raw).substr(pos + 1); } + void clear() { m_raw.clear(); } bool has(Axis axis) const { return (m_mask & (1 << int(axis))) != 0; } float value(Axis axis) const { return m_axis[axis]; } bool has(char axis) const;