From 298b730589371d39fe4a85851a9c72f87fc22d8e Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Wed, 9 Dec 2020 14:53:54 +0100 Subject: [PATCH] Implemented linear tapering of extrusion rate for the 1st spiral vase layer above the solid infill. Should fix first layer of vase (after bottom layers) is bulging (0.6nozzle, 0.4 layerhight) #3712 Adjust flow of the "second" layer in spiral vase mode #2795 --- src/libslic3r/GCode.cpp | 7 ++++--- src/libslic3r/GCode/SpiralVase.cpp | 14 ++++++++++---- src/libslic3r/GCode/SpiralVase.hpp | 12 ++++++++++-- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 7deb38349..fab7a7058 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -1764,6 +1764,7 @@ void GCode::process_layer( // Check whether it is possible to apply the spiral vase logic for this layer. // Just a reminder: A spiral vase mode is allowed for a single object, single material print only. + m_enable_loop_clipping = true; if (m_spiral_vase && layers.size() == 1 && support_layer == nullptr) { bool enable = (layer.id() > 0 || print.config().brim_width.value == 0.) && (layer.id() >= (size_t)print.config().skirt_height.value && ! print.has_infinite_skirt()); if (enable) { @@ -1775,10 +1776,10 @@ void GCode::process_layer( break; } } - m_spiral_vase->enable = enable; + m_spiral_vase->enable(enable); + // If we're going to apply spiralvase to this layer, disable loop clipping. + m_enable_loop_clipping = !enable; } - // If we're going to apply spiralvase to this layer, disable loop clipping - m_enable_loop_clipping = ! m_spiral_vase || ! m_spiral_vase->enable; std::string gcode; diff --git a/src/libslic3r/GCode/SpiralVase.cpp b/src/libslic3r/GCode/SpiralVase.cpp index a3c190069..c8df9fb2d 100644 --- a/src/libslic3r/GCode/SpiralVase.cpp +++ b/src/libslic3r/GCode/SpiralVase.cpp @@ -16,7 +16,7 @@ std::string SpiralVase::process_layer(const std::string &gcode) // If we're not going to modify G-code, just feed it to the reader // in order to update positions. - if (! this->enable) { + if (! m_enabled) { m_reader.parse_buffer(gcode); return gcode; } @@ -50,7 +50,10 @@ std::string SpiralVase::process_layer(const std::string &gcode) z -= layer_height; std::string new_gcode; - m_reader.parse_buffer(gcode, [&new_gcode, &z, &layer_height, &total_layer_length] + bool transition = m_transition_layer; + float layer_height_factor = layer_height / total_layer_length; + float len = 0.f; + m_reader.parse_buffer(gcode, [&new_gcode, &z, total_layer_length, layer_height_factor, transition, &len] (GCodeReader &reader, GCodeReader::GCodeLine line) { if (line.cmd_is("G1")) { if (line.has_z()) { @@ -64,8 +67,11 @@ std::string SpiralVase::process_layer(const std::string &gcode) if (dist_XY > 0) { // horizontal move if (line.extruding(reader)) { - z += dist_XY * layer_height / total_layer_length; - line.set(reader, Z, z); + len += dist_XY; + line.set(reader, Z, z + len * layer_height_factor); + if (transition && line.has(E)) + // Transition layer, modulate the amount of extrusion from zero to the final value. + line.set(reader, E, line.value(E) * len / total_layer_length); new_gcode += line.raw() + '\n'; } return; diff --git a/src/libslic3r/GCode/SpiralVase.hpp b/src/libslic3r/GCode/SpiralVase.hpp index 496c1425c..5353901fe 100644 --- a/src/libslic3r/GCode/SpiralVase.hpp +++ b/src/libslic3r/GCode/SpiralVase.hpp @@ -8,18 +8,26 @@ namespace Slic3r { class SpiralVase { public: - bool enable = false; - SpiralVase(const PrintConfig &config) : m_config(&config) { m_reader.z() = (float)m_config->z_offset; m_reader.apply_config(*m_config); }; + + void enable(bool en) { + m_transition_layer = en && ! m_enabled; + m_enabled = en; + } + std::string process_layer(const std::string &gcode); private: const PrintConfig *m_config; GCodeReader m_reader; + + bool m_enabled = false; + // First spiral vase layer. Layer height has to be ramped up from zero to the target layer height. + bool m_transition_layer = false; }; }