From 7f01c3a075d280907b08c5e6b73daf6ea9e107bd Mon Sep 17 00:00:00 2001 From: "c.lamboo" Date: Tue, 19 Sep 2023 14:36:32 +0200 Subject: [PATCH 1/2] Fix min layer time for gradual flow Change ordering of back pressure compensation, gradual flow and minimum layer time gcode modification steps Ordering before commit: 1: back pressure compensation 2: minimum layer time 3: gradual flow Ordering after commit: 1: gradual flow 2: back pressure compensation 3: minimum layer time CURA-11020 --- include/LayerPlan.h | 5 +++ src/FffGcodeWriter.cpp | 1 + src/LayerPlan.cpp | 85 ++++++++++++++++++++++-------------------- 3 files changed, 51 insertions(+), 40 deletions(-) diff --git a/include/LayerPlan.h b/include/LayerPlan.h index 3eda752178..e9e7bde3f1 100644 --- a/include/LayerPlan.h +++ b/include/LayerPlan.h @@ -704,6 +704,11 @@ class LayerPlan : public NoCopy */ void moveInsideCombBoundary(const coord_t distance, const std::optional& part = std::nullopt); + /*! + * If enabled, apply the modify plugin to the layer-plan. + */ + void applyModifyPlugin(); + /*! * Apply back-pressure compensation to this layer-plan. * Since the total (filament) pressure in a feeder-system is not only dependent on the pressure that exists between the nozzle and the diff --git a/src/FffGcodeWriter.cpp b/src/FffGcodeWriter.cpp index 648e9082ce..c66e6a7659 100644 --- a/src/FffGcodeWriter.cpp +++ b/src/FffGcodeWriter.cpp @@ -1046,6 +1046,7 @@ LayerPlan& FffGcodeWriter::processLayer(const SliceDataStorage& storage, LayerIn } } + gcode_layer.applyModifyPlugin(); gcode_layer.applyBackPressureCompensation(); return gcode_layer; } diff --git a/src/LayerPlan.cpp b/src/LayerPlan.cpp index 600869daac..639a47f76a 100644 --- a/src/LayerPlan.cpp +++ b/src/LayerPlan.cpp @@ -1852,46 +1852,6 @@ void LayerPlan::writeGCode(GCodeExport& gcode) { ExtruderPlan& extruder_plan = extruder_plans[extruder_plan_idx]; - scripta::log( - "extruder_plan_0", - extruder_plan.paths, - SectionType::NA, - layer_nr, - scripta::CellVDI{ "flow", &GCodePath::flow }, - scripta::CellVDI{ "width_factor", &GCodePath::width_factor }, - scripta::CellVDI{ "spiralize", &GCodePath::spiralize }, - scripta::CellVDI{ "speed_factor", &GCodePath::speed_factor }, - scripta::CellVDI{ "speed_back_pressure_factor", &GCodePath::speed_back_pressure_factor }, - scripta::CellVDI{ "retract", &GCodePath::retract }, - scripta::CellVDI{ "unretract_before_last_travel_move", &GCodePath::unretract_before_last_travel_move }, - scripta::CellVDI{ "perform_z_hop", &GCodePath::perform_z_hop }, - scripta::CellVDI{ "perform_prime", &GCodePath::perform_prime }, - scripta::CellVDI{ "fan_speed", &GCodePath::getFanSpeed }, - scripta::CellVDI{ "is_travel_path", &GCodePath::isTravelPath }, - scripta::CellVDI{ "extrusion_mm3_per_mm", &GCodePath::getExtrusionMM3perMM }); - - extruder_plan.paths = slots::instance().modify(extruder_plan.paths, extruder_plan.extruder_nr, layer_nr); - - // Since the time/material estimates _may_ have changed during the plugin modify step we recalculate it - extruder_plan.computeNaiveTimeEstimates(gcode.getPositionXY()); - scripta::log( - "extruder_plan_1", - extruder_plan.paths, - SectionType::NA, - layer_nr, - scripta::CellVDI{ "flow", &GCodePath::flow }, - scripta::CellVDI{ "width_factor", &GCodePath::width_factor }, - scripta::CellVDI{ "spiralize", &GCodePath::spiralize }, - scripta::CellVDI{ "speed_factor", &GCodePath::speed_factor }, - scripta::CellVDI{ "speed_back_pressure_factor", &GCodePath::speed_back_pressure_factor }, - scripta::CellVDI{ "retract", &GCodePath::retract }, - scripta::CellVDI{ "unretract_before_last_travel_move", &GCodePath::unretract_before_last_travel_move }, - scripta::CellVDI{ "perform_z_hop", &GCodePath::perform_z_hop }, - scripta::CellVDI{ "perform_prime", &GCodePath::perform_prime }, - scripta::CellVDI{ "fan_speed", &GCodePath::getFanSpeed }, - scripta::CellVDI{ "is_travel_path", &GCodePath::isTravelPath }, - scripta::CellVDI{ "extrusion_mm3_per_mm", &GCodePath::getExtrusionMM3perMM }); - const RetractionAndWipeConfig* retraction_config = current_mesh ? ¤t_mesh->retraction_wipe_config : &storage.retraction_wipe_config_per_extruder[extruder_plan.extruder_nr]; coord_t z_hop_height = retraction_config->retraction_config.zHop; @@ -2402,6 +2362,51 @@ bool LayerPlan::writePathWithCoasting( return true; } +void LayerPlan::applyModifyPlugin() +{ + for (auto& extruder_plan : extruder_plans) + { + scripta::log( + "extruder_plan_0", + extruder_plan.paths, + SectionType::NA, + layer_nr, + scripta::CellVDI{ "flow", &GCodePath::flow }, + scripta::CellVDI{ "width_factor", &GCodePath::width_factor }, + scripta::CellVDI{ "spiralize", &GCodePath::spiralize }, + scripta::CellVDI{ "speed_factor", &GCodePath::speed_factor }, + scripta::CellVDI{ "speed_back_pressure_factor", &GCodePath::speed_back_pressure_factor }, + scripta::CellVDI{ "retract", &GCodePath::retract }, + scripta::CellVDI{ "unretract_before_last_travel_move", &GCodePath::unretract_before_last_travel_move }, + scripta::CellVDI{ "perform_z_hop", &GCodePath::perform_z_hop }, + scripta::CellVDI{ "perform_prime", &GCodePath::perform_prime }, + scripta::CellVDI{ "fan_speed", &GCodePath::getFanSpeed }, + scripta::CellVDI{ "is_travel_path", &GCodePath::isTravelPath }, + scripta::CellVDI{ "extrusion_mm3_per_mm", &GCodePath::getExtrusionMM3perMM }); + + extruder_plan.paths = slots::instance().modify(extruder_plan.paths, extruder_plan.extruder_nr, layer_nr); + + scripta::log( + "extruder_plan_1", + extruder_plan.paths, + SectionType::NA, + layer_nr, + scripta::CellVDI{ "flow", &GCodePath::flow }, + scripta::CellVDI{ "width_factor", &GCodePath::width_factor }, + scripta::CellVDI{ "spiralize", &GCodePath::spiralize }, + scripta::CellVDI{ "speed_factor", &GCodePath::speed_factor }, + scripta::CellVDI{ "speed_back_pressure_factor", &GCodePath::speed_back_pressure_factor }, + scripta::CellVDI{ "retract", &GCodePath::retract }, + scripta::CellVDI{ "unretract_before_last_travel_move", &GCodePath::unretract_before_last_travel_move }, + scripta::CellVDI{ "perform_z_hop", &GCodePath::perform_z_hop }, + scripta::CellVDI{ "perform_prime", &GCodePath::perform_prime }, + scripta::CellVDI{ "fan_speed", &GCodePath::getFanSpeed }, + scripta::CellVDI{ "is_travel_path", &GCodePath::isTravelPath }, + scripta::CellVDI{ "extrusion_mm3_per_mm", &GCodePath::getExtrusionMM3perMM }); + + } +} + void LayerPlan::applyBackPressureCompensation() { for (auto& extruder_plan : extruder_plans) From 8157ad44bf2ef62a970fe1b212a6a9ee3acca01f Mon Sep 17 00:00:00 2001 From: casperlamboo Date: Tue, 19 Sep 2023 12:37:17 +0000 Subject: [PATCH 2/2] Applied clang-format. --- src/LayerPlan.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/LayerPlan.cpp b/src/LayerPlan.cpp index 639a47f76a..b2ff1d6273 100644 --- a/src/LayerPlan.cpp +++ b/src/LayerPlan.cpp @@ -2403,7 +2403,6 @@ void LayerPlan::applyModifyPlugin() scripta::CellVDI{ "fan_speed", &GCodePath::getFanSpeed }, scripta::CellVDI{ "is_travel_path", &GCodePath::isTravelPath }, scripta::CellVDI{ "extrusion_mm3_per_mm", &GCodePath::getExtrusionMM3perMM }); - } }