From 3244e4fa6b12001caad6f8689f1d36207ddab226 Mon Sep 17 00:00:00 2001 From: Erwan MATHIEU Date: Mon, 16 Dec 2024 15:47:32 +0100 Subject: [PATCH 1/6] Apply distance to walls for inside combing CURA-12236 --- src/FffGcodeWriter.cpp | 4 +++- src/LayerPlan.cpp | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/FffGcodeWriter.cpp b/src/FffGcodeWriter.cpp index 76b3d1b719..58e72d8019 100644 --- a/src/FffGcodeWriter.cpp +++ b/src/FffGcodeWriter.cpp @@ -1169,6 +1169,7 @@ FffGcodeWriter::ProcessLayerResult FffGcodeWriter::processLayer(const SliceDataS const Scene& scene = Application::getInstance().current_slice_->scene; + coord_t comb_offset_from_outlines = 0; coord_t avoid_distance = 0; // minimal avoid distance is zero const std::vector extruder_is_used = storage.getExtrudersUsed(); for (size_t extruder_nr = 0; extruder_nr < scene.extruders.size(); extruder_nr++) @@ -1181,6 +1182,8 @@ FffGcodeWriter::ProcessLayerResult FffGcodeWriter::processLayer(const SliceDataS { avoid_distance = std::max(avoid_distance, extruder.settings_.get("travel_avoid_distance")); } + + comb_offset_from_outlines = std::max(comb_offset_from_outlines, extruder.settings_.get("retraction_combing_avoid_distance")); } } @@ -1196,7 +1199,6 @@ FffGcodeWriter::ProcessLayerResult FffGcodeWriter::processLayer(const SliceDataS } max_inner_wall_width = std::max(max_inner_wall_width, mesh_inner_wall_width); } - const coord_t comb_offset_from_outlines = max_inner_wall_width * 2; const size_t first_extruder = findUsedExtruderIndex(storage, layer_nr, false); diff --git a/src/LayerPlan.cpp b/src/LayerPlan.cpp index 39f3e1b510..3587bd94a7 100644 --- a/src/LayerPlan.cpp +++ b/src/LayerPlan.cpp @@ -196,10 +196,10 @@ Shape LayerPlan::computeCombBoundary(const CombBoundary boundary_type) switch (boundary_type) { case CombBoundary::MINIMUM: - offset = -mesh.settings.get("machine_nozzle_size") / 2 - mesh.settings.get("wall_line_width_0") / 2 - extra_offset; + offset = -(mesh.settings.get("machine_nozzle_size") / 2 + mesh.settings.get("wall_line_width_0") / 2 + extra_offset); break; case CombBoundary::PREFERRED: - offset = -mesh.settings.get("machine_nozzle_size") * 3 / 2 - mesh.settings.get("wall_line_width_0") / 2 - extra_offset; + offset = -(mesh.settings.get("retraction_combing_avoid_distance") + mesh.settings.get("wall_line_width_0") / 2 + extra_offset); break; default: offset = 0; From d21af14fe518267c5d153868e123b35539428d27 Mon Sep 17 00:00:00 2001 From: Erwan MATHIEU Date: Tue, 17 Dec 2024 10:14:34 +0100 Subject: [PATCH 2/6] Fix "specific seam position" with "on vertex" case CURA-12340 During the previous refactoring for the seam, this settings combination has been overlooked and was not handled properly, resulting in a warning in the console and a wrong seam position. --- include/PathOrderOptimizer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/PathOrderOptimizer.h b/include/PathOrderOptimizer.h index 2d339e79f8..a401d4c0fd 100644 --- a/include/PathOrderOptimizer.h +++ b/include/PathOrderOptimizer.h @@ -747,7 +747,7 @@ class PathOrderOptimizer } else { - if (path.seam_config_.type_ == EZSeamType::SHORTEST) + if (path.seam_config_.type_ == EZSeamType::SHORTEST || path.seam_config_.type_ == EZSeamType::USER_SPECIFIED) { main_criterion.criterion = std::make_shared(points, target_pos); } From 60b27d6c45c6fd311096b796beeac04fd558889c Mon Sep 17 00:00:00 2001 From: Erwan MATHIEU Date: Tue, 17 Dec 2024 10:21:48 +0100 Subject: [PATCH 3/6] Fix comment and simplify code CURA-12340 --- include/PathOrderOptimizer.h | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/include/PathOrderOptimizer.h b/include/PathOrderOptimizer.h index a401d4c0fd..f50482d4ad 100644 --- a/include/PathOrderOptimizer.h +++ b/include/PathOrderOptimizer.h @@ -738,29 +738,26 @@ class PathOrderOptimizer BestElementFinder::WeighedCriterion main_criterion; - if (path.force_start_index_.has_value()) // Actually handles EZSeamType::USER_SPECIFIED + if (path.force_start_index_.has_value()) // Handles EZSeamType::USER_SPECIFIED with "seam_on_vertex" disabled { // Use a much smaller distance divider because we want points around the forced points to be filtered out very easily constexpr double distance_divider = 1.0; constexpr auto distance_type = DistanceScoringCriterion::DistanceType::Euclidian; main_criterion.criterion = std::make_shared(points, points.at(path.force_start_index_.value()), distance_type, distance_divider); } - else + else if (path.seam_config_.type_ == EZSeamType::SHORTEST || path.seam_config_.type_ == EZSeamType::USER_SPECIFIED) { - if (path.seam_config_.type_ == EZSeamType::SHORTEST || path.seam_config_.type_ == EZSeamType::USER_SPECIFIED) - { - main_criterion.criterion = std::make_shared(points, target_pos); - } - else if ( - path.seam_config_.type_ == EZSeamType::SHARPEST_CORNER - && (path.seam_config_.corner_pref_ != EZSeamCornerPrefType::Z_SEAM_CORNER_PREF_NONE && path.seam_config_.corner_pref_ != EZSeamCornerPrefType::PLUGIN)) - { - main_criterion.criterion = std::make_shared(points, path.seam_config_.corner_pref_); - } - else if (path.seam_config_.type_ == EZSeamType::RANDOM) - { - main_criterion.criterion = std::make_shared(); - } + main_criterion.criterion = std::make_shared(points, target_pos); + } + else if ( + path.seam_config_.type_ == EZSeamType::SHARPEST_CORNER + && (path.seam_config_.corner_pref_ != EZSeamCornerPrefType::Z_SEAM_CORNER_PREF_NONE && path.seam_config_.corner_pref_ != EZSeamCornerPrefType::PLUGIN)) + { + main_criterion.criterion = std::make_shared(points, path.seam_config_.corner_pref_); + } + else if (path.seam_config_.type_ == EZSeamType::RANDOM) + { + main_criterion.criterion = std::make_shared(); } if (main_criterion.criterion) From 2bc7601563ef5c35fb52d52943a57b7d0a8f7fa5 Mon Sep 17 00:00:00 2001 From: Erwan MATHIEU Date: Wed, 18 Dec 2024 16:01:16 +0100 Subject: [PATCH 4/6] Fix wrong retraction settings being CURA-12065 In the case where a mesh was printed with multiple extruders, the used retraction settings were always the one of the main extruder. Now we take the settings of the mesh only if using the main extruder. Mesh-specific settings will then be ignored for other extruders. --- src/LayerPlan.cpp | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/src/LayerPlan.cpp b/src/LayerPlan.cpp index 39f3e1b510..f57cba07a4 100644 --- a/src/LayerPlan.cpp +++ b/src/LayerPlan.cpp @@ -57,14 +57,15 @@ GCodePath* LayerPlan::getLatestPathWithConfig( { return &paths.back(); } - paths.emplace_back(GCodePath{ .z_offset = z_offset, - .config = config, - .mesh = current_mesh_, - .space_fill_type = space_fill_type, - .flow = flow, - .width_factor = width_factor, - .spiralize = spiralize, - .speed_factor = speed_factor }); + paths.emplace_back( + GCodePath{ .z_offset = z_offset, + .config = config, + .mesh = current_mesh_, + .space_fill_type = space_fill_type, + .flow = flow, + .width_factor = width_factor, + .spiralize = spiralize, + .speed_factor = speed_factor }); GCodePath* ret = &paths.back(); ret->skip_agressive_merge_hint = mode_skip_agressive_merge_; @@ -1322,7 +1323,7 @@ std::vector for (const auto& reversed_chunk : paths | ranges::views::enumerate | ranges::views::reverse | ranges::views::chunk_by( - [](const auto&path_a, const auto&path_b) + [](const auto& path_a, const auto& path_b) { return (! std::get<1>(path_a).isTravelPath()) || std::get<1>(path_b).isTravelPath(); })) @@ -2512,8 +2513,24 @@ void LayerPlan::writeGCode(GCodeExport& gcode) { ExtruderPlan& extruder_plan = extruder_plans_[extruder_plan_idx]; - const RetractionAndWipeConfig* retraction_config - = current_mesh ? ¤t_mesh->retraction_wipe_config : &storage_.retraction_wipe_config_per_extruder[extruder_plan.extruder_nr_]; + auto get_retraction_config = [&extruder_nr, this](std::shared_ptr& mesh) -> std::optional + { + if (mesh) + { + if (extruder_nr == mesh->settings.get("extruder_nr")) [[likely]] + { + return &mesh->retraction_wipe_config; + } + + // We are printing a part of a mesh with a different extruder, use this extruder settings instead (mesh-specific settings will be ignored) + return &storage_.retraction_wipe_config_per_extruder[extruder_nr]; + } + + // We have no mesh yet, a more global config should be used + return std::nullopt; + }; + + const RetractionAndWipeConfig* retraction_config = get_retraction_config(current_mesh).value_or(&storage_.retraction_wipe_config_per_extruder[extruder_plan.extruder_nr_]); coord_t z_hop_height = retraction_config->retraction_config.zHop; if (extruder_nr != extruder_plan.extruder_nr_) @@ -2697,7 +2714,7 @@ void LayerPlan::writeGCode(GCodeExport& gcode) if (path.retract) { - retraction_config = path.mesh ? &path.mesh->retraction_wipe_config : retraction_config; + retraction_config = get_retraction_config(path.mesh).value_or(retraction_config); gcode.writeRetraction(retraction_config->retraction_config); if (path.retract_for_nozzle_switch) { From 6bd4aa379a8e0564b00cf915c627cf338751948f Mon Sep 17 00:00:00 2001 From: wawanbreton Date: Wed, 18 Dec 2024 15:02:09 +0000 Subject: [PATCH 5/6] Apply clang-format --- src/LayerPlan.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/LayerPlan.cpp b/src/LayerPlan.cpp index f57cba07a4..5cfdd1d9c2 100644 --- a/src/LayerPlan.cpp +++ b/src/LayerPlan.cpp @@ -57,15 +57,14 @@ GCodePath* LayerPlan::getLatestPathWithConfig( { return &paths.back(); } - paths.emplace_back( - GCodePath{ .z_offset = z_offset, - .config = config, - .mesh = current_mesh_, - .space_fill_type = space_fill_type, - .flow = flow, - .width_factor = width_factor, - .spiralize = spiralize, - .speed_factor = speed_factor }); + paths.emplace_back(GCodePath{ .z_offset = z_offset, + .config = config, + .mesh = current_mesh_, + .space_fill_type = space_fill_type, + .flow = flow, + .width_factor = width_factor, + .spiralize = spiralize, + .speed_factor = speed_factor }); GCodePath* ret = &paths.back(); ret->skip_agressive_merge_hint = mode_skip_agressive_merge_; @@ -1323,7 +1322,7 @@ std::vector for (const auto& reversed_chunk : paths | ranges::views::enumerate | ranges::views::reverse | ranges::views::chunk_by( - [](const auto& path_a, const auto& path_b) + [](const auto&path_a, const auto&path_b) { return (! std::get<1>(path_a).isTravelPath()) || std::get<1>(path_b).isTravelPath(); })) From 8c126b3f3061941e55d6568d8d8f76cd0a8622d3 Mon Sep 17 00:00:00 2001 From: HellAholic Date: Fri, 10 Jan 2025 12:34:44 +0000 Subject: [PATCH 6/6] Apply clang-format --- src/LayerPlan.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LayerPlan.cpp b/src/LayerPlan.cpp index 5cfdd1d9c2..bd6b72ad1d 100644 --- a/src/LayerPlan.cpp +++ b/src/LayerPlan.cpp @@ -1322,7 +1322,7 @@ std::vector for (const auto& reversed_chunk : paths | ranges::views::enumerate | ranges::views::reverse | ranges::views::chunk_by( - [](const auto&path_a, const auto&path_b) + [](const auto& path_a, const auto& path_b) { return (! std::get<1>(path_a).isTravelPath()) || std::get<1>(path_b).isTravelPath(); }))