mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-08-06 01:27:40 +00:00
feat(engine): wire the per-filament volume-map producer pipeline
- Print::update_filament_maps_to_config takes filament/volume/nozzle maps, backfills an empty volume map from extruder types, rebuilds filament_map_2, re-expands the per-filament variant arrays, and recomputes retract overrides keyed by resolved slots - grouping writes its result back in every non-sequential mode; manual multi-nozzle grouping validates the user mapping and raises a translatable error on deviation; the engine's concrete volume assignment is deliberately not merged yet (per-filament arrays are already consumed by filament id, so materializing High Flow now would change motion before the layer-aware resolvers land) - Print::apply treats the three map keys as engine outputs in auto modes (erased from the diff and adopted), compares them against used filaments in manual mode, and keeps the pre-expansion snapshot in sync with the late normalization pass so rebuilt headers reflect the sliced state instead of resurrecting stale values - volume/nozzle maps and extruder_nozzle_stats join the invalidation group of filament_map (wipe tower + skirt/brim) - PresetBundle composes full configs with an optional per-filament volume map (plate map, else defaults derived from each extruder's flow type); project config keeps the map sized across filament count changes - PartPlate stores per-plate volume/nozzle maps; Plater injects them at every slice-composition site (incl. g-code reload and wipe-tower estimation); BackgroundSlicingProcess reads engine results back to the plate in auto modes - per-filament map trust guards relaxed to size-match everywhere now that every producer sizes the map; single-filament explicit flow assignments are honored - tests: grouping volume maps stay concrete, merge semantics of update_used_filament_values, single-filament override honoring Motion g-code is byte-identical fleet-wide including Hybrid projects (19-fixture gate + repro determinism double-slice). Header deltas: the map keys now dump real values, and stale pre-normalization values (e.g. enable_prime_tower on single-used-filament prints) no longer leak into the config block.
This commit is contained in:
@@ -58,6 +58,9 @@ static std::vector<std::string> s_project_options {
|
||||
"nozzle_volume_type",
|
||||
"filament_map_mode",
|
||||
"filament_map",
|
||||
// Per-filament nozzle-volume choice; project-level like filament_map so the per-filament
|
||||
// slot resolution survives preset switches.
|
||||
"filament_volume_map",
|
||||
// Filament Track Switch device state: whether the switch is installed and ready, and
|
||||
// whether dynamic per-nozzle filament mapping is active. Persisted with the project and
|
||||
// restored from a saved 3mf; reset to false on load and set true only by live device sync.
|
||||
@@ -79,7 +82,8 @@ DynamicPrintConfig PresetBundle::construct_full_config(
|
||||
const DynamicPrintConfig& project_config,
|
||||
std::vector<Preset>& in_filament_presets,
|
||||
bool apply_extruder,
|
||||
std::optional<std::vector<int>> filament_maps_new)
|
||||
std::optional<std::vector<int>> filament_maps_new,
|
||||
std::optional<std::vector<int>> filament_volume_maps_new)
|
||||
{
|
||||
DynamicPrintConfig &printer_config = in_printer_preset.config;
|
||||
DynamicPrintConfig &print_config = in_print_preset.config;
|
||||
@@ -94,12 +98,23 @@ DynamicPrintConfig PresetBundle::construct_full_config(
|
||||
size_t num_filaments = in_filament_presets.size();
|
||||
|
||||
std::vector<int> filament_maps = out.option<ConfigOptionInts>("filament_map")->values;
|
||||
std::vector<int> filament_volume_maps(num_filaments, (int)nvtStandard);
|
||||
|
||||
ConfigOptionInts* filament_volume_map_opt = out.option<ConfigOptionInts>("filament_volume_map");
|
||||
if (filament_maps_new.has_value())
|
||||
filament_maps = *filament_maps_new;
|
||||
if (filament_volume_maps_new.has_value())
|
||||
filament_volume_maps = *filament_volume_maps_new;
|
||||
else if (filament_volume_map_opt && filament_volume_map_opt->values.size() == num_filaments)
|
||||
filament_volume_maps = filament_volume_map_opt->values;
|
||||
|
||||
// in some middle state, they may be different
|
||||
if (filament_maps.size() != num_filaments) {
|
||||
filament_maps.resize(num_filaments, 1);
|
||||
}
|
||||
if (filament_volume_maps.size() != num_filaments) {
|
||||
filament_volume_maps.resize(num_filaments, nvtStandard);
|
||||
}
|
||||
|
||||
auto *extruder_diameter = dynamic_cast<const ConfigOptionFloats *>(out.option("nozzle_diameter"));
|
||||
// Collect the "compatible_printers_condition" and "inherits" values over all presets (print, filaments, printers) into a single vector.
|
||||
@@ -147,7 +162,7 @@ DynamicPrintConfig PresetBundle::construct_full_config(
|
||||
// BBS: update filament config related with variants
|
||||
DynamicPrintConfig filament_config = in_filament_presets[0].config;
|
||||
if (apply_extruder && ((extruder_count > 1) || different_extruder))
|
||||
filament_config.update_values_to_printer_extruders(out, extruder_count, extruder_volume_type_count, nozzle_volume_types, filament_options_with_variant, "", "filament_extruder_variant", 1, filament_maps[0]);
|
||||
filament_config.update_values_to_printer_extruders(out, extruder_count, extruder_volume_type_count, nozzle_volume_types, filament_options_with_variant, "", "filament_extruder_variant", 1, filament_maps[0], (NozzleVolumeType)filament_volume_maps[0]);
|
||||
out.apply(filament_config);
|
||||
compatible_printers_condition.emplace_back(in_filament_presets[0].compatible_printers_condition());
|
||||
compatible_prints_condition.emplace_back(in_filament_presets[0].compatible_prints_condition());
|
||||
@@ -171,7 +186,7 @@ DynamicPrintConfig PresetBundle::construct_full_config(
|
||||
for (size_t i = 0; i < num_filaments; ++i) {
|
||||
filament_temp_configs[i] = *(filament_configs[i]);
|
||||
if (apply_extruder && ((extruder_count > 1) || different_extruder))
|
||||
filament_temp_configs[i].update_values_to_printer_extruders(out, extruder_count, extruder_volume_type_count, nozzle_volume_types, filament_options_with_variant, "", "filament_extruder_variant", 1, filament_maps[i]);
|
||||
filament_temp_configs[i].update_values_to_printer_extruders(out, extruder_count, extruder_volume_type_count, nozzle_volume_types, filament_options_with_variant, "", "filament_extruder_variant", 1, filament_maps[i], (NozzleVolumeType)filament_volume_maps[i]);
|
||||
}
|
||||
|
||||
// loop through options and apply them to the resulting config.
|
||||
@@ -246,6 +261,7 @@ DynamicPrintConfig PresetBundle::construct_full_config(
|
||||
out.option<ConfigOptionString>("printer_settings_id", true)->value = in_printer_preset.name;
|
||||
out.option<ConfigOptionStrings>("filament_ids", true)->values = filament_ids;
|
||||
out.option<ConfigOptionInts>("filament_map", true)->values = filament_maps;
|
||||
out.option<ConfigOptionInts>("filament_volume_map", true)->values = filament_volume_maps;
|
||||
|
||||
auto add_if_some_non_empty = [&out](std::vector<std::string> &&values, const std::string &key) {
|
||||
bool nonempty = false;
|
||||
@@ -2701,6 +2717,9 @@ void PresetBundle::update_selections(AppConfig &config)
|
||||
std::vector<int> filament_maps(filament_colors.size(), 1);
|
||||
project_config.option<ConfigOptionInts>("filament_map")->values = filament_maps;
|
||||
|
||||
std::vector<int> filament_volume_maps(filament_colors.size(), static_cast<int>(NozzleVolumeType::nvtStandard));
|
||||
project_config.option<ConfigOptionInts>("filament_volume_map")->values = filament_volume_maps;
|
||||
|
||||
std::vector<std::string> extruder_ams_count_str;
|
||||
if (config.has_printer_setting(initial_printer_profile_name, "extruder_ams_count")) {
|
||||
boost::algorithm::split(extruder_ams_count_str, config.get_printer_setting(initial_printer_profile_name, "extruder_ams_count"), boost::algorithm::is_any_of(","));
|
||||
@@ -2845,6 +2864,9 @@ void PresetBundle::load_selections(AppConfig &config, const PresetPreferences& p
|
||||
std::vector<int> filament_maps(filament_colors.size(), 1);
|
||||
project_config.option<ConfigOptionInts>("filament_map")->values = filament_maps;
|
||||
|
||||
std::vector<int> filament_volume_maps(filament_colors.size(), static_cast<int>(NozzleVolumeType::nvtStandard));
|
||||
project_config.option<ConfigOptionInts>("filament_volume_map")->values = filament_volume_maps;
|
||||
|
||||
std::vector<std::string> extruder_ams_count_str;
|
||||
if (config.has_printer_setting(initial_printer_profile_name, "extruder_ams_count")) {
|
||||
boost::algorithm::split(extruder_ams_count_str, config.get_printer_setting(initial_printer_profile_name, "extruder_ams_count"), boost::algorithm::is_any_of(","));
|
||||
@@ -3021,7 +3043,7 @@ void PresetBundle::set_num_filaments(unsigned int n, std::vector<std::string> ne
|
||||
ConfigOptionStrings *filament_multi_color = project_config.option<ConfigOptionStrings>("filament_multi_colour");
|
||||
ConfigOptionStrings* filament_color_type = project_config.option<ConfigOptionStrings>("filament_colour_type");
|
||||
ConfigOptionInts* filament_map = project_config.option<ConfigOptionInts>("filament_map");
|
||||
|
||||
ConfigOptionInts* filament_volume_map = project_config.option<ConfigOptionInts>("filament_volume_map");
|
||||
|
||||
filament_color->resize(n);
|
||||
// Sync filament multi colour
|
||||
@@ -3031,6 +3053,7 @@ void PresetBundle::set_num_filaments(unsigned int n, std::vector<std::string> ne
|
||||
}
|
||||
filament_color_type->resize(n);
|
||||
filament_map->values.resize(n, 1);
|
||||
filament_volume_map->values.resize(n, static_cast<int>(NozzleVolumeType::nvtStandard));
|
||||
ams_multi_color_filment.resize(n);
|
||||
|
||||
// BBS set new filament color to new_color
|
||||
@@ -3058,7 +3081,7 @@ void PresetBundle::set_num_filaments(unsigned int n, std::string new_color)
|
||||
ConfigOptionStrings *filament_multi_color = project_config.option<ConfigOptionStrings>("filament_multi_colour");
|
||||
ConfigOptionStrings* filament_color_type = project_config.option<ConfigOptionStrings>("filament_colour_type");
|
||||
ConfigOptionInts* filament_map = project_config.option<ConfigOptionInts>("filament_map");
|
||||
|
||||
ConfigOptionInts* filament_volume_map = project_config.option<ConfigOptionInts>("filament_volume_map");
|
||||
|
||||
filament_color->resize(n);
|
||||
// Sync filament multi colour
|
||||
@@ -3068,6 +3091,7 @@ void PresetBundle::set_num_filaments(unsigned int n, std::string new_color)
|
||||
}
|
||||
filament_color_type->resize(n);
|
||||
filament_map->values.resize(n, 1);
|
||||
filament_volume_map->values.resize(n, static_cast<int>(NozzleVolumeType::nvtStandard));
|
||||
ams_multi_color_filment.resize(n);
|
||||
|
||||
//BBS set new filament color to new_color
|
||||
@@ -3108,15 +3132,20 @@ void PresetBundle::update_num_filaments(unsigned int to_del_flament_id)
|
||||
ConfigOptionStrings *filament_multi_color = project_config.option<ConfigOptionStrings>("filament_multi_colour");
|
||||
ConfigOptionStrings *filament_color_type = project_config.option<ConfigOptionStrings>("filament_colour_type");
|
||||
ConfigOptionInts* filament_map = project_config.option<ConfigOptionInts>("filament_map");
|
||||
ConfigOptionInts* filament_volume_map = project_config.option<ConfigOptionInts>("filament_volume_map");
|
||||
if (filament_color->values.size() > to_del_flament_id) {
|
||||
filament_color->values.erase(filament_color->values.begin() + to_del_flament_id);
|
||||
if (filament_map->values.size() > to_del_flament_id) {
|
||||
filament_map->values.erase(filament_map->values.begin() + to_del_flament_id);
|
||||
}
|
||||
if (filament_volume_map->values.size() > to_del_flament_id) {
|
||||
filament_volume_map->values.erase(filament_volume_map->values.begin() + to_del_flament_id);
|
||||
}
|
||||
}
|
||||
else {
|
||||
filament_color->values.resize(to_del_flament_id);
|
||||
filament_map->values.resize(to_del_flament_id, 1);
|
||||
filament_volume_map->values.resize(to_del_flament_id, static_cast<int>(NozzleVolumeType::nvtStandard));
|
||||
}
|
||||
|
||||
// lambda function to erase or resize the container
|
||||
@@ -3339,6 +3368,7 @@ unsigned int PresetBundle::sync_ams_list(std::vector<std::pair<DynamicPrintConfi
|
||||
ConfigOptionStrings *filament_color = project_config.option<ConfigOptionStrings>("filament_colour");
|
||||
ConfigOptionStrings *filament_color_type = project_config.option<ConfigOptionStrings>("filament_colour_type");
|
||||
ConfigOptionInts * filament_map = project_config.option<ConfigOptionInts>("filament_map");
|
||||
ConfigOptionInts * filament_volume_map = project_config.option<ConfigOptionInts>("filament_volume_map");
|
||||
if (color_only) {
|
||||
auto get_map_index = [&ams_infos](const std::vector<AMSMapInfo> &infos, const AMSMapInfo &temp) {
|
||||
for (int i = 0; i < infos.size(); i++) {
|
||||
@@ -3520,6 +3550,7 @@ unsigned int PresetBundle::sync_ams_list(std::vector<std::pair<DynamicPrintConfi
|
||||
ams_multi_color_filment = exist_multi_color_filment;
|
||||
this->filament_presets = exist_filament_presets;
|
||||
filament_map->values.resize(exist_filament_presets.size(), 1);
|
||||
filament_volume_map->values.resize(exist_filament_presets.size(), static_cast<int>(NozzleVolumeType::nvtStandard));
|
||||
}
|
||||
else {//overwrite;
|
||||
bool has_placeholders = std::any_of(ams_infos.begin(), ams_infos.end(),
|
||||
@@ -3574,12 +3605,14 @@ unsigned int PresetBundle::sync_ams_list(std::vector<std::pair<DynamicPrintConfi
|
||||
this->filament_presets = result_presets;
|
||||
ams_multi_color_filment = result_multi_colors;
|
||||
filament_map->values.resize(total, 1);
|
||||
filament_volume_map->values.resize(total, static_cast<int>(NozzleVolumeType::nvtStandard));
|
||||
} else {
|
||||
// BBL: existing wholesale replace
|
||||
filament_color->values = ams_filament_colors;
|
||||
filament_color_type->values = ams_filament_color_types;
|
||||
this->filament_presets = ams_filament_presets;
|
||||
filament_map->values.resize(ams_filament_colors.size(), 1);
|
||||
filament_volume_map->values.resize(ams_filament_colors.size(), static_cast<int>(NozzleVolumeType::nvtStandard));
|
||||
}
|
||||
|
||||
auto& print_config = this->prints.get_edited_preset().config;
|
||||
@@ -3882,10 +3915,26 @@ bool PresetBundle::support_different_extruders() const
|
||||
return supported;
|
||||
}
|
||||
|
||||
DynamicPrintConfig PresetBundle::full_config(bool apply_extruder, std::optional<std::vector<int>>filament_maps) const
|
||||
std::vector<int> PresetBundle::get_default_nozzle_volume_types_for_filaments(std::vector<int>& f_maps)
|
||||
{
|
||||
std::vector<int> result;
|
||||
int filament_count = f_maps.size();
|
||||
result.resize(filament_count, static_cast<int>(NozzleVolumeType::nvtStandard));
|
||||
|
||||
auto opt_nozzle_volume_type = dynamic_cast<const ConfigOptionEnumsGeneric*>(this->project_config.option("nozzle_volume_type"));
|
||||
for (int index = 0; index < filament_count; index++)
|
||||
{
|
||||
if (opt_nozzle_volume_type && opt_nozzle_volume_type->values.size() > (f_maps[index] - 1))
|
||||
result[index] = opt_nozzle_volume_type->values[f_maps[index] - 1];
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
DynamicPrintConfig PresetBundle::full_config(bool apply_extruder, std::optional<std::vector<int>>filament_maps, std::optional<std::vector<int>> filament_volume_maps) const
|
||||
{
|
||||
return (this->printers.get_edited_preset().printer_technology() == ptFFF) ?
|
||||
this->full_fff_config(apply_extruder, filament_maps) :
|
||||
this->full_fff_config(apply_extruder, filament_maps, filament_volume_maps) :
|
||||
this->full_sla_config();
|
||||
}
|
||||
|
||||
@@ -3944,7 +3993,7 @@ const std::set<std::string> ignore_settings_list ={
|
||||
"print_settings_id", "filament_settings_id", "printer_settings_id"
|
||||
};
|
||||
|
||||
DynamicPrintConfig PresetBundle::full_fff_config(bool apply_extruder, std::optional<std::vector<int>> filament_maps_new) const
|
||||
DynamicPrintConfig PresetBundle::full_fff_config(bool apply_extruder, std::optional<std::vector<int>> filament_maps_new, std::optional<std::vector<int>> filament_volume_maps_new) const
|
||||
{
|
||||
DynamicPrintConfig out;
|
||||
out.apply(FullPrintConfig::defaults());
|
||||
@@ -3958,8 +4007,17 @@ DynamicPrintConfig PresetBundle::full_fff_config(bool apply_extruder, std::optio
|
||||
size_t num_filaments = this->filament_presets.size();
|
||||
|
||||
std::vector<int> filament_maps = out.option<ConfigOptionInts>("filament_map")->values;
|
||||
std::vector<int> filament_volume_maps(num_filaments, (int)nvtStandard);
|
||||
|
||||
ConfigOptionInts* filament_volume_map_opt = out.option<ConfigOptionInts>("filament_volume_map");
|
||||
if (filament_maps_new.has_value())
|
||||
filament_maps = *filament_maps_new;
|
||||
if (filament_volume_maps_new.has_value()) {
|
||||
filament_volume_maps = *filament_volume_maps_new;
|
||||
out.option<ConfigOptionInts>("filament_volume_map", true)->values = filament_volume_maps;
|
||||
}
|
||||
else if (filament_volume_map_opt && filament_volume_map_opt->values.size() == num_filaments)
|
||||
filament_volume_maps = filament_volume_map_opt->values;
|
||||
//in some middle state, they may be different
|
||||
if (filament_maps.size() != num_filaments) {
|
||||
filament_maps.resize(num_filaments, 1);
|
||||
@@ -3967,6 +4025,9 @@ DynamicPrintConfig PresetBundle::full_fff_config(bool apply_extruder, std::optio
|
||||
else {
|
||||
assert(filament_maps.size() == num_filaments);
|
||||
}
|
||||
if (filament_volume_maps.size() != num_filaments) {
|
||||
filament_volume_maps.resize(num_filaments, nvtStandard);
|
||||
}
|
||||
|
||||
auto* extruder_diameter = dynamic_cast<const ConfigOptionFloats*>(out.option("nozzle_diameter"));
|
||||
// Collect the "compatible_printers_condition" and "inherits" values over all presets (print, filaments, printers) into a single vector.
|
||||
@@ -4023,7 +4084,7 @@ DynamicPrintConfig PresetBundle::full_fff_config(bool apply_extruder, std::optio
|
||||
//BBS: update filament config related with variants
|
||||
DynamicPrintConfig filament_config = this->filaments.get_edited_preset().config;
|
||||
if (apply_extruder && ((extruder_count > 1) || different_extruder))
|
||||
filament_config.update_values_to_printer_extruders(out, extruder_count, extruder_volume_type_count, nozzle_volume_types, filament_options_with_variant, "", "filament_extruder_variant", 1, filament_maps[0]);
|
||||
filament_config.update_values_to_printer_extruders(out, extruder_count, extruder_volume_type_count, nozzle_volume_types, filament_options_with_variant, "", "filament_extruder_variant", 1, filament_maps[0], (NozzleVolumeType)filament_volume_maps[0]);
|
||||
out.apply(filament_config);
|
||||
compatible_printers_condition.emplace_back(this->filaments.get_edited_preset().compatible_printers_condition());
|
||||
compatible_prints_condition .emplace_back(this->filaments.get_edited_preset().compatible_prints_condition());
|
||||
@@ -4117,7 +4178,7 @@ DynamicPrintConfig PresetBundle::full_fff_config(bool apply_extruder, std::optio
|
||||
for (size_t i = 0; i < num_filaments; ++i) {
|
||||
filament_temp_configs[i] = *(filament_configs[i]);
|
||||
if (apply_extruder && ((extruder_count > 1) || different_extruder))
|
||||
filament_temp_configs[i].update_values_to_printer_extruders(out, extruder_count, extruder_volume_type_count, nozzle_volume_types, filament_options_with_variant, "", "filament_extruder_variant", 1, filament_maps[i]);
|
||||
filament_temp_configs[i].update_values_to_printer_extruders(out, extruder_count, extruder_volume_type_count, nozzle_volume_types, filament_options_with_variant, "", "filament_extruder_variant", 1, filament_maps[i], (NozzleVolumeType)filament_volume_maps[i]);
|
||||
}
|
||||
|
||||
// loop through options and apply them to the resulting config.
|
||||
|
||||
Reference in New Issue
Block a user