From bd93d2f334dba024e11d9f1b607c5c6d7170ec23 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Thu, 13 Jul 2017 12:11:00 +0200 Subject: [PATCH] Fix of "Cooling fan problem Slic3r 1.35.5.16 " https://github.com/prusa3d/Slic3r/issues/418 This is a regression of the cooling buffer changes done for multi-material (supporting different cooling settings for different filaments) --- xs/src/libslic3r/GCode/CoolingBuffer.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/xs/src/libslic3r/GCode/CoolingBuffer.cpp b/xs/src/libslic3r/GCode/CoolingBuffer.cpp index 08d5daa7f..bf56f449c 100644 --- a/xs/src/libslic3r/GCode/CoolingBuffer.cpp +++ b/xs/src/libslic3r/GCode/CoolingBuffer.cpp @@ -160,7 +160,11 @@ std::string CoolingBuffer::process_layer(const std::string &gcode, size_t layer_ for (; *line_start != 0; line_start = line_end) { while (*line_end != '\n' && *line_end != 0) ++ line_end; + // sline will not contain the trailing '\n'. std::string sline(line_start, line_end); + // Adjustment::Line will contain the trailing '\n'. + if (*line_end == '\n') + ++ line_end; Adjustment::Line line(0, line_start - gcode.c_str(), line_end - gcode.c_str()); if (boost::starts_with(sline, "G0 ")) line.type = Adjustment::Line::TYPE_G0; @@ -264,8 +268,6 @@ std::string CoolingBuffer::process_layer(const std::string &gcode, size_t layer_ } if (line.type != 0) adjustment->lines.emplace_back(std::move(line)); - while (*line_end == '\n') - ++ line_end; } m_current_extruder = initial_extruder; } @@ -404,6 +406,7 @@ std::string CoolingBuffer::process_layer(const std::string &gcode, size_t layer_ } else { bridge_fan_control = false; bridge_fan_speed = 0; + fan_speed_new = 0; } if (fan_speed_new != fan_speed) { fan_speed = fan_speed_new; @@ -425,10 +428,10 @@ std::string CoolingBuffer::process_layer(const std::string &gcode, size_t layer_ new_gcode.append(gcode.c_str() + line->line_start, line->line_end - line->line_start); } else if (line->type & Adjustment::Line::TYPE_BRIDGE_FAN_START) { if (bridge_fan_control) - new_gcode += m_gcodegen.writer().set_fan(bridge_fan_speed, true) + "\n"; + new_gcode += m_gcodegen.writer().set_fan(bridge_fan_speed, true); } else if (line->type & Adjustment::Line::TYPE_BRIDGE_FAN_END) { if (bridge_fan_control) - new_gcode += m_gcodegen.writer().set_fan(fan_speed, true) + "\n"; + new_gcode += m_gcodegen.writer().set_fan(fan_speed, true); } else if (line->type & Adjustment::Line::TYPE_EXTRUDE_END) { // Just remove this comment. } else if (line->type & (Adjustment::Line::TYPE_ADJUSTABLE | Adjustment::Line::TYPE_EXTERNAL_PERIMETER | Adjustment::Line::TYPE_WIPE)) {