diff --git a/src/libslic3r/GCode/ToolOrdering.cpp b/src/libslic3r/GCode/ToolOrdering.cpp index a5e3cd23f..5230b066b 100644 --- a/src/libslic3r/GCode/ToolOrdering.cpp +++ b/src/libslic3r/GCode/ToolOrdering.cpp @@ -25,14 +25,20 @@ const static bool g_wipe_into_objects = false; // Shortest hamilton path problem -static std::vector solve_extruder_order(const std::vector>& wipe_volumes, std::vector all_extruders, unsigned int start_extruder_id) +static std::vector solve_extruder_order(const std::vector>& wipe_volumes, std::vector all_extruders, std::optional start_extruder_id) { - auto start_iter = std::find(all_extruders.begin(), all_extruders.end(), start_extruder_id); bool add_start_extruder_flag = false; - if (start_iter == all_extruders.end()) - all_extruders.insert(all_extruders.begin(), start_extruder_id), add_start_extruder_flag = true; - else - std::swap(*all_extruders.begin(), *start_iter); + + if (start_extruder_id) { + auto start_iter = std::find(all_extruders.begin(), all_extruders.end(), start_extruder_id); + if (start_iter == all_extruders.end()) + all_extruders.insert(all_extruders.begin(), *start_extruder_id), add_start_extruder_flag = true; + else + std::swap(*all_extruders.begin(), *start_iter); + } + else { + *start_extruder_id = all_extruders.front(); + } unsigned int iterations = (1 << all_extruders.size()); unsigned int final_state = iterations - 1; @@ -84,7 +90,7 @@ static std::vector solve_extruder_order(const std::vector get_extruders_order(const std::vector> &wipe_volumes, std::vector all_extruders, unsigned int start_extruder_id) +std::vector get_extruders_order(const std::vector> &wipe_volumes, std::vector all_extruders, std::optionalstart_extruder_id) { #define USE_DP_OPTIMIZE #ifdef USE_DP_OPTIMIZE @@ -823,10 +829,11 @@ void ToolOrdering::reorder_extruders_for_minimum_flush_volume() 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)); - auto extruders_to_hash_key = [](const std::vector& extruders, unsigned int initial_extruder_id)->uint32_t { + auto extruders_to_hash_key = [](const std::vector& extruders, std::optionalinitial_extruder_id)->uint32_t { uint32_t hash_key = 0; // high 16 bit define initial extruder ,low 16 bit define extruder set - hash_key |= (1 << (16 + initial_extruder_id)); + if (initial_extruder_id) + hash_key |= (1 << (16 + *initial_extruder_id)); for (auto item : extruders) hash_key |= (1 << item); return hash_key; @@ -853,7 +860,7 @@ void ToolOrdering::reorder_extruders_for_minimum_flush_volume() return false; }; - unsigned int current_extruder_id = -1; + std::optionalcurrent_extruder_id; for (int i = 0; i < m_layer_tools.size(); ++i) { LayerTools& lt = m_layer_tools[i]; if (lt.extruders.empty()) diff --git a/src/slic3r/Utils/FontUtils.cpp b/src/slic3r/Utils/FontUtils.cpp index e7bc0c0e7..733038c2c 100644 --- a/src/slic3r/Utils/FontUtils.cpp +++ b/src/slic3r/Utils/FontUtils.cpp @@ -83,7 +83,7 @@ fontinfo_opt load_font_info(const unsigned char *data, unsigned int index) stbtt_fontinfo font_info; if (stbtt_InitFont(&font_info, data, font_offset) == 0) { // Can't initialize font. - assert(false); + //assert(false); return {}; } return font_info;