diff options
Diffstat (limited to 'src/libslic3r/GCode/SpiralVase.cpp')
-rw-r--r-- | src/libslic3r/GCode/SpiralVase.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/libslic3r/GCode/SpiralVase.cpp b/src/libslic3r/GCode/SpiralVase.cpp index a3c190069..acb6ad034 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; } @@ -25,11 +25,11 @@ std::string SpiralVase::process_layer(const std::string &gcode) float total_layer_length = 0; float layer_height = 0; float z = 0.f; - bool set_z = false; { //FIXME Performance warning: This copies the GCodeConfig of the reader. GCodeReader r = m_reader; // clone + bool set_z = false; r.parse_buffer(gcode, [&total_layer_length, &layer_height, &z, &set_z] (GCodeReader &reader, const GCodeReader::GCodeLine &line) { if (line.cmd_is("G1")) { @@ -50,7 +50,14 @@ 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] + //FIXME Tapering of the transition layer only works reliably with relative extruder distances. + // For absolute extruder distances it will be switched off. + // Tapering the absolute extruder distances requires to process every extrusion value after the first transition + // layer. + bool transition = m_transition_layer && m_config->use_relative_e_distances.value; + 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 +71,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; |