diff --git a/src/libslic3r/Brim.cpp b/src/libslic3r/Brim.cpp index e865efc781..cd75d3f31a 100644 --- a/src/libslic3r/Brim.cpp +++ b/src/libslic3r/Brim.cpp @@ -7,6 +7,7 @@ #include "ShortestPath.hpp" #include "libslic3r.h" #include "PrintConfig.hpp" +#include "MaterialType.hpp" #include "Model.hpp" #include #include @@ -590,13 +591,10 @@ double getadhesionCoeff(const PrintObject* printObject) for (auto iter = extrudersFirstLayer.begin(); iter != extrudersFirstLayer.end(); iter++) { if (modelVolume->extruder_id() == *iter) { if (Model::extruderParamsMap.find(modelVolume->extruder_id()) != Model::extruderParamsMap.end()) { - if (Model::extruderParamsMap.at(modelVolume->extruder_id()).materialName == "PETG" || - Model::extruderParamsMap.at(modelVolume->extruder_id()).materialName == "PCTG") { - adhesionCoeff = 2; - } - else if (Model::extruderParamsMap.at(modelVolume->extruder_id()).materialName == "TPU") { - adhesionCoeff = 0.5; - } + std::string filament_type = Model::extruderParamsMap.at(modelVolume->extruder_id()).materialName; + double adhesion_coefficient = 1.0; // Default value + MaterialType::get_adhesion_coefficient(filament_type, adhesion_coefficient); + adhesionCoeff = adhesion_coefficient; } } } diff --git a/src/libslic3r/CMakeLists.txt b/src/libslic3r/CMakeLists.txt index d85c65fd51..747fdcdb67 100644 --- a/src/libslic3r/CMakeLists.txt +++ b/src/libslic3r/CMakeLists.txt @@ -340,6 +340,8 @@ set(lisbslic3r_sources PrintApply.cpp PrintBase.cpp PrintBase.hpp + MaterialType.cpp + MaterialType.hpp PrintConfig.cpp PrintConfig.hpp Print.cpp diff --git a/src/libslic3r/MaterialType.cpp b/src/libslic3r/MaterialType.cpp new file mode 100644 index 0000000000..8307b0e2dd --- /dev/null +++ b/src/libslic3r/MaterialType.cpp @@ -0,0 +1,169 @@ +#include "MaterialType.hpp" + +#include + +namespace Slic3r { +namespace { +constexpr int DEFAULT_MIN_TEMP = 190; +constexpr int DEFAULT_MAX_TEMP = 300; +constexpr int DEFAULT_CHAMBER_MIN_TEMP = 0; +constexpr int DEFAULT_CHAMBER_MAX_TEMP = 100; +constexpr double DEFAULT_ADHESION_COEFFICIENT = 1.0; +constexpr double DEFAULT_YIELD_STRENGTH = 0.02; +constexpr double DEFAULT_THERMAL_LENGTH = 200.0; +} // namespace + +const std::vector& MaterialType::all() +{ + static const std::vector material_types = { + {"ABS", 190, 300, 50, 65, 1, 0.1 , 100}, + {"ABS-CF", 220, 300, 50, 65, 1, 0.1 , 100}, + {"ABS-GF", 240, 280, 50, 65, 1, 0.1 , 100}, + {"ASA", 220, 300, 50, 65, 1, 0.1 , 100}, + {"ASA-CF", 230, 300, 50, 65, 1, 0.1 , 100}, + {"ASA-GF", 240, 300, 50, 65, 1, 0.1 , 100}, + {"ASA-Aero", 240, 280, 50, 65, 1, 0.1 , 100}, + {"BVOH", 190, 240, 0, 70, 1, 0.02, 200}, + {"EVA", 175, 220, 0, 50, 1, 0.02, 200}, + {"FLEX", 210, 230, 0, 50, 0.5, 0.02, 1000}, + {"HIPS", 220, 270, 50, 60, 1, 0.02, 200}, + {"PA", 235, 280, 50, 60, 1, 0.02, 100}, + {"PA-CF", 240, 315, 50, 60, 1, 0.02, 100}, + {"PA-GF", 240, 290, 50, 60, 1, 0.02, 100}, + {"PA6", 260, 300, 50, 60, 1, 0.02, 100}, + {"PA6-CF", 230, 300, 50, 60, 1, 0.02, 100}, + {"PA6-GF", 260, 300, 50, 60, 1, 0.02, 100}, + {"PA11", 275, 295, 50, 60, 1, 0.02, 100}, + {"PA11-CF", 275, 295, 50, 60, 1, 0.02, 100}, + {"PA11-GF", 275, 295, 50, 60, 1, 0.02, 100}, + {"PA12", 250, 270, 50, 60, 1, 0.02, 100}, + {"PA12-CF", 250, 300, 50, 60, 1, 0.02, 100}, + {"PA12-GF", 255, 270, 50, 60, 1, 0.02, 100}, + {"PAHT", 260, 310, 55, 65, 1, 0.02, 200}, + {"PAHT-CF", 270, 310, 55, 65, 1, 0.02, 200}, + {"PAHT-GF", 270, 310, 55, 65, 1, 0.02, 200}, + {"PC", 240, 300, 60, 70, 1, 0.02, 40}, + {"PC-ABS", 230, 270, 60, 70, 1, 0.02, 80}, + {"PC-CF", 270, 295, 60, 70, 1, 0.02, 80}, + {"PC-PBT", 260, 300, 60, 70, 1, 0.02, 40}, + {"PCL", 130, 170, 0, 45, 1, 0.02, 200}, + {"PCTG", 220, 300, 0, 55, 2, 0.02, 200}, + {"PE", 175, 260, 45, 60, 1, 0.02, 200}, + {"PE-CF", 175, 260, 45, 60, 1, 0.02, 200}, + {"PE-GF", 230, 270, 45, 60, 1, 0.02, 200}, + {"PEI-1010", 370, 430, 80, 100, 1, 0.02, 200}, + {"PEI-1010-CF", 380, 430, 80, 100, 1, 0.02, 200}, + {"PEI-1010-GF", 380, 430, 80, 100, 1, 0.02, 200}, + {"PEI-9085", 350, 390, 80, 100, 1, 0.02, 200}, + {"PEI-9085-CF", 365, 390, 80, 100, 1, 0.02, 200}, + {"PEI-9085-GF", 370, 390, 80, 100, 1, 0.02, 200}, + {"PEEK", 350, 460, 80, 100, 1, 0.02, 200}, + {"PEEK-CF", 380, 410, 80, 100, 1, 0.02, 200}, + {"PEEK-GF", 375, 410, 80, 100, 1, 0.02, 200}, + {"PEKK", 325, 400, 80, 100, 1, 0.02, 200}, + {"PEKK-CF", 360, 400, 80, 100, 1, 0.02, 200}, + {"PES", 340, 390, 80, 100, 1, 0.02, 200}, + {"PET", 200, 290, 0, 55, 2, 0.3 , 100}, + {"PET-CF", 240, 320, 0, 55, 2, 0.3 , 100}, + {"PET-GF", 280, 320, 0, 55, 2, 0.3 , 100}, + {"PETG", 190, 260, 0, 55, 2, 0.3 , 100}, + {"PETG-CF", 230, 290, 0, 55, 1, 0.3 , 100}, + {"PETG-GF", 210, 270, 0, 55, 1, 0.3 , 100}, + {"PHA", 190, 250, 0, 55, 1, 0.02, 200}, + {"PI", 390, 410, 90, 100, 1, 0.02, 200}, + {"PLA", 180, 240, 0, 45, 1, 0.02, 200}, + {"PLA-AERO", 220, 270, 0, 55, 1, 0.02, 200}, + {"PLA-CF", 190, 250, 0, 50, 1, 0.02, 200}, + {"POM", 210, 250, 50, 65, 1, 0.02, 200}, + {"PP", 200, 240, 45, 60, 1, 0.02, 200}, + {"PP-CF", 210, 250, 45, 60, 1, 0.02, 200}, + {"PP-GF", 220, 260, 45, 60, 1, 0.02, 200}, + {"PPA-CF", 260, 300, 55, 70, 1, 0.02, 200}, + {"PPA-GF", 260, 290, 55, 70, 1, 0.02, 200}, + {"PPS", 300, 345, 90, 100, 1, 0.02, 200}, + {"PPS-CF", 295, 350, 90, 100, 1, 0.02, 200}, + {"PPSU", 360, 420, 90, 100, 1, 0.02, 200}, + {"PSU", 350, 380, 90, 100, 1, 0.02, 200}, + {"PVA", 185, 250, 0, 60, 1, 0.02, 200}, + {"PVB", 190, 250, 0, 55, 1, 0.02, 200}, + {"PVDF", 245, 265, 40, 60, 1, 0.02, 200}, + {"SBS", 195, 250, 0, 55, 1, 0.02, 200}, + {"TPI", 420, 445, 90, 100, 1, 0.02, 200}, + {"TPU", 175, 260, 0, 50, 0.5, 0.02, 1000} + }; + + return material_types; +} + +const MaterialTypeInfo* MaterialType::find(const std::string& name) +{ + const auto& types = all(); + const auto it = std::find_if(types.begin(), types.end(), [&name](const MaterialTypeInfo& info) { return info.name == name; }); + return it != types.end() ? &(*it) : nullptr; +} + +bool MaterialType::get_temperature_range(const std::string& type, int& min_temp, int& max_temp) +{ + min_temp = DEFAULT_MIN_TEMP; + max_temp = DEFAULT_MAX_TEMP; + + if (const auto* info = find(type)) { + min_temp = info->min_temp; + max_temp = info->max_temp; + return true; + } + + return false; +} + +bool MaterialType::get_chamber_temperature_range(const std::string& type, int& chamber_min_temp, int& chamber_max_temp) +{ + chamber_min_temp = DEFAULT_CHAMBER_MIN_TEMP; + chamber_max_temp = DEFAULT_CHAMBER_MAX_TEMP; + + if (const auto* info = find(type)) { + chamber_min_temp = info->chamber_min_temp; + chamber_max_temp = info->chamber_max_temp; + return true; + } + + return false; +} + +bool MaterialType::get_adhesion_coefficient(const std::string& type, double& adhesion_coefficient) +{ + adhesion_coefficient = DEFAULT_ADHESION_COEFFICIENT; + + if (const auto* info = find(type)) { + adhesion_coefficient = info->adhesion_coefficient; + return true; + } + + return false; +} + +bool MaterialType::get_yield_strength(const std::string& type, double& yield_strength) +{ + yield_strength = DEFAULT_YIELD_STRENGTH; + + if (const auto* info = find(type)) { + yield_strength = info->yield_strength; + return true; + } + + return false; +} + +bool MaterialType::get_thermal_length(const std::string& type, double& thermal_length) +{ + thermal_length = DEFAULT_THERMAL_LENGTH; + + if (const auto* info = find(type)) { + thermal_length = info->thermal_length; + return true; + } + + return false; +} + +} // namespace Slic3r diff --git a/src/libslic3r/MaterialType.hpp b/src/libslic3r/MaterialType.hpp new file mode 100644 index 0000000000..8b06d80c07 --- /dev/null +++ b/src/libslic3r/MaterialType.hpp @@ -0,0 +1,32 @@ +#pragma once + +#include +#include + +namespace Slic3r { + +struct MaterialTypeInfo { + std::string name; + int min_temp; + int max_temp; + int chamber_min_temp; + int chamber_max_temp; + double adhesion_coefficient; + double yield_strength; + double thermal_length; +}; + +class MaterialType { +public: + static const std::vector& all(); + + static const MaterialTypeInfo* find(const std::string& name); + + static bool get_temperature_range(const std::string& type, int& min_temp, int& max_temp); + static bool get_chamber_temperature_range(const std::string& type, int& chamber_min_temp, int& chamber_max_temp); + static bool get_adhesion_coefficient(const std::string& type, double& adhesion_coefficient); + static bool get_yield_strength(const std::string& type, double& yield_strength); + static bool get_thermal_length(const std::string& type, double& thermal_length); +}; + +} // namespace Slic3r diff --git a/src/libslic3r/Model.cpp b/src/libslic3r/Model.cpp index 4edec076af..ba8350f065 100644 --- a/src/libslic3r/Model.cpp +++ b/src/libslic3r/Model.cpp @@ -9,6 +9,7 @@ #include "MTUtils.hpp" #include "TriangleMeshSlicer.hpp" #include "TriangleSelector.hpp" +#include "MaterialType.hpp" #include "Format/AMF.hpp" #include "Format/svg.hpp" @@ -3138,18 +3139,10 @@ double Model::getThermalLength(const ModelVolume* modelVolumePtr) { double thermalLength = 200.; auto aa = modelVolumePtr->extruder_id(); if (Model::extruderParamsMap.find(aa) != Model::extruderParamsMap.end()) { - if (Model::extruderParamsMap.at(aa).materialName == "ABS" || - Model::extruderParamsMap.at(aa).materialName == "PA-CF" || - Model::extruderParamsMap.at(aa).materialName == "PET-CF") { - thermalLength = 100; + double thermal_length = 200.0; + if (MaterialType::get_thermal_length(Model::extruderParamsMap.at(aa).materialName, thermal_length)) { + return thermal_length; } - if (Model::extruderParamsMap.at(aa).materialName == "PC") { - thermalLength = 40; - } - if (Model::extruderParamsMap.at(aa).materialName == "TPU") { - thermalLength = 1000; - } - } return thermalLength; } @@ -3212,16 +3205,10 @@ void ModelInstance::invalidate_convex_hull_2d() //BBS adhesion coefficients from model object class double getadhesionCoeff(const ModelVolumePtrs objectVolumes) { - double adhesionCoeff = 1; + double adhesionCoeff = 1.0; for (const ModelVolume* modelVolume : objectVolumes) { if (Model::extruderParamsMap.find(modelVolume->extruder_id()) != Model::extruderParamsMap.end()) { - if (Model::extruderParamsMap.at(modelVolume->extruder_id()).materialName == "PETG" || - Model::extruderParamsMap.at(modelVolume->extruder_id()).materialName == "PCTG") { - adhesionCoeff = 2; - } - else if (Model::extruderParamsMap.at(modelVolume->extruder_id()).materialName == "TPU") { - adhesionCoeff = 0.5; - } + MaterialType::get_adhesion_coefficient(Model::extruderParamsMap.at(modelVolume->extruder_id()).materialName, adhesionCoeff); } } return adhesionCoeff; diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index d229ea866c..7fa9c78ba2 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -16,6 +16,7 @@ #include "GCode/WipeTower2.hpp" #include "Utils.hpp" #include "PrintConfig.hpp" +#include "MaterialType.hpp" #include "Model.hpp" #include "format.hpp" #include @@ -56,6 +57,13 @@ PrintRegion::PrintRegion(PrintRegionConfig &&config) : PrintRegion(std::move(con // ORCA: Now this is a parameter //float Print::min_skirt_length = 0; +struct FilamentType { + std::string name; + int min_temp; + int max_temp; + std::string temp_type; +}; + void Print::clear() { std::scoped_lock lock(this->state_mutex()); @@ -2512,6 +2520,14 @@ Vec2d Print::translate_to_print_space(const Point &point) const { FilamentTempType Print::get_filament_temp_type(const std::string& filament_type) { + // FilamentTempType Temperature-based logic + int min_temp, max_temp; + if (MaterialType::get_temperature_range(filament_type, min_temp, max_temp)) { + if (max_temp <= 250) return FilamentTempType::LowTemp; + else if (max_temp < 280) return FilamentTempType::HighLowCompatible; + else return FilamentTempType::HighTemp; + } + const static std::string HighTempFilamentStr = "high_temp_filament"; const static std::string LowTempFilamentStr = "low_temp_filament"; const static std::string HighLowCompatibleFilamentStr = "high_low_compatible_filament"; diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index dfd62ec223..5f74991526 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -1,6 +1,7 @@ #include "PrintConfig.hpp" #include "ClipperUtils.hpp" #include "Config.hpp" +#include "MaterialType.hpp" #include "I18N.hpp" #include "format.hpp" @@ -53,6 +54,9 @@ namespace Slic3r { #define L(s) (s) #define _(s) Slic3r::I18N::translate(s) +// Filament types are defined in MaterialType. + + static t_config_enum_names enum_names_from_keys_map(const t_config_enum_values &enum_keys_map) { t_config_enum_names names; @@ -2261,45 +2265,11 @@ void PrintConfigDef::init_fff_params() def->gui_type = ConfigOptionDef::GUIType::f_enum_open; def->gui_flags = "show_value"; - def->enum_values.push_back("ABS"); - def->enum_values.push_back("ABS-GF"); - def->enum_values.push_back("ASA"); - def->enum_values.push_back("ASA-Aero"); - def->enum_values.push_back("BVOH"); - def->enum_values.push_back("PCTG"); - def->enum_values.push_back("EVA"); - def->enum_values.push_back("FLEX"); - def->enum_values.push_back("HIPS"); - def->enum_values.push_back("PA"); - def->enum_values.push_back("PA-CF"); - def->enum_values.push_back("PA-GF"); - def->enum_values.push_back("PA6-CF"); - def->enum_values.push_back("PA11-CF"); - def->enum_values.push_back("PC"); - def->enum_values.push_back("PC-CF"); - def->enum_values.push_back("PCTG"); - def->enum_values.push_back("PE"); - def->enum_values.push_back("PE-CF"); - def->enum_values.push_back("PET-CF"); - def->enum_values.push_back("PETG"); - def->enum_values.push_back("PETG-CF"); - def->enum_values.push_back("PETG-CF10"); - def->enum_values.push_back("PETG-GF"); - def->enum_values.push_back("PHA"); - def->enum_values.push_back("PLA"); - def->enum_values.push_back("PLA-AERO"); - def->enum_values.push_back("PLA-CF"); - def->enum_values.push_back("PP"); - def->enum_values.push_back("PP-CF"); - def->enum_values.push_back("PP-GF"); - def->enum_values.push_back("PPA-CF"); - def->enum_values.push_back("PPA-GF"); - def->enum_values.push_back("PPS"); - def->enum_values.push_back("PPS-CF"); - def->enum_values.push_back("PVA"); - def->enum_values.push_back("PVB"); - def->enum_values.push_back("SBS"); - def->enum_values.push_back("TPU"); + // Populate the enum values using the shared material type database + for (const auto& filament : MaterialType::all()) { + def->enum_values.push_back(filament.name); + } + def->mode = comSimple; def->set_default_value(new ConfigOptionStrings { "PLA" }); diff --git a/src/libslic3r/Support/SupportSpotsGenerator.hpp b/src/libslic3r/Support/SupportSpotsGenerator.hpp index 73a3419067..48f07d52aa 100644 --- a/src/libslic3r/Support/SupportSpotsGenerator.hpp +++ b/src/libslic3r/Support/SupportSpotsGenerator.hpp @@ -5,6 +5,7 @@ #include "Line.hpp" #include "PrintBase.hpp" #include "PrintConfig.hpp" +#include "MaterialType.hpp" #include #include #include @@ -64,15 +65,9 @@ struct Params return get_support_spots_adhesion_strength() * 2.0; } - if (filament_type == "PLA") { - return 0.02 * 1e6; - } else if (filament_type == "PET" || filament_type == "PETG") { - return 0.3 * 1e6; - } else if (filament_type == "ABS" || filament_type == "ASA") { - return 0.1 * 1e6; //TODO do measurements - } else { //PLA default value - defensive approach, PLA has quite low adhesion - return 0.02 * 1e6; - } + double yield_strength = 0.02; + MaterialType::get_yield_strength(filament_type, yield_strength); + return yield_strength * 1e6; } double get_support_spots_adhesion_strength() const { diff --git a/src/slic3r/GUI/ConfigManipulation.cpp b/src/slic3r/GUI/ConfigManipulation.cpp index 367cd9d26a..a8e4e37ac2 100644 --- a/src/slic3r/GUI/ConfigManipulation.cpp +++ b/src/slic3r/GUI/ConfigManipulation.cpp @@ -6,6 +6,7 @@ #include "libslic3r/Config.hpp" #include "libslic3r/Model.hpp" #include "libslic3r/PresetBundle.hpp" +#include "libslic3r/MaterialType.hpp" #include "MsgDialog.hpp" #include "libslic3r/PrintConfig.hpp" @@ -59,10 +60,29 @@ void ConfigManipulation::check_nozzle_recommended_temperature_range(DynamicPrint int temperature_range_low, temperature_range_high; if (!get_temperature_range(config, temperature_range_low, temperature_range_high)) return; + // Get the selected filament type + std::string filament_type = ""; + if (config->has("filament_type") && config->option("filament_type")->values.size() > 0) { + filament_type = config->option("filament_type")->values[0]; + } + + int min_recommended_temp = 190; + int max_recommended_temp = 300; + + if (!MaterialType::get_temperature_range(filament_type, min_recommended_temp, max_recommended_temp)){ + filament_type = "Unknown"; + } + wxString msg_text; bool need_check = false; - if (temperature_range_low < 190 || temperature_range_high > 300) { - msg_text += _L("The recommended minimum temperature is less than 190°C or the recommended maximum temperature is greater than 300°C.\n"); + if (temperature_range_low < min_recommended_temp) { + msg_text += wxString::Format(_L("A minimum temperature above %d\u2103 is recommended for %s.\n"), + min_recommended_temp, filament_type); + need_check = true; + } + if (temperature_range_high > max_recommended_temp) { + msg_text += wxString::Format(_L("A maximum temperature below %d\u2103 is recommended for %s.\n"), + max_recommended_temp, filament_type); need_check = true; } if (temperature_range_low > temperature_range_high) { @@ -145,23 +165,14 @@ void ConfigManipulation::check_filament_max_volumetric_speed(DynamicPrintConfig void ConfigManipulation::check_chamber_temperature(DynamicPrintConfig* config) { - const static std::maprecommend_temp_map = { - {"PLA",45}, - {"PLA-CF",45}, - {"PVA",45}, - {"TPU",50}, - {"PETG",55}, - {"PCTG",55}, - {"PETG-CF",55} - }; bool support_chamber_temp_control=GUI::wxGetApp().preset_bundle->printers.get_selected_preset().config.opt_bool("support_chamber_temp_control"); if (support_chamber_temp_control&&config->has("chamber_temperatures")) { std::string filament_type = config->option("filament_type")->get_at(0); - auto iter = recommend_temp_map.find(filament_type); - if (iter!=recommend_temp_map.end()) { - if (iter->second < config->option("chamber_temperatures")->get_at(0)) { + int chamber_min_temp, chamber_max_temp; + if (MaterialType::get_chamber_temperature_range(filament_type, chamber_min_temp, chamber_max_temp)) { + if (chamber_max_temp < config->option("chamber_temperatures")->get_at(0)) { wxString msg_text = wxString::Format(_L("Current chamber temperature is higher than the material's safe temperature, this may result in material softening and clogging. " - "The maximum safe temperature for the material is %d"), iter->second); + "The maximum safe temperature for the material is %d"), chamber_max_temp); MessageDialog dialog(m_msg_dlg_parent, msg_text, "", wxICON_WARNING | wxOK); is_msg_dlg_already_exist = true; dialog.ShowModal();