mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-10 09:11:08 +00:00
Fix loading a multi-toolhead 3MF that has no filament_self_index (#16331)
This commit is contained in:
@@ -5381,13 +5381,15 @@ void PresetBundle::load_config_file_config(const std::string &name_or_path, bool
|
||||
bool process_multi_extruder = false;
|
||||
std::vector<int> filament_variant_index;
|
||||
size_t extruder_variant_count;
|
||||
if (!config.option<ConfigOptionInts>("filament_self_index")) {
|
||||
std::vector<int>& filament_self_indice = config.option<ConfigOptionInts>("filament_self_index", true)->values;
|
||||
// A config loaded over the full defaults has a one-entry index even when the file has none.
|
||||
ConfigOptionInts* filament_self_index_opt = config.option<ConfigOptionInts>("filament_self_index", true);
|
||||
if (filament_self_index_opt->size() < num_filaments) {
|
||||
std::vector<int>& filament_self_indice = filament_self_index_opt->values;
|
||||
filament_self_indice.resize(num_filaments);
|
||||
for (int index = 0; index < num_filaments; index++)
|
||||
filament_self_indice[index] = index + 1;
|
||||
}
|
||||
std::vector<int> filament_self_indice = std::move(config.option<ConfigOptionInts>("filament_self_index")->values);
|
||||
std::vector<int> filament_self_indice = std::move(filament_self_index_opt->values);
|
||||
// ORCA: Initialize filament_extruder_variant for backward compatibility with old 3mf files
|
||||
// that don't have this option saved or have it with default single-element value
|
||||
ConfigOptionStrings* filament_extruder_variant_opt = config.option<ConfigOptionStrings>("filament_extruder_variant");
|
||||
|
||||
@@ -5888,6 +5888,21 @@ TEST_CASE("A project saved with pressure advance per filament applies it to ever
|
||||
check_double_vector(petg.opt<ConfigOptionFloatsNullable>("filament_flow_ratio")->values, { 0.97 });
|
||||
}
|
||||
|
||||
TEST_CASE("A multi-toolhead project saved without filament self indices loads every filament", "[Preset][Bundle]")
|
||||
{
|
||||
const std::vector<std::string> colors = { "#FF0000", "#000000", "#FFFFFF", "#FFFF00" };
|
||||
DynamicPrintConfig config = DynamicPrintConfig::full_print_config();
|
||||
config.opt<ConfigOptionStrings>("filament_colour")->values = colors;
|
||||
config.opt<ConfigOptionFloats>("nozzle_diameter")->values = std::vector<double>(colors.size(), 0.4);
|
||||
config.option<ConfigOptionBool>("single_extruder_multi_material")->value = false;
|
||||
Preset::normalize(config);
|
||||
|
||||
PresetBundle bundle;
|
||||
REQUIRE_NOTHROW(bundle.load_config_model("test.3mf", std::move(config)));
|
||||
CHECK(bundle.filament_presets.size() == colors.size());
|
||||
CHECK(bundle.project_config.opt<ConfigOptionStrings>("filament_colour")->values == colors);
|
||||
}
|
||||
|
||||
TEST_CASE("A system preset resolves by name from the bundled profiles", "[Preset][Bundle]")
|
||||
{
|
||||
ScopedTemporaryDir temp_dir;
|
||||
|
||||
Reference in New Issue
Block a user