Fix infill and surface filaments overriding each other in Filament for features (#17058)

(cherry picked from commit 304924a69a)
This commit is contained in:
Ian Bassi authored and SoftFever committed 2026-11-01 09:53:53 +08:00
1 parent 414857c9d4
commit f4bfb4660f
4 files changed
+32 -50

No files matched your search

-38
View File
@@ -10371,25 +10371,6 @@ void DynamicPrintConfig::normalize_fdm(int used_filaments)
}
}
if (this->has("sparse_infill_filament_id")) {
int sparse_infill_filament_id = this->option("sparse_infill_filament_id")->getInt();
if (sparse_infill_filament_id > 0 && (!this->has("internal_solid_filament_id") || this->option("internal_solid_filament_id")->getInt() == 0))
this->option("internal_solid_filament_id", true)->setInt(sparse_infill_filament_id);
}
const int internal_solid = this->has("internal_solid_filament_id") ? this->option("internal_solid_filament_id")->getInt() : 0;
const int top_surface = this->has("top_surface_filament_id") ? this->option("top_surface_filament_id")->getInt() : 0;
const int bottom_surface = this->has("bottom_surface_filament_id") ? this->option("bottom_surface_filament_id")->getInt() : 0;
if (internal_solid == 0 && top_surface > 0)
this->option("internal_solid_filament_id", true)->setInt(top_surface);
if (internal_solid == 0 && bottom_surface > 0)
this->option("internal_solid_filament_id", true)->setInt(bottom_surface);
if (top_surface == 0 && internal_solid > 0)
this->option("top_surface_filament_id", true)->setInt(internal_solid);
if (bottom_surface == 0 && internal_solid > 0)
this->option("bottom_surface_filament_id", true)->setInt(internal_solid);
if (this->has("spiral_mode") && this->opt<ConfigOptionBool>("spiral_mode", true)->value) {
{
// this should be actually done only on the spiral layers instead of all
@@ -10468,25 +10449,6 @@ void DynamicPrintConfig::normalize_fdm_1()
}
}
if (this->has("sparse_infill_filament_id")) {
int sparse_infill_filament_id = this->option("sparse_infill_filament_id")->getInt();
if (sparse_infill_filament_id > 0 && (!this->has("internal_solid_filament_id") || this->option("internal_solid_filament_id")->getInt() == 0))
this->option("internal_solid_filament_id", true)->setInt(sparse_infill_filament_id);
}
const int internal_solid = this->has("internal_solid_filament_id") ? this->option("internal_solid_filament_id")->getInt() : 0;
const int top_surface = this->has("top_surface_filament_id") ? this->option("top_surface_filament_id")->getInt() : 0;
const int bottom_surface = this->has("bottom_surface_filament_id") ? this->option("bottom_surface_filament_id")->getInt() : 0;
if (internal_solid == 0 && top_surface > 0)
this->option("internal_solid_filament_id", true)->setInt(top_surface);
if (internal_solid == 0 && bottom_surface > 0)
this->option("internal_solid_filament_id", true)->setInt(bottom_surface);
if (top_surface == 0 && internal_solid > 0)
this->option("top_surface_filament_id", true)->setInt(internal_solid);
if (bottom_surface == 0 && internal_solid > 0)
this->option("bottom_surface_filament_id", true)->setInt(internal_solid);
if (this->has("spiral_mode") && this->opt<ConfigOptionBool>("spiral_mode", true)->value) {
{
// this should be actually done only on the spiral layers instead of all
-12
View File
@@ -3093,8 +3093,6 @@ std::vector<int> PartPlate::get_extruders(bool conside_custom_gcode, const Dynam
int glb_internal_solid_extr = glb_config.opt_int("internal_solid_filament_id");
int glb_top_surface_extr = glb_config.opt_int("top_surface_filament_id");
int glb_bottom_surface_extr = glb_config.opt_int("bottom_surface_filament_id");
if (glb_top_surface_extr == 0) glb_top_surface_extr = glb_internal_solid_extr;
if (glb_bottom_surface_extr == 0) glb_bottom_surface_extr = glb_internal_solid_extr;
bool glb_support = glb_config.opt_bool("enable_support");
glb_support |= glb_config.opt_int("raft_layers") > 0;
@@ -3192,8 +3190,6 @@ std::vector<int> PartPlate::get_extruders(bool conside_custom_gcode, const Dynam
int obj_top_surface_extr = 0;
if (const ConfigOption* top_opt = mo->config.option("top_surface_filament_id"); top_opt != nullptr)
obj_top_surface_extr = top_opt->getInt();
if (obj_top_surface_extr == 0)
obj_top_surface_extr = obj_internal_solid_extr;
if (obj_top_surface_extr != 0)
plate_extruders.push_back(obj_top_surface_extr);
else if (glb_top_surface_extr != 0)
@@ -3202,8 +3198,6 @@ std::vector<int> PartPlate::get_extruders(bool conside_custom_gcode, const Dynam
int obj_bottom_surface_extr = 0;
if (const ConfigOption* bottom_opt = mo->config.option("bottom_surface_filament_id"); bottom_opt != nullptr)
obj_bottom_surface_extr = bottom_opt->getInt();
if (obj_bottom_surface_extr == 0)
obj_bottom_surface_extr = obj_internal_solid_extr;
if (obj_bottom_surface_extr != 0)
plate_extruders.push_back(obj_bottom_surface_extr);
else if (glb_bottom_surface_extr != 0)
@@ -3264,8 +3258,6 @@ std::vector<int> PartPlate::get_extruders_under_cli(bool conside_custom_gcode, D
int glb_internal_solid_extr = full_config.opt_int("internal_solid_filament_id");
int glb_top_surface_extr = full_config.opt_int("top_surface_filament_id");
int glb_bottom_surface_extr = full_config.opt_int("bottom_surface_filament_id");
if (glb_top_surface_extr == 0) glb_top_surface_extr = glb_internal_solid_extr;
if (glb_bottom_surface_extr == 0) glb_bottom_surface_extr = glb_internal_solid_extr;
bool glb_support = full_config.opt_bool("enable_support");
glb_support |= full_config.opt_int("raft_layers") > 0;
@@ -3370,8 +3362,6 @@ std::vector<int> PartPlate::get_extruders_under_cli(bool conside_custom_gcode, D
int obj_top_surface_extr = 0;
if (const ConfigOption* top_opt = object->config.option("top_surface_filament_id"); top_opt != nullptr)
obj_top_surface_extr = top_opt->getInt();
if (obj_top_surface_extr == 0)
obj_top_surface_extr = obj_internal_solid_extr;
if (obj_top_surface_extr != 0)
plate_extruders.push_back(obj_top_surface_extr);
else if (glb_top_surface_extr != 0)
@@ -3380,8 +3370,6 @@ std::vector<int> PartPlate::get_extruders_under_cli(bool conside_custom_gcode, D
int obj_bottom_surface_extr = 0;
if (const ConfigOption* bottom_opt = object->config.option("bottom_surface_filament_id"); bottom_opt != nullptr)
obj_bottom_surface_extr = bottom_opt->getInt();
if (obj_bottom_surface_extr == 0)
obj_bottom_surface_extr = obj_internal_solid_extr;
if (obj_bottom_surface_extr != 0)
plate_extruders.push_back(obj_bottom_surface_extr);
else if (glb_bottom_surface_extr != 0)
+22
View File
@@ -370,6 +370,28 @@ static std::set<int> tools_for_feature(const std::string& gcode, std::string_vie
return tools;
}
// Choosing the filament of one infill or surface must not move the others off "Default", the object's filament.
TEST_CASE("Infill and surfaces left on Default print with the object filament", "[MultiFilament]")
{
const std::pair<const char *, std::string_view> features[] = {
{ "sparse_infill_filament_id", "Sparse infill" },
{ "internal_solid_filament_id", "Internal solid infill" },
{ "top_surface_filament_id", "Top surface" },
{ "bottom_surface_filament_id", "Bottom surface" },
};
const std::string set_key = GENERATE("sparse_infill_filament_id", "internal_solid_filament_id",
"top_surface_filament_id", "bottom_surface_filament_id");
CAPTURE(set_key);
DynamicPrintConfig config = multifilament_config(2, { { "skirt_loops", 0 }, { "brim_type", "no_brim" } });
config.set_deserialize_strict(set_key, "2");
const std::string gcode = slice({ cube(20) }, config);
for (const auto &[key, feature] : features) {
CAPTURE(feature);
CHECK(tools_for_feature(gcode, feature) == std::set<int>{ key == set_key ? 1 : 0 });
}
}
// A 20x20mm slab on a 4x4mm pillar: on the slab's first layer both walls are overhangs from end to end, so
// only their wall index tells the inner wall from the outer one.
TEST_CASE("Overhanging inner walls print with the inner wall filament", "[MultiFilament]")
+10
View File
@@ -1544,6 +1544,16 @@ TEST_CASE("handle_legacy migrates the adaptive TPMS keys", "[Config]") {
CHECK(ctxt.substitutions.empty());
}
TEST_CASE("normalize_fdm leaves feature filaments on Default", "[Config]") {
DynamicPrintConfig config;
config.set_key_value("sparse_infill_filament_id", new ConfigOptionInt(2));
config.set_key_value("internal_solid_filament_id", new ConfigOptionInt(0));
config.set_key_value("top_surface_filament_id", new ConfigOptionInt(3));
config.normalize_fdm();
CHECK(config.opt_int("internal_solid_filament_id") == 0);
CHECK_FALSE(config.has("bottom_surface_filament_id"));
}
TEST_CASE("silent_mode is no longer saved and is dropped on load", "[Config]") {
DynamicPrintConfig full;
full.apply(FullPrintConfig::defaults());