diff --git a/src/libslic3r/GCode/ExtrusionOrder.cpp b/src/libslic3r/GCode/ExtrusionOrder.cpp index 84f5387904..713bac78b4 100644 --- a/src/libslic3r/GCode/ExtrusionOrder.cpp +++ b/src/libslic3r/GCode/ExtrusionOrder.cpp @@ -540,7 +540,8 @@ std::vector get_extrusions( if (layer_tools.has_wipe_tower && wipe_tower != nullptr) { const bool finish_wipe_tower{extruder_id == layer_tools.extruders.back()}; if (finish_wipe_tower || is_toolchange_required(is_first_layer, layer_tools.extruders.back(), extruder_id, current_extruder_id)) { - if (const auto tool_change{wipe_tower->get_toolchange(toolchange_number)}) { + const bool ignore_sparse{print.config().wipe_tower_no_sparse_layers.value}; + if (const auto tool_change{wipe_tower->get_toolchange(toolchange_number, ignore_sparse)}) { toolchange_number++; previous_position = Point::new_scale(wipe_tower->transform_wt_pt(tool_change->end_pos)); current_extruder_id = tool_change->new_tool; diff --git a/src/libslic3r/GCode/WipeTowerIntegration.hpp b/src/libslic3r/GCode/WipeTowerIntegration.hpp index adc76b0185..beb5614c30 100644 --- a/src/libslic3r/GCode/WipeTowerIntegration.hpp +++ b/src/libslic3r/GCode/WipeTowerIntegration.hpp @@ -42,10 +42,23 @@ public: std::string tool_change(GCodeGenerator &gcodegen, int extruder_id, bool finish_layer); std::string finalize(GCodeGenerator &gcodegen); std::vector used_filament_length() const; - std::optional get_toolchange(std::size_t index) const { + std::optional get_toolchange(std::size_t index, bool ignore_sparse) const { if (m_layer_idx >= m_tool_changes.size()) { return std::nullopt; } + if( + ignore_sparse + && m_tool_changes.at(m_layer_idx).size() == 1 + && ( + m_tool_changes.at(m_layer_idx).front().initial_tool + == m_tool_changes.at(m_layer_idx).front().new_tool + ) + && m_layer_idx != 0 + ) { + // Ignore sparse + return std::nullopt; + } + return m_tool_changes.at(m_layer_idx).at(index); }