From 7dc088a8b4fd5f2fb2c33a49836355ab194d33b0 Mon Sep 17 00:00:00 2001 From: sentientstardust Date: Tue, 23 Jun 2026 19:53:36 +0100 Subject: [PATCH] Remove legacy fallback code --- src/libslic3r/TextureMappingContoning.cpp | 96 ----------------------- src/libslic3r/TextureMappingContoning.hpp | 11 --- 2 files changed, 107 deletions(-) diff --git a/src/libslic3r/TextureMappingContoning.cpp b/src/libslic3r/TextureMappingContoning.cpp index c49b0e01563..b19347ca56e 100644 --- a/src/libslic3r/TextureMappingContoning.cpp +++ b/src/libslic3r/TextureMappingContoning.cpp @@ -9,9 +9,7 @@ #include #include -#include #include -#include namespace Slic3r { namespace { @@ -190,22 +188,6 @@ float perceptual_error(const std::array &lhs, const std::array &counts, - std::vector> &out) -{ - if (component_idx + 1 == counts.size()) { - counts[component_idx] = remaining; - out.emplace_back(counts); - return; - } - for (int count = 0; count <= remaining; ++count) { - counts[component_idx] = count; - enumerate_counts(component_idx + 1, remaining - count, counts, out); - } -} - bool can_finish_without_repeat(const std::vector &ids, const std::vector &counts, unsigned int previous_id, @@ -442,9 +424,6 @@ TextureMappingContoningSolver::TextureMappingContoningSolver(const TextureMappin return; m_component_roles = texture_mapping_contoning_component_roles(zone, m_component_ids.size()); - m_component_luminance.reserve(m_component_ids.size()); - for (const unsigned int id : m_component_ids) - m_component_luminance.emplace_back(filament_luminance(config, id)); std::vector background_weights(m_component_colors.size(), 1.f / float(m_component_colors.size())); m_background_rgb = mix_color_solver_components(m_component_colors, background_weights, m_mix_model); m_effective_transmission_distances_mm = @@ -595,42 +574,6 @@ void TextureMappingContoningSolver::record_nearest_measured_sample_fallback_area area.total_area_mm2 += total_area_mm2; } -const std::vector& -TextureMappingContoningSolver::candidates_for_depth(int stack_layers) const -{ - const int depth = std::clamp(stack_layers, - TextureMappingZone::MinTopSurfaceContoningStackLayers, - TextureMappingZone::MaxTopSurfaceContoningStackLayers); - std::lock_guard lock(*m_candidate_mutex); - auto found = m_candidates_by_depth.find(depth); - if (found != m_candidates_by_depth.end()) - return found->second; - - std::vector candidates; - if (!valid()) - return m_candidates_by_depth.emplace(depth, std::move(candidates)).first->second; - - std::vector> counts_list; - std::vector counts(m_component_ids.size(), 0); - enumerate_counts(0, depth, counts, counts_list); - candidates.reserve(counts_list.size()); - for (std::vector &candidate_counts : counts_list) { - std::vector weights(candidate_counts.size(), 0.f); - for (size_t idx = 0; idx < candidate_counts.size(); ++idx) - weights[idx] = float(candidate_counts[idx]) / float(std::max(1, depth)); - - Candidate candidate; - candidate.counts = std::move(candidate_counts); - candidate.rgb = mix_color_solver_components(m_component_colors, weights, m_mix_model); - candidate.oklab = color_solver_oklab_from_srgb(candidate.rgb); - for (size_t idx = 0; idx < candidate.counts.size() && idx < m_component_luminance.size(); ++idx) - candidate.dark_score += float(candidate.counts[idx]) * (1.f - clamp01(m_component_luminance[idx])); - candidates.emplace_back(std::move(candidate)); - } - - return m_candidates_by_depth.emplace(depth, std::move(candidates)).first->second; -} - std::optional TextureMappingContoningSolver::component_index(unsigned int component_id) const { const auto it = std::find(m_component_ids.begin(), m_component_ids.end(), component_id); @@ -1059,45 +1002,6 @@ TextureMappingContoningStack TextureMappingContoningSolver::solve_impl( } } - const std::vector &candidates = candidates_for_depth(depth); - if (candidates.empty()) - return out; - - const std::array target_oklab = color_solver_oklab_from_srgb(target_rgb); - size_t best_idx = size_t(-1); - float best_error = std::numeric_limits::max(); - float best_dark_score = -std::numeric_limits::max(); - for (size_t idx = 0; idx < candidates.size(); ++idx) { - const Candidate &candidate = candidates[idx]; - const float error = perceptual_error(candidate.oklab, target_oklab); - const bool near_tie = std::isfinite(best_error) && error <= best_error * 1.03f + 1e-6f; - if (error < best_error || (near_tie && candidate.dark_score > best_dark_score)) { - best_idx = idx; - best_error = error; - best_dark_score = candidate.dark_score; - } - } - if (best_idx >= candidates.size()) - return out; - - const Candidate &best = candidates[best_idx]; - out.bottom_to_top.reserve(size_t(depth)); - for (const unsigned int ordered_id : m_components_bottom_to_top) { - const auto component_it = std::find(m_component_ids.begin(), m_component_ids.end(), ordered_id); - if (component_it == m_component_ids.end()) - continue; - const size_t component_idx = size_t(component_it - m_component_ids.begin()); - const int count = component_idx < best.counts.size() ? best.counts[component_idx] : 0; - for (int i = 0; i < count; ++i) - out.bottom_to_top.emplace_back(ordered_id); - } - while (int(out.bottom_to_top.size()) < depth) - out.bottom_to_top.emplace_back(m_components_bottom_to_top.empty() ? m_component_ids.front() : m_components_bottom_to_top.back()); - if (int(out.bottom_to_top.size()) > depth) - out.bottom_to_top.resize(size_t(depth)); - arrange_stack_for_light_path(out.bottom_to_top, target_rgb); - if (lower_surface && m_td_adjustment_enabled) - std::reverse(out.bottom_to_top.begin(), out.bottom_to_top.end()); return out; } diff --git a/src/libslic3r/TextureMappingContoning.hpp b/src/libslic3r/TextureMappingContoning.hpp index 15ead60b6b2..85db04523e5 100644 --- a/src/libslic3r/TextureMappingContoning.hpp +++ b/src/libslic3r/TextureMappingContoning.hpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include @@ -96,12 +95,6 @@ public: bool record_nearest_measured_sample_fallback = true) const; private: - struct Candidate { - std::array rgb { { 0.f, 0.f, 0.f } }; - std::array oklab { { 0.f, 0.f, 0.f } }; - std::vector counts; - float dark_score { 0.f }; - }; struct PredictionOptions { const ColorSolverCalibratedStackModel *calibrated_stack_model { nullptr }; bool beer_lambert_rgb_correction_enabled { false }; @@ -109,7 +102,6 @@ private: bool adaptive_spectral_correction_enabled { false }; }; - const std::vector& candidates_for_depth(int stack_layers) const; void arrange_stack_for_light_path(std::vector &bottom_to_top, const std::array &target_rgb) const; std::optional component_index(unsigned int component_id) const; @@ -142,7 +134,6 @@ private: std::vector m_components_bottom_to_top; std::vector> m_component_colors; std::array m_background_rgb { { 0.f, 0.f, 0.f } }; - std::vector m_component_luminance; std::vector m_effective_transmission_distances_mm; std::vector m_component_layer_opacity; float m_layer_height_mm { 0.2f }; @@ -159,8 +150,6 @@ private: ColorSolverCalibratedStackModel m_nearest_measured_sample_fallback_model; int m_nearest_measured_sample_fallback_mode { TextureMappingZone::SlicerDefaultTopSurfaceContoningColorPredictionMode }; std::vector m_component_roles; - mutable std::map> m_candidates_by_depth; - mutable std::shared_ptr m_candidate_mutex { std::make_shared() }; mutable std::shared_ptr m_ordered_candidate_cache { std::make_shared() }; mutable std::shared_ptr m_ordered_candidate_cache_mutex { std::make_shared() }; mutable std::shared_ptr> m_nearest_measured_sample_upper_fallback_used { std::make_shared>(false) };