From d21af14fe518267c5d153868e123b35539428d27 Mon Sep 17 00:00:00 2001 From: Erwan MATHIEU Date: Tue, 17 Dec 2024 10:14:34 +0100 Subject: [PATCH 1/2] 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 2/2] 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)