FIX: unassigned initial extruder ignored
jira:NEW Signed-off-by: xun.zhang <xun.zhang@bambulab.com> Change-Id: I97dbfac705c890d1c2b16c2b685f31d05e82a292 (cherry picked from commit a5a2909c795c6c99ff7d6c6bbe5741491a2b63e0)
This commit is contained in:
parent
46da98c432
commit
4cf4e640ce
|
@ -25,14 +25,20 @@ const static bool g_wipe_into_objects = false;
|
||||||
|
|
||||||
|
|
||||||
// Shortest hamilton path problem
|
// Shortest hamilton path problem
|
||||||
static std::vector<unsigned int> solve_extruder_order(const std::vector<std::vector<float>>& wipe_volumes, std::vector<unsigned int> all_extruders, unsigned int start_extruder_id)
|
static std::vector<unsigned int> solve_extruder_order(const std::vector<std::vector<float>>& wipe_volumes, std::vector<unsigned int> all_extruders, std::optional<unsigned int> start_extruder_id)
|
||||||
{
|
{
|
||||||
auto start_iter = std::find(all_extruders.begin(), all_extruders.end(), start_extruder_id);
|
|
||||||
bool add_start_extruder_flag = false;
|
bool add_start_extruder_flag = false;
|
||||||
|
|
||||||
|
if (start_extruder_id) {
|
||||||
|
auto start_iter = std::find(all_extruders.begin(), all_extruders.end(), start_extruder_id);
|
||||||
if (start_iter == all_extruders.end())
|
if (start_iter == all_extruders.end())
|
||||||
all_extruders.insert(all_extruders.begin(), start_extruder_id), add_start_extruder_flag = true;
|
all_extruders.insert(all_extruders.begin(), *start_extruder_id), add_start_extruder_flag = true;
|
||||||
else
|
else
|
||||||
std::swap(*all_extruders.begin(), *start_iter);
|
std::swap(*all_extruders.begin(), *start_iter);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
*start_extruder_id = all_extruders.front();
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int iterations = (1 << all_extruders.size());
|
unsigned int iterations = (1 << all_extruders.size());
|
||||||
unsigned int final_state = iterations - 1;
|
unsigned int final_state = iterations - 1;
|
||||||
|
@ -84,7 +90,7 @@ static std::vector<unsigned int> solve_extruder_order(const std::vector<std::vec
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<unsigned int> get_extruders_order(const std::vector<std::vector<float>> &wipe_volumes, std::vector<unsigned int> all_extruders, unsigned int start_extruder_id)
|
std::vector<unsigned int> get_extruders_order(const std::vector<std::vector<float>> &wipe_volumes, std::vector<unsigned int> all_extruders, std::optional<unsigned int>start_extruder_id)
|
||||||
{
|
{
|
||||||
#define USE_DP_OPTIMIZE
|
#define USE_DP_OPTIMIZE
|
||||||
#ifdef 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)
|
for (unsigned int i = 0; i < number_of_extruders; ++i)
|
||||||
wipe_volumes.push_back(std::vector<float>(flush_matrix.begin() + i * number_of_extruders, flush_matrix.begin() + (i + 1) * number_of_extruders));
|
wipe_volumes.push_back(std::vector<float>(flush_matrix.begin() + i * number_of_extruders, flush_matrix.begin() + (i + 1) * number_of_extruders));
|
||||||
|
|
||||||
auto extruders_to_hash_key = [](const std::vector<unsigned int>& extruders, unsigned int initial_extruder_id)->uint32_t {
|
auto extruders_to_hash_key = [](const std::vector<unsigned int>& extruders, std::optional<unsigned int>initial_extruder_id)->uint32_t {
|
||||||
uint32_t hash_key = 0;
|
uint32_t hash_key = 0;
|
||||||
// high 16 bit define initial extruder ,low 16 bit define extruder set
|
// 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)
|
for (auto item : extruders)
|
||||||
hash_key |= (1 << item);
|
hash_key |= (1 << item);
|
||||||
return hash_key;
|
return hash_key;
|
||||||
|
@ -853,7 +860,7 @@ void ToolOrdering::reorder_extruders_for_minimum_flush_volume()
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
unsigned int current_extruder_id = -1;
|
std::optional<unsigned int>current_extruder_id;
|
||||||
for (int i = 0; i < m_layer_tools.size(); ++i) {
|
for (int i = 0; i < m_layer_tools.size(); ++i) {
|
||||||
LayerTools& lt = m_layer_tools[i];
|
LayerTools& lt = m_layer_tools[i];
|
||||||
if (lt.extruders.empty())
|
if (lt.extruders.empty())
|
||||||
|
|
|
@ -83,7 +83,7 @@ fontinfo_opt load_font_info(const unsigned char *data, unsigned int index)
|
||||||
stbtt_fontinfo font_info;
|
stbtt_fontinfo font_info;
|
||||||
if (stbtt_InitFont(&font_info, data, font_offset) == 0) {
|
if (stbtt_InitFont(&font_info, data, font_offset) == 0) {
|
||||||
// Can't initialize font.
|
// Can't initialize font.
|
||||||
assert(false);
|
//assert(false);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
return font_info;
|
return font_info;
|
||||||
|
|
Loading…
Reference in New Issue