From c00f9443086752cc8311e0b7a0b08c7debf7ffeb Mon Sep 17 00:00:00 2001 From: "xun.zhang" Date: Wed, 13 Sep 2023 10:46:40 +0800 Subject: [PATCH] ENH: add func to get filament hrc by type 1.Support get filament required hrc by filament type jira:STUDIO-3518 Signed-off-by: xun.zhang Change-Id: If0c1699331b75da17380b9eeca7bb155d98a14c2 --- src/libslic3r/PresetBundle.cpp | 22 ++++++++++++++++++++++ src/libslic3r/PresetBundle.hpp | 1 + 2 files changed, 23 insertions(+) diff --git a/src/libslic3r/PresetBundle.cpp b/src/libslic3r/PresetBundle.cpp index 3c839937e..b9b3c7824 100644 --- a/src/libslic3r/PresetBundle.cpp +++ b/src/libslic3r/PresetBundle.cpp @@ -1273,6 +1273,28 @@ const std::string& PresetBundle::get_preset_name_by_alias( const Preset::Type& p return presets.get_preset_name_by_alias(alias); } +//BBS: get filament required hrc by filament type +const int PresetBundle::get_required_hrc_by_filament_type(const std::string& filament_type) const +{ + static std::unordered_mapfilament_type_to_hrc; + if (filament_type_to_hrc.empty()) { + for (auto iter = filaments.m_presets.begin(); iter != filaments.m_presets.end(); iter++) { + if (iter->vendor && iter->vendor->id == "BBL") { + if (iter->config.has("filament_type") && iter->config.has("required_nozzle_HRC")) { + auto type = iter->config.opt_string("filament_type", 0); + auto hrc = iter->config.opt_int("required_nozzle_HRC", 0); + filament_type_to_hrc[type] = hrc; + } + } + } + } + auto iter = filament_type_to_hrc.find(filament_type); + if (iter != filament_type_to_hrc.end()) + return iter->second; + else + return 0; +} + //BBS: add project embedded preset logic void PresetBundle::save_changes_for_preset(const std::string& new_name, Preset::Type type, const std::vector& unselected_options, bool save_to_project) diff --git a/src/libslic3r/PresetBundle.hpp b/src/libslic3r/PresetBundle.hpp index 61e7626c7..5e44e4e4e 100644 --- a/src/libslic3r/PresetBundle.hpp +++ b/src/libslic3r/PresetBundle.hpp @@ -205,6 +205,7 @@ public: const std::string& get_preset_name_by_alias(const Preset::Type& preset_type, const std::string& alias) const; + const int get_required_hrc_by_filament_type(const std::string& filament_type) const; // Save current preset of a provided type under a new name. If the name is different from the old one, // Unselected option would be reverted to the beginning values //BBS: add project embedded preset logic