diff --git a/src/libslic3r/GCode/GCodeProcessor.cpp b/src/libslic3r/GCode/GCodeProcessor.cpp index 69dbddfaa4..3f3a4ed4b8 100644 --- a/src/libslic3r/GCode/GCodeProcessor.cpp +++ b/src/libslic3r/GCode/GCodeProcessor.cpp @@ -695,7 +695,9 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename, st if (!disable_m73 && !processed &&!is_temporary_decoration(gcode_line) && (GCodeReader::GCodeLine::cmd_is(gcode_line, "G1") || GCodeReader::GCodeLine::cmd_is(gcode_line, "G2") || - GCodeReader::GCodeLine::cmd_is(gcode_line, "G3"))) { + GCodeReader::GCodeLine::cmd_is(gcode_line, "G3") || + GCodeReader::GCodeLine::cmd_is(gcode_line, "G10")|| + GCodeReader::GCodeLine::cmd_is(gcode_line, "G11"))) { // remove temporary lines, add lines M73 where needed unsigned int extra_lines_count = process_line_move(g1_lines_counter ++); if (extra_lines_count > 0) @@ -3813,14 +3815,18 @@ void GCodeProcessor::process_G29(const GCodeReader::GCodeLine& line) void GCodeProcessor::process_G10(const GCodeReader::GCodeLine& line) { - // stores retract move - store_move_vertex(EMoveType::Retract); + GCodeReader::GCodeLine g10; + g10.set(Axis::E, -this->m_parser.config().retraction_length.get_at(m_extruder_id)); + g10.set(Axis::F, this->m_parser.config().retraction_speed.get_at(m_extruder_id) * 60); + process_G1(g10); } void GCodeProcessor::process_G11(const GCodeReader::GCodeLine& line) { - // stores unretract move - store_move_vertex(EMoveType::Unretract); + GCodeReader::GCodeLine g11; + g11.set(Axis::E, this->m_parser.config().retraction_length.get_at(m_extruder_id) + this->m_parser.config().retract_restart_extra.get_at(m_extruder_id)); + g11.set(Axis::F, this->m_parser.config().deretraction_speed.get_at(m_extruder_id) * 60); + process_G1(g11); } void GCodeProcessor::process_G20(const GCodeReader::GCodeLine& line) diff --git a/src/libslic3r/GCode/SpiralVase.cpp b/src/libslic3r/GCode/SpiralVase.cpp index 8462e73111..8ffe7ef95b 100644 --- a/src/libslic3r/GCode/SpiralVase.cpp +++ b/src/libslic3r/GCode/SpiralVase.cpp @@ -131,7 +131,7 @@ std::string SpiralVase::process_layer(const std::string &gcode, bool last_layer) if (line.has_z() && !line.retracting(reader)) { // If this is the initial Z move of the layer, replace it with a // (redundant) move to the last Z of previous layer. - line.set(reader, Z, z); + line.set(Z, z); new_gcode += line.raw() + '\n'; return; } else { @@ -142,17 +142,17 @@ std::string SpiralVase::process_layer(const std::string &gcode, bool last_layer) 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*/); + line.set(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*/); + transitionLine.set(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); + line.set(Z, z + factor * layer_height); if (smooth_spiral) { // Now we also need to try to interpolate X and Y SpiralVase::SpiralPoint p(line.x(), line.y()); // Get current x/y coordinates @@ -171,10 +171,10 @@ std::string SpiralVase::process_layer(const std::string &gcode, bool last_layer) if (modified_dist_XY < 0.001) line.clear(); else { - line.set(reader, X, target.x); - line.set(reader, Y, target.y); + line.set(X, target.x); + line.set(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*/); + line.set(E, line.e() * modified_dist_XY / dist_XY, 5 /*decimal_digits*/); last_point = target; } } else { diff --git a/src/libslic3r/GCodeReader.cpp b/src/libslic3r/GCodeReader.cpp index 1168378286..9889fe90cb 100644 --- a/src/libslic3r/GCodeReader.cpp +++ b/src/libslic3r/GCodeReader.cpp @@ -275,7 +275,7 @@ bool GCodeReader::GCodeLine::has_value(char axis, float &value) const return false; } -void GCodeReader::GCodeLine::set(const GCodeReader &reader, const Axis axis, const float new_value, const int decimal_digits) +void GCodeReader::GCodeLine::set(const Axis axis, const float new_value, const int decimal_digits) { std::ostringstream ss; ss << std::fixed << std::setprecision(decimal_digits) << new_value; diff --git a/src/libslic3r/GCodeReader.hpp b/src/libslic3r/GCodeReader.hpp index 52a37dde55..c0b868c6f7 100644 --- a/src/libslic3r/GCodeReader.hpp +++ b/src/libslic3r/GCodeReader.hpp @@ -50,7 +50,7 @@ public: bool extruding(const GCodeReader &reader) const { return (this->cmd_is("G1") || this->cmd_is("G2") || this->cmd_is("G3")) && this->dist_E(reader) > 0; } bool retracting(const GCodeReader &reader) const { return (this->cmd_is("G1") || this->cmd_is("G2") || this->cmd_is("G3")) && this->dist_E(reader) < 0; } bool travel() const { return (this->cmd_is("G1") || this->cmd_is("G2") || this->cmd_is("G3")) && ! this->has(E); } - void set(const GCodeReader &reader, const Axis axis, const float new_value, const int decimal_digits = 3); + void set(const Axis axis, const float new_value, const int decimal_digits = 3); bool has_x() const { return this->has(X); } bool has_y() const { return this->has(Y); } @@ -93,6 +93,7 @@ public: void reset() { memset(m_position, 0, sizeof(m_position)); } void apply_config(const GCodeConfig &config); void apply_config(const DynamicPrintConfig &config); + const GCodeConfig& config() { return m_config; }; template void parse_buffer(const std::string &buffer, Callback callback)