From 01a46f316a7ba9f451a856216ecfab7bbbd90a64 Mon Sep 17 00:00:00 2001 From: "c.lamboo" Date: Fri, 23 Feb 2024 06:43:06 +0100 Subject: [PATCH 1/5] Remove none option --- include/settings/EnumSettings.h | 5 ----- src/FffGcodeWriter.cpp | 2 -- src/FffPolygonGenerator.cpp | 4 ++-- src/PrimeTower.cpp | 2 +- src/settings/Settings.cpp | 10 ++-------- 5 files changed, 5 insertions(+), 18 deletions(-) diff --git a/include/settings/EnumSettings.h b/include/settings/EnumSettings.h index 7b8c970db4..333fa1d07a 100644 --- a/include/settings/EnumSettings.h +++ b/include/settings/EnumSettings.h @@ -250,11 +250,6 @@ enum class InsetDirection */ enum class PrimeTowerMethod { - /*! - * No prime tower is generated. - */ - NONE, - /*! * Prime tower that minimizes time and used filament as much as possible. */ diff --git a/src/FffGcodeWriter.cpp b/src/FffGcodeWriter.cpp index d4c64cb685..e45912fdb9 100644 --- a/src/FffGcodeWriter.cpp +++ b/src/FffGcodeWriter.cpp @@ -1602,8 +1602,6 @@ std::vector switch (method) { - case PrimeTowerMethod::NONE: - break; case PrimeTowerMethod::NORMAL: if (extruder_is_used_on_this_layer[extruder_nr] && extruder_nr != last_extruder) diff --git a/src/FffPolygonGenerator.cpp b/src/FffPolygonGenerator.cpp index c5c33dcc01..f2fcbe8910 100644 --- a/src/FffPolygonGenerator.cpp +++ b/src/FffPolygonGenerator.cpp @@ -972,7 +972,7 @@ void FffPolygonGenerator::processOozeShield(SliceDataStorage& storage) { storage.oozeShield[layer_nr].removeSmallAreas(largest_printed_area); } - if (mesh_group_settings.get("prime_tower_mode") != PrimeTowerMethod::NONE) + if (mesh_group_settings.get("prime_tower_enable")) { coord_t max_line_width = 0; { // compute max_line_width @@ -1024,7 +1024,7 @@ void FffPolygonGenerator::processDraftShield(SliceDataStorage& storage) maximum_deviation = std::min(maximum_deviation, extruder.settings_.get("meshfix_maximum_deviation")); } storage.draft_protection_shield = Simplify(maximum_resolution, maximum_deviation, 0).polygon(storage.draft_protection_shield); - if (mesh_group_settings.get("prime_tower_mode") != PrimeTowerMethod::NONE) + if (mesh_group_settings.get("prime_tower_enable")) { coord_t max_line_width = 0; { // compute max_line_width diff --git a/src/PrimeTower.cpp b/src/PrimeTower.cpp index 5264ecb346..180a79a331 100644 --- a/src/PrimeTower.cpp +++ b/src/PrimeTower.cpp @@ -48,7 +48,7 @@ PrimeTower::PrimeTower() && ((adhesion_type != EPlatformAdhesion::SKIRT) && (adhesion_type != EPlatformAdhesion::BRIM))); } - enabled_ = method != PrimeTowerMethod::NONE && scene.current_mesh_group->settings.get("prime_tower_min_volume") > 10 + enabled_ = scene.current_mesh_group->settings.get("prime_tower_enable") && scene.current_mesh_group->settings.get("prime_tower_min_volume") > 10 && scene.current_mesh_group->settings.get("prime_tower_size") > 10; would_have_actual_tower_ = enabled_; // Assume so for now. diff --git a/src/settings/Settings.cpp b/src/settings/Settings.cpp index b94364d9e5..fb40910eef 100644 --- a/src/settings/Settings.cpp +++ b/src/settings/Settings.cpp @@ -686,14 +686,8 @@ PrimeTowerMethod Settings::get(const std::string& key) const { return PrimeTowerMethod::INTERLEAVED; } - else if (value == "normal") - { - return PrimeTowerMethod::NORMAL; - } - else // Default. - { - return PrimeTowerMethod::NONE; - } + + return PrimeTowerMethod::NORMAL; } template<> From f5ac2b902d3e7395505eb8be0284ee029d23f0a0 Mon Sep 17 00:00:00 2001 From: casperlamboo Date: Fri, 23 Feb 2024 05:43:44 +0000 Subject: [PATCH 2/5] Applied clang-format. --- src/FffGcodeWriter.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/FffGcodeWriter.cpp b/src/FffGcodeWriter.cpp index e45912fdb9..c04c3b45d4 100644 --- a/src/FffGcodeWriter.cpp +++ b/src/FffGcodeWriter.cpp @@ -1602,7 +1602,6 @@ std::vector switch (method) { - case PrimeTowerMethod::NORMAL: if (extruder_is_used_on_this_layer[extruder_nr] && extruder_nr != last_extruder) { From 23188b9686079e949217143049967ab3f0d2d5e3 Mon Sep 17 00:00:00 2001 From: "c.lamboo" Date: Fri, 23 Feb 2024 10:10:07 +0100 Subject: [PATCH 3/5] Revert old prime tower = off logic --- src/FffGcodeWriter.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/FffGcodeWriter.cpp b/src/FffGcodeWriter.cpp index c04c3b45d4..9d674301fe 100644 --- a/src/FffGcodeWriter.cpp +++ b/src/FffGcodeWriter.cpp @@ -1568,7 +1568,8 @@ std::vector assert(static_cast(extruder_count) > 0); std::vector ret; std::vector extruder_is_used_on_this_layer = storage.getExtrudersUsed(layer_nr); - PrimeTowerMethod method = mesh_group_settings.get("prime_tower_mode"); + const auto method = mesh_group_settings.get("prime_tower_mode"); + const auto prime_tower_enable = mesh_group_settings.get("prime_tower_enable"); // check if we are on the first layer if (layer_nr == -static_cast(Raft::getTotalExtraLayers())) @@ -1600,6 +1601,11 @@ std::vector { ExtruderPrime prime = ExtruderPrime::None; + if (!prime_tower_enable) + { + break; + } + switch (method) { case PrimeTowerMethod::NORMAL: From 24ce45e5227e6d0bfd914cdf92d05e8c2277ebd8 Mon Sep 17 00:00:00 2001 From: casperlamboo Date: Fri, 23 Feb 2024 09:10:36 +0000 Subject: [PATCH 4/5] Applied clang-format. --- src/FffGcodeWriter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FffGcodeWriter.cpp b/src/FffGcodeWriter.cpp index 9d674301fe..7857be155b 100644 --- a/src/FffGcodeWriter.cpp +++ b/src/FffGcodeWriter.cpp @@ -1601,7 +1601,7 @@ std::vector { ExtruderPrime prime = ExtruderPrime::None; - if (!prime_tower_enable) + if (! prime_tower_enable) { break; } From 44c19f1b8d974e67310e4caee7f856fb66affb72 Mon Sep 17 00:00:00 2001 From: Erwan MATHIEU Date: Mon, 26 Feb 2024 11:04:14 +0100 Subject: [PATCH 5/5] Fix crash when prime tower disabled CURA-11645 --- src/FffGcodeWriter.cpp | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/src/FffGcodeWriter.cpp b/src/FffGcodeWriter.cpp index 7857be155b..3fef253514 100644 --- a/src/FffGcodeWriter.cpp +++ b/src/FffGcodeWriter.cpp @@ -1601,30 +1601,28 @@ std::vector { ExtruderPrime prime = ExtruderPrime::None; - if (! prime_tower_enable) + if (prime_tower_enable) { - break; - } - - switch (method) - { - case PrimeTowerMethod::NORMAL: - if (extruder_is_used_on_this_layer[extruder_nr] && extruder_nr != last_extruder) + switch (method) { - prime = ExtruderPrime::Prime; - } - else if (layer_nr < storage.max_print_height_second_to_last_extruder) - { - prime = ExtruderPrime::Sparse; - } - break; + case PrimeTowerMethod::NORMAL: + if (extruder_is_used_on_this_layer[extruder_nr] && extruder_nr != last_extruder) + { + prime = ExtruderPrime::Prime; + } + else if (layer_nr < storage.max_print_height_second_to_last_extruder) + { + prime = ExtruderPrime::Sparse; + } + break; - case PrimeTowerMethod::INTERLEAVED: - if (extruder_is_used_on_this_layer[extruder_nr] && extruder_nr != last_extruder) - { - prime = ExtruderPrime::Prime; + case PrimeTowerMethod::INTERLEAVED: + if (extruder_is_used_on_this_layer[extruder_nr] && extruder_nr != last_extruder) + { + prime = ExtruderPrime::Prime; + } + break; } - break; } if (extruder_is_used_on_this_layer[extruder_nr] || prime != ExtruderPrime::None)