Fix first positions on layers with wipe tower with not toolchange

This commit is contained in:
Martin Šach 2024-08-09 11:00:54 +02:00 committed by Lukas Matena
parent 6cfad69a5a
commit dbc8300a59
2 changed files with 12 additions and 6 deletions

View File

@ -525,11 +525,14 @@ std::vector<ExtruderExtrusions> get_extrusions(
ExtruderExtrusions extruder_extrusions{extruder_id};
if (layer_tools.has_wipe_tower && wipe_tower != nullptr) {
if (is_toolchange_required(is_first_layer, layer_tools.extruders.back(), extruder_id, current_extruder_id)) {
const WipeTower::ToolChangeResult tool_change{wipe_tower->get_toolchange(toolchange_number++)};
previous_position = Point::new_scale(wipe_tower->transform_wt_pt(tool_change.end_pos));
current_extruder_id = tool_change.new_tool;
extruder_extrusions.wipe_tower_start = Point::new_scale(wipe_tower->transform_wt_pt(tool_change.start_pos));
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)}) {
toolchange_number++;
previous_position = Point::new_scale(wipe_tower->transform_wt_pt(tool_change->end_pos));
current_extruder_id = tool_change->new_tool;
extruder_extrusions.wipe_tower_start = Point::new_scale(wipe_tower->transform_wt_pt(tool_change->start_pos));
}
}
}

View File

@ -39,7 +39,10 @@ public:
std::string tool_change(GCodeGenerator &gcodegen, int extruder_id, bool finish_layer);
std::string finalize(GCodeGenerator &gcodegen);
std::vector<float> used_filament_length() const;
WipeTower::ToolChangeResult get_toolchange(std::size_t index) const {
std::optional<WipeTower::ToolChangeResult> get_toolchange(std::size_t index) const {
if (m_layer_idx >= m_tool_changes.size()) {
return std::nullopt;
}
return m_tool_changes.at(m_layer_idx).at(index);
}