diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index 24ac4382e..1531802ad 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -880,41 +880,51 @@ static StringObjectException layered_print_cleareance_valid(const Print &print, return {}; } -//BBS -static std::map filament_is_high_temp { - {"PLA", false}, - {"PLA-CF", false}, - //{"PETG", true}, - {"ABS", true}, - {"TPU", false}, - {"PA", true}, - {"PA-CF", true}, - {"PET-CF", true}, - {"PC", true}, - {"ASA", true}, - {"HIPS", true} -}; - -//BBS: this function is used to check whether multi filament can be printed -StringObjectException Print::check_multi_filament_valid(const Print& print) +bool Print::check_multi_filaments_compatibility(const std::vector& filament_types) { + static std::map filament_is_high_temp{ + {"PLA", false}, + {"PLA-CF", false}, + //{"PETG", true}, + {"ABS", true}, + {"TPU", false}, + {"PA", true}, + {"PA-CF", true}, + {"PET-CF", true}, + {"PC", true}, + {"ASA", true}, + {"HIPS", true} + }; + bool has_high_temperature_filament = false; bool has_low_temperature_filament = false; - auto print_config = print.config(); - std::vector extruders = print.extruders(); - - for (const auto& extruder_idx : extruders) { - std::string filament_type = print_config.filament_type.get_at(extruder_idx); - if (filament_is_high_temp.find(filament_type) != filament_is_high_temp.end()) { - if (filament_is_high_temp[filament_type]) + for (const auto& type : filament_types) + if (filament_is_high_temp.find(type) != filament_is_high_temp.end()) { + if (filament_is_high_temp[type]) has_high_temperature_filament = true; else has_low_temperature_filament = true; } - } if (has_high_temperature_filament && has_low_temperature_filament) + return false; + + return true; +} + +//BBS: this function is used to check whether multi filament can be printed +StringObjectException Print::check_multi_filament_valid(const Print& print) +{ + auto print_config = print.config(); + std::vector extruders = print.extruders(); + std::vector filament_types; + filament_types.reserve(extruders.size()); + + for (const auto& extruder_idx : extruders) + filament_types.push_back(print_config.filament_type.get_at(extruder_idx)); + + if (!check_multi_filaments_compatibility(filament_types)) return { L("Can not print multiple filaments which have large difference of temperature together. Otherwise, the extruder and nozzle may be blocked or damaged during printing") }; return {std::string()}; diff --git a/src/libslic3r/Print.hpp b/src/libslic3r/Print.hpp index 51a5b0dbc..801514710 100644 --- a/src/libslic3r/Print.hpp +++ b/src/libslic3r/Print.hpp @@ -819,6 +819,8 @@ public: // scaled point Vec2d translate_to_print_space(const Point& point) const; + static bool check_multi_filaments_compatibility(const std::vector& filament_types); + protected: // Invalidates the step, and its depending steps in Print. bool invalidate_step(PrintStep step);