mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-15 03:55:56 +08:00
Merge branch 'ms_fix_wipe_tower' (SPE-2439, bug introduced by the recent gcode generator refactoring)
This commit is contained in:
commit
bdde536cc1
@ -2564,7 +2564,7 @@ LayerResult GCodeGenerator::process_layer(
|
|||||||
}
|
}
|
||||||
|
|
||||||
this->set_origin({0, 0});
|
this->set_origin({0, 0});
|
||||||
bool moved_to_first_point{false};
|
this->m_moved_to_first_layer_point = false;
|
||||||
|
|
||||||
// Extrude the skirt, brim, support, perimeters, infill ordered by the extruders.
|
// Extrude the skirt, brim, support, perimeters, infill ordered by the extruders.
|
||||||
for (const ExtruderExtrusions &extruder_extrusions : extrusions)
|
for (const ExtruderExtrusions &extruder_extrusions : extrusions)
|
||||||
@ -2589,7 +2589,7 @@ LayerResult GCodeGenerator::process_layer(
|
|||||||
this->m_label_objects.update(nullptr);
|
this->m_label_objects.update(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!moved_to_first_point) {
|
if (!this->m_moved_to_first_layer_point) {
|
||||||
const Vec3crd point{to_3d(first_point, scaled(print_z))};
|
const Vec3crd point{to_3d(first_point, scaled(print_z))};
|
||||||
|
|
||||||
gcode += this->travel_to_first_position(point, print_z, ExtrusionRole::Mixed, [this]() {
|
gcode += this->travel_to_first_position(point, print_z, ExtrusionRole::Mixed, [this]() {
|
||||||
@ -2598,7 +2598,6 @@ LayerResult GCodeGenerator::process_layer(
|
|||||||
}
|
}
|
||||||
return m_label_objects.maybe_change_instance(m_writer);
|
return m_label_objects.maybe_change_instance(m_writer);
|
||||||
});
|
});
|
||||||
moved_to_first_point = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!extruder_extrusions.skirt.empty()) {
|
if (!extruder_extrusions.skirt.empty()) {
|
||||||
@ -2861,7 +2860,11 @@ std::string GCodeGenerator::change_layer(
|
|||||||
gcode += this->retract_and_wipe();
|
gcode += this->retract_and_wipe();
|
||||||
}
|
}
|
||||||
if (!first_layer) {
|
if (!first_layer) {
|
||||||
|
// travel_to_z is not used as it may not generate the travel if the writter z == print_z.
|
||||||
gcode += this->writer().get_travel_to_z_gcode(print_z, "simple layer change");
|
gcode += this->writer().get_travel_to_z_gcode(print_z, "simple layer change");
|
||||||
|
Vec3d position{this->writer().get_position()};
|
||||||
|
position.z() = print_z;
|
||||||
|
this->writer().update_position(position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3112,6 +3115,7 @@ std::string GCodeGenerator::travel_to_first_position(const Vec3crd& point, const
|
|||||||
this->writer().update_position(gcode_point);
|
this->writer().update_position(gcode_point);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->m_moved_to_first_layer_point = true;
|
||||||
return gcode;
|
return gcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -429,6 +429,8 @@ private:
|
|||||||
|
|
||||||
std::optional<Vec3d> m_previous_layer_last_position;
|
std::optional<Vec3d> m_previous_layer_last_position;
|
||||||
std::optional<Vec3d> m_previous_layer_last_position_before_wipe;
|
std::optional<Vec3d> m_previous_layer_last_position_before_wipe;
|
||||||
|
bool m_moved_to_first_layer_point{false};
|
||||||
|
|
||||||
// This needs to be populated during the layer processing!
|
// This needs to be populated during the layer processing!
|
||||||
std::unique_ptr<CoolingBuffer> m_cooling_buffer;
|
std::unique_ptr<CoolingBuffer> m_cooling_buffer;
|
||||||
std::unique_ptr<SpiralVase> m_spiral_vase;
|
std::unique_ptr<SpiralVase> m_spiral_vase;
|
||||||
|
@ -525,11 +525,14 @@ std::vector<ExtruderExtrusions> get_extrusions(
|
|||||||
ExtruderExtrusions extruder_extrusions{extruder_id};
|
ExtruderExtrusions extruder_extrusions{extruder_id};
|
||||||
|
|
||||||
if (layer_tools.has_wipe_tower && wipe_tower != nullptr) {
|
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 bool finish_wipe_tower{extruder_id == layer_tools.extruders.back()};
|
||||||
const WipeTower::ToolChangeResult tool_change{wipe_tower->get_toolchange(toolchange_number++)};
|
if (finish_wipe_tower || is_toolchange_required(is_first_layer, layer_tools.extruders.back(), extruder_id, current_extruder_id)) {
|
||||||
previous_position = Point::new_scale(wipe_tower->transform_wt_pt(tool_change.end_pos));
|
if (const auto tool_change{wipe_tower->get_toolchange(toolchange_number)}) {
|
||||||
current_extruder_id = tool_change.new_tool;
|
toolchange_number++;
|
||||||
extruder_extrusions.wipe_tower_start = Point::new_scale(wipe_tower->transform_wt_pt(tool_change.start_pos));
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,13 +68,18 @@ std::string WipeTowerIntegration::append_tcr(GCodeGenerator &gcodegen, const Wip
|
|||||||
gcode += gcodegen.retract_and_wipe();
|
gcode += gcodegen.retract_and_wipe();
|
||||||
gcodegen.m_avoid_crossing_perimeters.use_external_mp_once = true;
|
gcodegen.m_avoid_crossing_perimeters.use_external_mp_once = true;
|
||||||
const std::string comment{"Travel to a Wipe Tower"};
|
const std::string comment{"Travel to a Wipe Tower"};
|
||||||
if (gcodegen.last_position) {
|
if (!gcodegen.m_moved_to_first_layer_point) {
|
||||||
gcode += gcodegen.travel_to(
|
const Vec3crd point = to_3d(xy_point, scaled(z));
|
||||||
*gcodegen.last_position, xy_point, ExtrusionRole::Mixed, comment, [](){return "";}
|
gcode += gcodegen.travel_to_first_position(point, current_z, ExtrusionRole::Mixed, [](){return "";});
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
gcode += gcodegen.writer().travel_to_xy(gcodegen.point_to_gcode(xy_point), comment);
|
if (gcodegen.last_position) {
|
||||||
gcode += gcodegen.writer().get_travel_to_z_gcode(z, comment);
|
gcode += gcodegen.travel_to(
|
||||||
|
*gcodegen.last_position, xy_point, ExtrusionRole::Mixed, comment, [](){return "";}
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
gcode += gcodegen.writer().travel_to_xy(gcodegen.point_to_gcode(xy_point), comment);
|
||||||
|
gcode += gcodegen.writer().get_travel_to_z_gcode(z, comment);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
gcode += gcodegen.unretract();
|
gcode += gcodegen.unretract();
|
||||||
} else {
|
} else {
|
||||||
|
@ -39,7 +39,10 @@ public:
|
|||||||
std::string tool_change(GCodeGenerator &gcodegen, int extruder_id, bool finish_layer);
|
std::string tool_change(GCodeGenerator &gcodegen, int extruder_id, bool finish_layer);
|
||||||
std::string finalize(GCodeGenerator &gcodegen);
|
std::string finalize(GCodeGenerator &gcodegen);
|
||||||
std::vector<float> used_filament_length() const;
|
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);
|
return m_tool_changes.at(m_layer_idx).at(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user