diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 9eb51456396..ebe23a0dce7 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -5441,9 +5441,9 @@ double_t GCode::_compute_speed_mm_per_sec(const ExtrusionPath& path, double spee void GCode::cooldown_marker_init() { if (_cooldown_marker_speed[ExtrusionRole::erExternalPerimeter].empty()) { - std::string allow_speed_change = ";CM_extrude_speed;_EXTRUDE_SET_SPEED"; + std::string allow_speed_change = ";_EXTRUDE_SET_SPEED"; //only change speed on external perimeter (and similar) speed if really necessary. - std::string maybe_allow_speed_change = ";CM_extrude_speed_external;_EXTRUDE_SET_SPEED_MAYBE"; + std::string maybe_allow_speed_change = ";_EXTRUDE_SET_SPEED_MAYBE"; _cooldown_marker_speed[erNone] = ""; _cooldown_marker_speed[erPerimeter] = allow_speed_change; _cooldown_marker_speed[erExternalPerimeter] = maybe_allow_speed_change; diff --git a/src/libslic3r/GCode/CoolingBuffer.cpp b/src/libslic3r/GCode/CoolingBuffer.cpp index a52bee44a0c..c19f3d60b79 100644 --- a/src/libslic3r/GCode/CoolingBuffer.cpp +++ b/src/libslic3r/GCode/CoolingBuffer.cpp @@ -405,6 +405,26 @@ std::vector CoolingBuffer::parse_layer_gcode(const std:: // type to add to each next G1 (just for adjustable for now) size_t current_stamp = CoolingLine::TYPE_NONE; + auto finalize_sm = [&](bool ignore_empty) { + if (active_speed_modifier != size_t(-1)) { + assert(active_speed_modifier < adjustment->lines.size()); + CoolingLine &sm = adjustment->lines[active_speed_modifier]; + // There should be at least some extrusion move inside the adjustment block. + // However if the block has no extrusion (which is wrong), fix it for the cooling buffer to work. + //FIXME: Pressure equalizer add EXTRUDE_SET_SPEED_TAG withotu removing the previous one at the line before. + assert(ignore_empty || sm.length > 0); + assert(ignore_empty || sm.time > 0); + if (sm.time <= 0) { + // Likely a zero length extrusion, it should not be emitted, however the zero extrusions should + // not confuse firmware either. Prohibit time adjustment of a block of zero length extrusions by + // the cooling buffer. + sm.type &= ~CoolingLine::TYPE_ADJUSTABLE; + // But the start / end comment shall be removed. + sm.type |= CoolingLine::TYPE_ADJUSTABLE_EMPTY; + } + } + }; + for (; *line_start != 0; line_start = line_end) { while (*line_end != '\n' && *line_end != 0) @@ -462,7 +482,8 @@ std::vector CoolingBuffer::parse_layer_gcode(const std:: bool wipe = boost::contains(sline, ";_WIPE"); if (wipe) line.type |= CoolingLine::TYPE_WIPE; - if (boost::contains(sline, ";_EXTRUDE_SET_SPEED") && ! wipe) { + if (boost::contains(sline, ";_EXTRUDE_SET_SPEED") && !wipe) { + finalize_sm(true); active_speed_modifier = adjustment->lines.size(); line.type |= CoolingLine::TYPE_ADJUSTABLE; current_stamp |= CoolingLine::TYPE_ADJUSTABLE; @@ -542,21 +563,7 @@ std::vector CoolingBuffer::parse_layer_gcode(const std:: } else if (boost::starts_with(sline, ";_EXTRUDE_END")) { // Closing a block of non-zero length extrusion moves. line.type = CoolingLine::TYPE_EXTRUDE_END; - if (active_speed_modifier != size_t(-1)) { - assert(active_speed_modifier < adjustment->lines.size()); - CoolingLine &sm = adjustment->lines[active_speed_modifier]; - // There should be at least some extrusion move inside the adjustment block. - // However if the block has no extrusion (which is wrong), fix it for the cooling buffer to work. - assert(sm.length > 0); - assert(sm.time > 0); - if (sm.time <= 0) { - // Likely a zero length extrusion, it should not be emitted, however the zero extrusions should not confuse firmware either. - // Prohibit time adjustment of a block of zero length extrusions by the cooling buffer. - sm.type &= ~CoolingLine::TYPE_ADJUSTABLE; - // But the start / end comment shall be removed. - sm.type |= CoolingLine::TYPE_ADJUSTABLE_EMPTY; - } - } + finalize_sm(false); active_speed_modifier = size_t(-1); current_stamp = CoolingLine::TYPE_NONE; } else if (boost::starts_with(sline, ";_TOOLCHANGE")) { @@ -1042,8 +1049,6 @@ std::string CoolingBuffer::apply_layer_cooldown( } else if (line->type & CoolingLine::TYPE_EXTRUDE_END) { assert(extrude_tree.size() > 0); if (extrude_tree.size() > 0) { - new_gcode.append(std::string(";TYPE_EXTRUDE remove type ") + - ExtrusionEntity::role_to_string(extrude_tree.back()) + std::string("\n")); extrude_tree.pop_back(); fan_need_set = true; } diff --git a/src/libslic3r/GCode/PressureEqualizer.cpp b/src/libslic3r/GCode/PressureEqualizer.cpp index da8f833138d..fd3a8998914 100644 --- a/src/libslic3r/GCode/PressureEqualizer.cpp +++ b/src/libslic3r/GCode/PressureEqualizer.cpp @@ -17,7 +17,7 @@ namespace Slic3r { static const std::string EXTRUSION_ROLE_TAG = ";_EXTRUSION_ROLE:"; static const std::string EXTRUDE_END_TAG = ";_EXTRUDE_END"; static const std::string EXTRUDE_SET_SPEED_TAG = ";_EXTRUDE_SET_SPEED"; -static const std::string EXTERNAL_PERIMETER_TAG = ";_EXTERNAL_PERIMETER"; +//static const std::string EXTERNAL_PERIMETER_TAG = ";_EXTERNAL_PERIMETER"; // Maximum segment length to split a long segment if the initial and the final flow rate differ. // Smaller value means a smoother transition between two different flow rates. @@ -685,7 +685,7 @@ inline bool is_just_line_with_extrude_set_speed_tag(const std::string &line) break; else return false; -} + } parse_float(p_line, line_end - p_line); eatws(p_line); p_line += EXTRUDE_SET_SPEED_TAG.length(); @@ -700,16 +700,19 @@ void PressureEqualizer::push_line_to_output(const size_t line_idx, const float n output_buffer.begin() + int(this->output_buffer_length) + 1); if (is_just_line_with_extrude_set_speed_tag(prev_line_str)) this->output_buffer_length = this->output_buffer_prev_length; // Remove the last line because it only sets the speed for an empty block of g-code lines, so it is useless. - else - push_to_output(EXTRUDE_END_TAG.data(), EXTRUDE_END_TAG.length(), true); - } else - push_to_output(EXTRUDE_END_TAG.data(), EXTRUDE_END_TAG.length(), true); + //else + //push_to_output(EXTRUDE_END_TAG.data(), EXTRUDE_END_TAG.length(), true); // you don't need to extrude_end a EXTRUDE_SET_SPEED_TAG anymore, only for _EXTRUDETYPE_ + } else { + std::cout<<"\n"; + } + //else push_to_output(EXTRUDE_END_TAG.data(), EXTRUDE_END_TAG.length(), true); // you don't need to extrude_end a EXTRUDE_SET_SPEED_TAG anymore, only for _EXTRUDETYPE_ GCodeG1Formatter feedrate_formatter(m_gcode_precision_xyz, m_gcode_precision_e); feedrate_formatter.emit_f(new_feedrate); feedrate_formatter.emit_string(std::string(EXTRUDE_SET_SPEED_TAG.data(), EXTRUDE_SET_SPEED_TAG.length())); - if (line.extrusion_role == erExternalPerimeter) - feedrate_formatter.emit_string(std::string(EXTERNAL_PERIMETER_TAG.data(), EXTERNAL_PERIMETER_TAG.length())); + //you don't need to re-emit that. and now it's _EXTRUDETYPE_{code} anyway + //if (line.extrusion_role == erExternalPerimeter) + // feedrate_formatter.emit_string(std::string(EXTERNAL_PERIMETER_TAG.data(), EXTERNAL_PERIMETER_TAG.length())); push_to_output(feedrate_formatter); GCodeG1Formatter extrusion_formatter(m_gcode_precision_xyz, m_gcode_precision_e);