diff --git a/src/libslic3r/PresetBundle.cpp b/src/libslic3r/PresetBundle.cpp index 6bdb62176..11c1a98fd 100644 --- a/src/libslic3r/PresetBundle.cpp +++ b/src/libslic3r/PresetBundle.cpp @@ -2279,6 +2279,7 @@ DynamicPrintConfig PresetBundle::full_fff_config(bool apply_extruder, std::vecto //BBS: add logic for settings check between different system presets add_if_some_non_empty(std::move(different_settings), "different_settings_to_system"); add_if_some_non_empty(std::move(print_compatible_printers), "print_compatible_printers"); + out.option("extruder_filament_count", true)->values = this->extruder_filament_counts; out.option("printer_technology", true)->value = ptFFF; return out; @@ -2496,6 +2497,11 @@ void PresetBundle::load_config_file_config(const std::string &name_or_path, bool } } } + //no need to parse extruder_filament_count + std::vector extruder_filament_count = std::move(config.option("extruder_filament_count", true)->values); + config.erase("extruder_filament_count"); + if (this->extruder_filament_counts.empty()) + this->extruder_filament_counts = extruder_filament_count; // 1) Create a name from the file name. // Keep the suffix (.ini, .gcode, .amf, .3mf etc) to differentiate it from the normal profiles. diff --git a/src/libslic3r/PresetBundle.hpp b/src/libslic3r/PresetBundle.hpp index 69a619177..1deb267c8 100644 --- a/src/libslic3r/PresetBundle.hpp +++ b/src/libslic3r/PresetBundle.hpp @@ -127,7 +127,7 @@ public: std::vector> ams_multi_color_filment; // todo multi_extruders: delete mutable - mutable std::vector filament_maps; + mutable std::vector extruder_filament_counts; // Calibrate Preset const * calibrate_printer = nullptr; std::set calibrate_filaments; diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index bd07a4b48..3ee054cbe 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -244,6 +244,9 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n || opt_key == "first_layer_print_sequence" || opt_key == "other_layers_print_sequence" || opt_key == "other_layers_print_sequence_nums" + || opt_key == "extruder_filament_count" + || opt_key == "filament_map_mode" + || opt_key == "filament_map" //|| opt_key == "wipe_tower_bridging" || opt_key == "wipe_tower_no_sparse_layers" || opt_key == "flush_volumes_matrix" @@ -2306,6 +2309,19 @@ void Print::finalize_first_layer_convex_hull() m_first_layer_convex_hull = Geometry::convex_hull(m_first_layer_convex_hull.points); } +void Print::update_filament_maps_to_config(std::vector f_maps) +{ + std::vector& filament_maps = m_full_print_config.option("filament_map", true)->values; + + filament_maps = f_maps; + m_config.filament_map.values = f_maps; +} + +std::vector Print::get_filament_maps() const +{ + return m_config.filament_map.values; +} + // Wipe tower support. bool Print::has_wipe_tower() const { @@ -2476,35 +2492,35 @@ void Print::_make_wipe_tower() } else { std::vector flush_matrix(cast(get_flush_volumes_matrix(m_config.flush_volumes_matrix.values, 0, nozzle_nums))); - + // Extract purging volumes for each extruder pair: std::vector> wipe_volumes; for (unsigned int i = 0; i < number_of_extruders; ++i) wipe_volumes.push_back(std::vector(flush_matrix.begin() + i * number_of_extruders, flush_matrix.begin() + (i + 1) * number_of_extruders)); - - + + // BBS: priming logic is removed, so get the initial extruder by first_extruder() unsigned int current_extruder_id = m_wipe_tower_data.tool_ordering.first_extruder(); for (auto &layer_tools : m_wipe_tower_data.tool_ordering.layer_tools()) { // for all layers if (!layer_tools.has_wipe_tower) continue; bool first_layer = &layer_tools == &m_wipe_tower_data.tool_ordering.front(); wipe_tower.plan_toolchange((float)layer_tools.print_z, (float)layer_tools.wipe_tower_layer_height, current_extruder_id, current_extruder_id); - + for (const auto extruder_id : layer_tools.extruders) { // BBS: priming logic is removed, so no need to do toolchange for first extruder if (/*(first_layer && extruder_id == m_wipe_tower_data.tool_ordering.all_extruders().back()) || */extruder_id != current_extruder_id) { float volume_to_purge = wipe_volumes[current_extruder_id][extruder_id]; volume_to_purge *= m_config.flush_multiplier.get_at(0); - + // Not all of that can be used for infill purging: //volume_to_purge -= (float)m_config.filament_minimal_purge_on_wipe_tower.get_at(extruder_id); - + // try to assign some infills/objects for the wiping: volume_to_purge = layer_tools.wiping_extrusions().mark_wiping_extrusions(*this, current_extruder_id, extruder_id, volume_to_purge); - + // add back the minimal amount toforce on the wipe tower: //volume_to_purge += (float)m_config.filament_minimal_purge_on_wipe_tower.get_at(extruder_id); - + // request a toolchange at the wipe tower with at least volume_to_wipe purging amount wipe_tower.plan_toolchange((float)layer_tools.print_z, (float)layer_tools.wipe_tower_layer_height, current_extruder_id, extruder_id, m_config.prime_volume, volume_to_purge); @@ -2512,14 +2528,14 @@ void Print::_make_wipe_tower() } } layer_tools.wiping_extrusions().ensure_perimeters_infills_order(*this); - + // if enable timelapse, slice all layer if (enable_timelapse_print()) { if (layer_tools.wipe_tower_partitions == 0) wipe_tower.set_last_layer_extruder_fill(false); continue; } - + if (&layer_tools == &m_wipe_tower_data.tool_ordering.back() || (&layer_tools + 1)->wipe_tower_partitions == 0) break; } diff --git a/src/libslic3r/Print.hpp b/src/libslic3r/Print.hpp index a28a8aa13..997e74b82 100644 --- a/src/libslic3r/Print.hpp +++ b/src/libslic3r/Print.hpp @@ -805,6 +805,9 @@ public: const WipeTowerData& wipe_tower_data(size_t filaments_cnt = 0) const; const ToolOrdering& tool_ordering() const { return m_tool_ordering; } + void update_filament_maps_to_config(std::vector f_maps); + std::vector get_filament_maps() const; + bool enable_timelapse_print() const; std::string output_filename(const std::string &filename_base = std::string()) const override; diff --git a/src/libslic3r/PrintApply.cpp b/src/libslic3r/PrintApply.cpp index 3538c6b8d..fdef6d049 100644 --- a/src/libslic3r/PrintApply.cpp +++ b/src/libslic3r/PrintApply.cpp @@ -1028,12 +1028,14 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_ new_full_config.option("print_settings_id", true); new_full_config.option("filament_settings_id", true); new_full_config.option("printer_settings_id", true); + // BBS - int used_filaments = this->extruders(true).size(); + std::vector used_filaments = this->extruders(true); + std::unordered_set used_filament_set(used_filaments.begin(), used_filaments.end()); //new_full_config.normalize_fdm(used_filaments); new_full_config.normalize_fdm_1(); - t_config_option_keys changed_keys = new_full_config.normalize_fdm_2(objects().size(), used_filaments); + t_config_option_keys changed_keys = new_full_config.normalize_fdm_2(objects().size(), used_filaments.size()); if (changed_keys.size() > 0) { BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", got changed_keys, size=%1%")%changed_keys.size(); for (int i = 0; i < changed_keys.size(); i++) @@ -1114,6 +1116,40 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_ t_config_option_keys object_diff = m_default_object_config.diff(new_full_config); t_config_option_keys region_diff = m_default_region_config.diff(new_full_config); + //BBS: process the filament_map related logic + std::unordered_set print_diff_set(print_diff.begin(), print_diff.end()); + if (print_diff_set.find("filament_map_mode") == print_diff_set.end()) + { + FilamentMapMode map_mode = new_full_config.option>("filament_map_mode", true)->value; + if (map_mode == fmmAuto) { + print_diff_set.erase("filament_map"); + } + else { + print_diff_set.erase("extruder_filament_count"); + std::vector old_filament_map = m_config.filament_map.values; + std::vector new_filament_map = new_full_config.option("filament_map", true)->values; + + if (old_filament_map.size() == new_filament_map.size()) + { + bool same_map = true; + for (size_t index = 0; index < old_filament_map.size(); index++) + { + if ((old_filament_map[index] == new_filament_map[index]) + || (used_filament_set.find(index + 1) == used_filament_set.end())) + continue; + else { + same_map = false; + break; + } + } + if (same_map) + print_diff_set.erase("filament_map"); + } + } + if (print_diff_set.size() != print_diff.size()) + print_diff.assign(print_diff_set.begin(), print_diff_set.end()); + } + // Do not use the ApplyStatus as we will use the max function when updating apply_status. unsigned int apply_status = APPLY_STATUS_UNCHANGED; auto update_apply_status = [&apply_status](bool invalidated) diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 01bb1fd5c..d29dd7ad8 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -3019,6 +3019,12 @@ void PrintConfigDef::init_fff_params() def->set_default_value(new ConfigOptionStrings { "Direct Drive Normal" }); def->cli = ConfigOptionDef::nocli; + def = this->add("extruder_filament_count", coInts); + def->label = "Extruder filament count"; + def->tooltip = "Filament counts per extruder"; + def->set_default_value(new ConfigOptionInts { 1 }); + def->cli = ConfigOptionDef::nocli; + def = this->add("printer_extruder_id", coInts); def->label = "Printer extruder id"; def->tooltip = "Printer extruder id"; diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index 781bd8031..c60a4c6af 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -969,6 +969,7 @@ PRINT_CONFIG_CLASS_DEFINE( ((ConfigOptionInts, temperature_vitrification)) //BBS ((ConfigOptionFloats, filament_max_volumetric_speed)) ((ConfigOptionInts, required_nozzle_HRC)) + ((ConfigOptionEnum, filament_map_mode)) ((ConfigOptionInts, filament_map)) //((ConfigOptionInts, filament_extruder_id)) ((ConfigOptionStrings, filament_extruder_variant)) @@ -1024,6 +1025,7 @@ PRINT_CONFIG_CLASS_DEFINE( ((ConfigOptionPercent, accel_to_decel_factor)) ((ConfigOptionEnumsGeneric, extruder_type)) ((ConfigOptionEnumsGeneric, nozzle_volume_type)) + ((ConfigOptionInts, extruder_filament_count)) ((ConfigOptionInts, printer_extruder_id)) ((ConfigOptionStrings, printer_extruder_variant)) //Orca