mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-07-24 19:32:18 +00:00
ENH: add manual grouping mode stats
1.In auto mode,display the statistics of auto mode and single extruder 2.In manual mode,display the statistics of manual mode and auto mode 3.Support by object mode jira:NONE Signed-off-by: xun.zhang <xun.zhang@bambulab.com> Change-Id: If54c4db79f33d5278c0f18d01ab0518e8660f9c7 (cherry picked from commit 2dbc5c939666e294c805ee4bf33ec09976688be3)
This commit is contained in:
@@ -464,10 +464,10 @@ static double calc_max_layer_height(const PrintConfig &config, double max_object
|
||||
}
|
||||
|
||||
//calculate the flush weight (first value) and filament change count(second value)
|
||||
static std::pair<int,int> calc_filament_change_info_by_toolorder(const PrintConfig* config,const std::vector<int>&filament_map,const std::vector<FlushMatrix>&flush_matrix,const std::vector<std::vector<unsigned int>>&layer_sequences)
|
||||
static FilamentChangeStats calc_filament_change_info_by_toolorder(const PrintConfig* config,const std::vector<int>&filament_map,const std::vector<FlushMatrix>&flush_matrix,const std::vector<std::vector<unsigned int>>&layer_sequences)
|
||||
{
|
||||
FilamentChangeStats ret;
|
||||
std::map<int, int> flush_volume_per_filament;
|
||||
|
||||
std::vector<unsigned int>last_filament_per_extruder(2, -1);
|
||||
|
||||
int total_filament_change_count = 0;
|
||||
@@ -490,7 +490,10 @@ static std::pair<int,int> calc_filament_change_info_by_toolorder(const PrintConf
|
||||
total_filament_flush_weight += weight;
|
||||
}
|
||||
|
||||
return { total_filament_flush_weight,total_filament_change_count };
|
||||
ret.filament_change_count = total_filament_change_count;
|
||||
ret.filament_flush_weight = total_filament_flush_weight;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -1259,6 +1262,22 @@ std::vector<int> ToolOrdering::get_recommended_filament_maps(const std::vector<s
|
||||
return ret;
|
||||
}
|
||||
|
||||
FilamentChangeStats ToolOrdering::get_filament_change_stats(FilamentChangeMode mode)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case Slic3r::ToolOrdering::SingleExt:
|
||||
return m_stats_by_single_extruder;
|
||||
case Slic3r::ToolOrdering::MultiExtAuto:
|
||||
return m_stats_by_multi_extruder_auto;
|
||||
case Slic3r::ToolOrdering::MultiExtManual:
|
||||
return m_stats_by_multi_extruder_manual;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return m_stats_by_single_extruder;
|
||||
}
|
||||
|
||||
void ToolOrdering::reorder_extruders_for_minimum_flush_volume(bool reorder_first_layer)
|
||||
{
|
||||
const PrintConfig* print_config = m_print_config_ptr;
|
||||
@@ -1289,9 +1308,11 @@ void ToolOrdering::reorder_extruders_for_minimum_flush_volume(bool reorder_first
|
||||
}
|
||||
|
||||
std::vector<int>filament_maps(number_of_extruders, 0);
|
||||
FilamentMapMode map_mode = FilamentMapMode::fmmAuto;
|
||||
if (nozzle_nums > 1) {
|
||||
filament_maps = m_print->get_filament_maps();
|
||||
if (m_print->get_filament_map_mode() == FilamentMapMode::fmmAuto
|
||||
map_mode = m_print->get_filament_map_mode();
|
||||
if (map_mode == FilamentMapMode::fmmAuto
|
||||
&& (print_config->print_sequence != PrintSequence::ByObject || m_print->objects().size() == 1)) {
|
||||
const PrintConfig* print_config = m_print_config_ptr;
|
||||
if (!print_config && m_print_object_ptr) {
|
||||
@@ -1361,23 +1382,46 @@ void ToolOrdering::reorder_extruders_for_minimum_flush_volume(bool reorder_first
|
||||
);
|
||||
|
||||
auto curr_flush_info = calc_filament_change_info_by_toolorder(print_config, filament_maps, nozzle_flush_mtx, filament_sequences);
|
||||
m_curr_flush_info = curr_flush_info;
|
||||
if (nozzle_nums <= 1)
|
||||
m_stats_by_single_extruder = curr_flush_info;
|
||||
else if (map_mode == fmmAuto)
|
||||
m_stats_by_multi_extruder_auto = curr_flush_info;
|
||||
else if (map_mode == fmmManual)
|
||||
m_stats_by_multi_extruder_manual = curr_flush_info;
|
||||
|
||||
// in multi extruder mode
|
||||
if (nozzle_nums > 1) {
|
||||
std::vector<std::vector<unsigned int>>filament_sequences_one_extruder;
|
||||
auto maps_without_group = filament_maps;
|
||||
for (auto& item : maps_without_group)
|
||||
item = 0;
|
||||
reorder_filaments_for_minimum_flush_volume(
|
||||
filament_lists,
|
||||
maps_without_group,
|
||||
layer_filaments,
|
||||
nozzle_flush_mtx,
|
||||
get_custom_seq,
|
||||
&filament_sequences_one_extruder
|
||||
// always calculate the info by one extruder
|
||||
{
|
||||
std::vector<std::vector<unsigned int>>filament_sequences_one_extruder;
|
||||
auto maps_without_group = filament_maps;
|
||||
for (auto& item : maps_without_group)
|
||||
item = 0;
|
||||
reorder_filaments_for_minimum_flush_volume(
|
||||
filament_lists,
|
||||
maps_without_group,
|
||||
layer_filaments,
|
||||
nozzle_flush_mtx,
|
||||
get_custom_seq,
|
||||
&filament_sequences_one_extruder
|
||||
);
|
||||
auto one_extruder_flush_info = calc_filament_change_info_by_toolorder(print_config, maps_without_group, nozzle_flush_mtx, filament_sequences_one_extruder);
|
||||
m_one_extruder_flush_info = one_extruder_flush_info;
|
||||
m_stats_by_single_extruder = calc_filament_change_info_by_toolorder(print_config, maps_without_group, nozzle_flush_mtx, filament_sequences_one_extruder);
|
||||
}
|
||||
// if in manual mode,also calculate the info by auto mode
|
||||
if (map_mode == fmmManual)
|
||||
{
|
||||
std::vector<std::vector<unsigned int>>filament_sequences_one_extruder;
|
||||
std::vector<int>filament_maps_auto = get_recommended_filament_maps(layer_filaments, print_config);
|
||||
reorder_filaments_for_minimum_flush_volume(
|
||||
filament_lists,
|
||||
filament_maps_auto,
|
||||
layer_filaments,
|
||||
nozzle_flush_mtx,
|
||||
get_custom_seq,
|
||||
&filament_sequences_one_extruder
|
||||
);
|
||||
m_stats_by_multi_extruder_auto = calc_filament_change_info_by_toolorder(print_config, filament_maps_auto, nozzle_flush_mtx, filament_sequences_one_extruder);
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < filament_sequences.size(); ++i)
|
||||
|
||||
@@ -101,6 +101,37 @@ private:
|
||||
const LayerTools* m_layer_tools = nullptr; // so we know which LayerTools object this belongs to
|
||||
};
|
||||
|
||||
|
||||
struct FilamentChangeStats
|
||||
{
|
||||
int filament_flush_weight{0};
|
||||
int filament_change_count{0};
|
||||
int extruder_change_count{0};
|
||||
|
||||
void clear(){
|
||||
filament_flush_weight = 0;
|
||||
filament_change_count = 0;
|
||||
extruder_change_count = 0;
|
||||
}
|
||||
|
||||
FilamentChangeStats& operator+=(const FilamentChangeStats& other) {
|
||||
this->filament_flush_weight += other.filament_flush_weight;
|
||||
this->filament_change_count += other.filament_change_count;
|
||||
this->extruder_change_count += other.extruder_change_count;
|
||||
return *this;
|
||||
}
|
||||
|
||||
FilamentChangeStats operator+(const FilamentChangeStats& other){
|
||||
FilamentChangeStats ret;
|
||||
ret.filament_flush_weight = this->filament_flush_weight + other.filament_flush_weight;
|
||||
ret.filament_change_count = this->filament_change_count + other.filament_change_count;
|
||||
ret.extruder_change_count = this->extruder_change_count + other.extruder_change_count;
|
||||
return ret;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
class LayerTools
|
||||
{
|
||||
public:
|
||||
@@ -156,9 +187,10 @@ private:
|
||||
class ToolOrdering
|
||||
{
|
||||
public:
|
||||
enum FlushCalcMode {
|
||||
Normal=0,
|
||||
OneExtruder
|
||||
enum FilamentChangeMode {
|
||||
SingleExt,
|
||||
MultiExtAuto,
|
||||
MultiExtManual
|
||||
};
|
||||
ToolOrdering() = default;
|
||||
|
||||
@@ -172,8 +204,9 @@ public:
|
||||
|
||||
void clear() {
|
||||
m_layer_tools.clear();
|
||||
m_curr_flush_info = { 0,0 };
|
||||
m_one_extruder_flush_info = { 0,0 };
|
||||
m_stats_by_single_extruder.clear();
|
||||
m_stats_by_multi_extruder_auto.clear();
|
||||
m_stats_by_multi_extruder_manual.clear();
|
||||
}
|
||||
|
||||
// Only valid for non-sequential print:
|
||||
@@ -205,8 +238,8 @@ public:
|
||||
|
||||
static std::vector<int> get_recommended_filament_maps(const std::vector<std::vector<unsigned int>>& layer_filaments, const PrintConfig *print_config);
|
||||
|
||||
// first val: flush weight second val: change count
|
||||
std::pair<int, int> get_flush_info(int mode) const { return mode == FlushCalcMode::OneExtruder ? m_one_extruder_flush_info : m_curr_flush_info; }
|
||||
// should be called after doing reorder
|
||||
FilamentChangeStats get_filament_change_stats(FilamentChangeMode mode);
|
||||
|
||||
private:
|
||||
void initialize_layers(std::vector<coordf_t> &zs);
|
||||
@@ -236,8 +269,9 @@ private:
|
||||
Print* m_print;
|
||||
bool m_is_BBL_printer = false;
|
||||
|
||||
std::pair<int, int> m_curr_flush_info{ 0,0 };
|
||||
std::pair<int, int> m_one_extruder_flush_info{ 0,0 };
|
||||
FilamentChangeStats m_stats_by_single_extruder;
|
||||
FilamentChangeStats m_stats_by_multi_extruder_manual;
|
||||
FilamentChangeStats m_stats_by_multi_extruder_auto;
|
||||
};
|
||||
|
||||
} // namespace SLic3r
|
||||
|
||||
Reference in New Issue
Block a user