mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-12-24 16:48:49 -07:00
FIX: display the minimum flush data
1. Use the minimum flush between nozzle volume and flush in datalist 2. Add a new param to decide the datalist to use github:7445 Signed-off-by: xun.zhang <xun.zhang@bambulab.com> Change-Id: Id87c98ca5069e7b328974d641d7a81dfbf9c50a0 (cherry picked from commit 2be29b784727330732170b5c2ff0ba9d5e79d82f)
This commit is contained in:
parent
cf9a38bbc6
commit
bc02e48dc0
13 changed files with 69 additions and 65 deletions
|
|
@ -233,6 +233,12 @@
|
|||
"0.08",
|
||||
"0.08"
|
||||
],
|
||||
"nozzle_flush_dataset": [
|
||||
"1",
|
||||
"2",
|
||||
"1",
|
||||
"2"
|
||||
],
|
||||
"nozzle_type": [
|
||||
"hardened_steel",
|
||||
"hardened_steel",
|
||||
|
|
|
|||
|
|
@ -94,6 +94,9 @@
|
|||
"0.08"
|
||||
],
|
||||
"nozzle_height": "4",
|
||||
"nozzle_flush_dataset": [
|
||||
"0"
|
||||
],
|
||||
"printable_height": "250",
|
||||
"printer_settings_id": "",
|
||||
"printer_structure": "corexy",
|
||||
|
|
|
|||
|
|
@ -3166,19 +3166,8 @@ int CLI::run(int argc, char **argv)
|
|||
std::vector<double>& flush_multipliers = m_print_config.option<ConfigOptionFloats>("flush_multiplier", true)->values;
|
||||
flush_multipliers.resize(new_extruder_count, 1.f);
|
||||
|
||||
ConfigOptionEnumsGeneric* nozzle_volume_opt = nullptr;
|
||||
if (m_print_config.has("nozzle_volume_type"))
|
||||
nozzle_volume_opt = m_print_config.option<ConfigOptionEnumsGeneric>("nozzle_volume_type");
|
||||
if (m_extra_config.has("nozzle_volume_type"))
|
||||
nozzle_volume_opt = m_extra_config.option<ConfigOptionEnumsGeneric>("nozzle_volume_type");
|
||||
|
||||
std::vector<NozzleVolumeType> volume_type_list;
|
||||
if (nozzle_volume_opt) {
|
||||
for (size_t idx = 0; idx < nozzle_volume_opt->values.size(); ++idx) {
|
||||
volume_type_list.emplace_back(NozzleVolumeType(nozzle_volume_opt->values[idx]));
|
||||
}
|
||||
}
|
||||
volume_type_list.resize(new_extruder_count, NozzleVolumeType::nvtStandard);
|
||||
std::vector<int>& nozzle_flush_dataset = m_print_config.option<ConfigOptionIntsNullable>("filament_flush_dataset",true)->values;
|
||||
nozzle_flush_dataset.resize(new_extruder_count, 0);
|
||||
|
||||
for (size_t nozzle_id = 0; nozzle_id < new_extruder_count; ++nozzle_id) {
|
||||
std::vector<double> flush_vol_mtx = get_flush_volumes_matrix(flush_vol_matrix, nozzle_id, new_extruder_count);
|
||||
|
|
@ -3200,7 +3189,7 @@ int CLI::run(int argc, char **argv)
|
|||
unsigned char to_rgb[4] = {};
|
||||
Slic3r::GUI::BitmapCache::parse_color4(to_color, to_rgb);
|
||||
|
||||
Slic3r::FlushVolCalculator calculator(min_flush_volumes[from_idx], Slic3r::g_max_flush_volume, new_extruder_count > 1, volume_type_list[nozzle_id]);
|
||||
Slic3r::FlushVolCalculator calculator(min_flush_volumes[from_idx], Slic3r::g_max_flush_volume,nozzle_flush_dataset[nozzle_id]);
|
||||
flushing_volume = calculator.calc_flush_vol(from_rgb[3], from_rgb[0], from_rgb[1], from_rgb[2], to_rgb[3], to_rgb[0], to_rgb[1], to_rgb[2]);
|
||||
if (is_from_support) { flushing_volume = std::max(Slic3r::g_min_flush_volume_from_support, flushing_volume); }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,24 +39,15 @@ static float DeltaHS_BBS(float h1, float s1, float v1, float h2, float s2, float
|
|||
return std::min(1.2f, dxy);
|
||||
}
|
||||
|
||||
FlushVolCalculator::FlushVolCalculator(int min, int max, bool is_multi_extruder, NozzleVolumeType volume_type, float multiplier)
|
||||
:m_min_flush_vol(min), m_max_flush_vol(max), m_multiplier(multiplier)
|
||||
FlushVolCalculator::FlushVolCalculator(int min, int max, int flush_dataset, float multiplier)
|
||||
:m_min_flush_vol(min), m_max_flush_vol(max), m_multiplier(multiplier), m_flush_dataset(flush_dataset)
|
||||
{
|
||||
if (!is_multi_extruder) {
|
||||
m_machine_type = FlushPredict::Standard;
|
||||
return;
|
||||
}
|
||||
|
||||
if (volume_type == NozzleVolumeType::nvtHighFlow)
|
||||
m_machine_type = FlushPredict::DualHighFlow;
|
||||
else
|
||||
m_machine_type = FlushPredict::DualStandard;
|
||||
}
|
||||
|
||||
bool FlushVolCalculator::get_flush_vol_from_data(unsigned char src_r, unsigned char src_g, unsigned char src_b,
|
||||
unsigned char dst_r, unsigned char dst_g, unsigned char dst_b, float& flush)
|
||||
{
|
||||
GenericFlushPredictor pd(m_machine_type);
|
||||
GenericFlushPredictor pd(m_flush_dataset);
|
||||
FlushPredict::RGBColor src(src_r, src_g, src_b);
|
||||
FlushPredict::RGBColor dst(dst_r, dst_g, dst_b);
|
||||
|
||||
|
|
@ -67,7 +58,7 @@ int FlushVolCalculator::calc_flush_vol_rgb(unsigned char src_r, unsigned char sr
|
|||
unsigned char dst_r, unsigned char dst_g, unsigned char dst_b)
|
||||
{
|
||||
float flush_volume;
|
||||
if(m_machine_type == FlushPredict::Standard && get_flush_vol_from_data(src_r, src_g, src_b, dst_r, dst_g, dst_b, flush_volume))
|
||||
if(m_flush_dataset == 0 && get_flush_vol_from_data(src_r, src_g, src_b, dst_r, dst_g, dst_b, flush_volume))
|
||||
return flush_volume;
|
||||
float src_r_f, src_g_f, src_b_f, dst_r_f, dst_g_f, dst_b_f;
|
||||
float from_hsv_h, from_hsv_s, from_hsv_v;
|
||||
|
|
@ -119,7 +110,7 @@ int FlushVolCalculator::calc_flush_vol(unsigned char src_a, unsigned char src_r,
|
|||
}
|
||||
|
||||
float flush_volume;
|
||||
if(m_machine_type != FlushPredict::Standard && get_flush_vol_from_data(src_r, src_g, src_b, dst_r, dst_g, dst_b, flush_volume))
|
||||
if(m_flush_dataset != 0 && get_flush_vol_from_data(src_r, src_g, src_b, dst_r, dst_g, dst_b, flush_volume))
|
||||
return std::min((int)flush_volume, m_max_flush_vol);
|
||||
|
||||
|
||||
|
|
@ -129,7 +120,7 @@ int FlushVolCalculator::calc_flush_vol(unsigned char src_a, unsigned char src_r,
|
|||
constexpr float light_color_thres = 75.f/255.f;
|
||||
bool is_from_dark = get_luminance(src_r, src_g, src_b) > dark_color_thres;
|
||||
bool is_to_light = get_luminance(dst_r, dst_g, dst_b) < light_color_thres;
|
||||
if (m_machine_type != FlushPredict::Standard && is_from_dark && is_to_light)
|
||||
if (m_flush_dataset != 0 && is_from_dark && is_to_light)
|
||||
flush_volume *= 1.3;
|
||||
|
||||
flush_volume += m_min_flush_vol;
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ extern const int g_max_flush_volume;
|
|||
class FlushVolCalculator
|
||||
{
|
||||
public:
|
||||
FlushVolCalculator(int min, int max, bool is_multi_extruder, NozzleVolumeType volume_type, float multiplier = 1.0f);
|
||||
FlushVolCalculator(int min, int max, int flush_dataset, float multiplier = 1.0f);
|
||||
~FlushVolCalculator()
|
||||
{
|
||||
}
|
||||
|
|
@ -33,7 +33,7 @@ private:
|
|||
int m_min_flush_vol;
|
||||
int m_max_flush_vol;
|
||||
float m_multiplier;
|
||||
FlushPredict::FlushMachineType m_machine_type;
|
||||
int m_flush_dataset;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -173,6 +173,7 @@ class FlushVolPredictor
|
|||
public:
|
||||
bool predict(const RGB& from,const RGB& to , float& flush);
|
||||
FlushVolPredictor(const std::string& data_file);
|
||||
int get_min_flush_volume();
|
||||
FlushVolPredictor() = default;
|
||||
private:
|
||||
uint64_t generate_hash_key(const RGB& from, const RGB& to);
|
||||
|
|
@ -181,6 +182,13 @@ private:
|
|||
bool m_valid{ false };
|
||||
};
|
||||
|
||||
int FlushVolPredictor::get_min_flush_volume()
|
||||
{
|
||||
if(!m_valid)
|
||||
return std::numeric_limits<int>::max();
|
||||
return static_cast<int>(std::min_element(m_flush_map.begin(), m_flush_map.end(), [](const auto& a, const auto& b) {return a.second < b.second; })->second);
|
||||
}
|
||||
|
||||
uint64_t FlushVolPredictor::generate_hash_key(const RGB& from, const RGB& to)
|
||||
{
|
||||
uint64_t key = 0;
|
||||
|
|
@ -299,24 +307,24 @@ bool FlushVolPredictor::predict(const RGB& from, const RGB& to, float& flush)
|
|||
}
|
||||
|
||||
|
||||
static std::unordered_map<FlushPredict::FlushMachineType, FlushVolPredictor> predictor_instances;
|
||||
static std::unordered_map<int, FlushVolPredictor> predictor_instances;
|
||||
|
||||
GenericFlushPredictor::GenericFlushPredictor(const MachineType& type)
|
||||
GenericFlushPredictor::GenericFlushPredictor(const int dataset_value)
|
||||
{
|
||||
auto iter = predictor_instances.find(type);
|
||||
auto iter = predictor_instances.find(dataset_value);
|
||||
if (iter != predictor_instances.end())
|
||||
predictor = &iter->second;
|
||||
else {
|
||||
std::string path = Slic3r::resources_dir();
|
||||
if (type == MachineType::DualHighFlow)
|
||||
path += "/flush/flush_data_dual_highflow.txt";
|
||||
else if (type == MachineType::DualStandard)
|
||||
path += "/flush/flush_data_dual_standard.txt";
|
||||
else
|
||||
if (dataset_value == 0)
|
||||
path += "/flush/flush_data_standard.txt";
|
||||
predictor_instances[type] = FlushVolPredictor(path);
|
||||
else if (dataset_value == 1)
|
||||
path += "/flush/flush_data_dual_standard.txt";
|
||||
else if (dataset_value == 2)
|
||||
path += "/flush/flush_data_dual_highflow.txt";
|
||||
predictor_instances[dataset_value] = FlushVolPredictor(path);
|
||||
|
||||
predictor = &predictor_instances[type];
|
||||
predictor = &predictor_instances[dataset_value];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -327,3 +335,10 @@ bool GenericFlushPredictor::predict(const RGB& from, const RGB& to, float& flush
|
|||
return false;
|
||||
return predictor->predict(from, to, flush);
|
||||
}
|
||||
|
||||
int GenericFlushPredictor::get_min_flush_volume()
|
||||
{
|
||||
if (!predictor)
|
||||
return std::numeric_limits<int>::max();
|
||||
return predictor->get_min_flush_volume();
|
||||
}
|
||||
|
|
@ -8,14 +8,6 @@
|
|||
|
||||
namespace FlushPredict
|
||||
{
|
||||
enum FlushMachineType
|
||||
{
|
||||
Standard,
|
||||
DualStandard,
|
||||
DualHighFlow
|
||||
};
|
||||
|
||||
|
||||
struct RGBColor
|
||||
{
|
||||
unsigned char r{ 0 };
|
||||
|
|
@ -48,10 +40,10 @@ class FlushVolPredictor;
|
|||
class GenericFlushPredictor
|
||||
{
|
||||
using RGB = FlushPredict::RGBColor;
|
||||
using MachineType = FlushPredict::FlushMachineType;
|
||||
public:
|
||||
explicit GenericFlushPredictor(const MachineType& type);
|
||||
explicit GenericFlushPredictor(const int dataset_value);
|
||||
bool predict(const RGB& from, const RGB& to, float& flush);
|
||||
int get_min_flush_volume();
|
||||
private:
|
||||
FlushVolPredictor* predictor{ nullptr };
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1016,7 +1016,7 @@ static std::vector<std::string> s_Preset_printer_options {
|
|||
"cooling_tube_length", "high_current_on_filament_swap", "parking_pos_retraction", "extra_loading_move", "purge_in_prime_tower", "enable_filament_ramming",
|
||||
"z_offset",
|
||||
"disable_m73", "preferred_orientation", "emit_machine_limits_to_gcode", "pellet_modded_printer", "support_multi_bed_types", "default_bed_type", "bed_mesh_min","bed_mesh_max","bed_mesh_probe_distance", "adaptive_bed_mesh_margin", "enable_long_retraction_when_cut","long_retractions_when_cut","retraction_distances_when_cut",
|
||||
"bed_temperature_formula"
|
||||
"bed_temperature_formula", "nozzle_flush_dataset"
|
||||
};
|
||||
|
||||
static std::vector<std::string> s_Preset_sla_print_options {
|
||||
|
|
|
|||
|
|
@ -2277,6 +2277,10 @@ void PrintConfigDef::init_fff_params()
|
|||
def->enum_labels.push_back(L("By Highest Temp"));
|
||||
def->set_default_value(new ConfigOptionEnum<BedTempFormula>(BedTempFormula::btfFirstFilament));
|
||||
|
||||
def = this->add("nozzle_flush_dataset", coInts);
|
||||
def->nullable = true;
|
||||
def->set_default_value(new ConfigOptionIntsNullable{0});
|
||||
|
||||
def = this->add("filament_diameter", coFloats);
|
||||
def->label = L("Diameter");
|
||||
def->tooltip = L("Filament diameter is used to calculate extrusion in G-code, so it is important and should be accurate.");
|
||||
|
|
@ -7535,7 +7539,8 @@ std::set<std::string> printer_options_with_variant_1 = {
|
|||
"nozzle_volume",
|
||||
"nozzle_type",
|
||||
"printer_extruder_id",
|
||||
"printer_extruder_variant"
|
||||
"printer_extruder_variant",
|
||||
"nozzle_flush_dataset"
|
||||
};
|
||||
|
||||
//options with silient mode
|
||||
|
|
|
|||
|
|
@ -1251,6 +1251,7 @@ PRINT_CONFIG_CLASS_DEFINE(
|
|||
((ConfigOptionStrings, filament_extruder_variant))
|
||||
((ConfigOptionEnum<BedTempFormula>, bed_temperature_formula))
|
||||
((ConfigOptionInts, physical_extruder_map))
|
||||
((ConfigOptionIntsNullable, nozzle_flush_dataset))
|
||||
((ConfigOptionFloatsNullable, filament_flush_volumetric_speed))
|
||||
((ConfigOptionIntsNullable, filament_flush_temp))
|
||||
// BBS
|
||||
|
|
|
|||
|
|
@ -3582,9 +3582,7 @@ void Sidebar::auto_calc_flushing_volumes_internal(const int modify_id, const int
|
|||
const auto& full_config = wxGetApp().preset_bundle->full_config();
|
||||
auto& ams_multi_color_filament = preset_bundle->ams_multi_color_filment;
|
||||
size_t extruder_nums = preset_bundle->get_printer_extruder_count();
|
||||
bool is_multi_extruder = extruder_nums > 1;
|
||||
NozzleVolumeType volume_type=NozzleVolumeType(full_config.option<ConfigOptionEnumsGeneric>("nozzle_volume_type")->values[extruder_id]);
|
||||
|
||||
int nozzle_flush_dataset = full_config.option<ConfigOptionIntsNullable>("nozzle_flush_dataset")->values[extruder_id];
|
||||
std::vector<double> init_matrix = get_flush_volumes_matrix((project_config.option<ConfigOptionFloats>("flush_volumes_matrix"))->values, extruder_id, extruder_nums);
|
||||
|
||||
const std::vector<int>& min_flush_volumes = get_min_flush_volumes(full_config, extruder_id);
|
||||
|
|
@ -3621,7 +3619,7 @@ void Sidebar::auto_calc_flushing_volumes_internal(const int modify_id, const int
|
|||
// from to modify
|
||||
int from_idx = i;
|
||||
if (from_idx != modify_id) {
|
||||
Slic3r::FlushVolCalculator calculator(min_flush_volumes[from_idx], m_max_flush_volume, is_multi_extruder,volume_type);
|
||||
Slic3r::FlushVolCalculator calculator(min_flush_volumes[from_idx], m_max_flush_volume, nozzle_flush_dataset);
|
||||
int flushing_volume = 0;
|
||||
bool is_from_support = is_support_filament(from_idx);
|
||||
bool is_to_support = is_support_filament(modify_id);
|
||||
|
|
@ -3646,7 +3644,7 @@ void Sidebar::auto_calc_flushing_volumes_internal(const int modify_id, const int
|
|||
// modify to to
|
||||
int to_idx = i;
|
||||
if (to_idx != modify_id) {
|
||||
Slic3r::FlushVolCalculator calculator(min_flush_volumes[modify_id], m_max_flush_volume, is_multi_extruder, volume_type);
|
||||
Slic3r::FlushVolCalculator calculator(min_flush_volumes[modify_id], m_max_flush_volume, nozzle_flush_dataset);
|
||||
bool is_from_support = is_support_filament(modify_id);
|
||||
bool is_to_support = is_support_filament(to_idx);
|
||||
int flushing_volume = 0;
|
||||
|
|
|
|||
|
|
@ -214,6 +214,8 @@ wxString WipingDialog::BuildTableObjStr()
|
|||
auto flush_multiplier = full_config.option<ConfigOptionFloats>("flush_multiplier")->values;
|
||||
int nozzle_num = full_config.option<ConfigOptionFloatsNullable>("nozzle_diameter")->values.size();
|
||||
auto raw_matrix_data = full_config.option<ConfigOptionFloats>("flush_volumes_matrix")->values;
|
||||
auto nozzle_flush_dataset = full_config.option<ConfigOptionIntsNullable>("nozzle_flush_dataset")->values;
|
||||
|
||||
std::vector<std::vector<double>> flush_matrixs;
|
||||
for (int idx = 0; idx < nozzle_num; ++idx) {
|
||||
flush_matrixs.emplace_back(get_flush_volumes_matrix(raw_matrix_data, idx, nozzle_num));
|
||||
|
|
@ -239,7 +241,10 @@ wxString WipingDialog::BuildTableObjStr()
|
|||
}
|
||||
|
||||
for (int idx = 0; idx < nozzle_num; ++idx) {
|
||||
obj["min_flush_volumes"].push_back(0);
|
||||
int min_flush_from_nozzle_volume = *min_element(m_extra_flush_volume[idx].begin(), m_extra_flush_volume[idx].end());
|
||||
GenericFlushPredictor pd(nozzle_flush_dataset[idx]);
|
||||
int min_flush_from_flush_data = pd.get_min_flush_volume();
|
||||
obj["min_flush_volumes"].push_back(std::min(min_flush_from_flush_data,min_flush_from_nozzle_volume));
|
||||
obj["max_flush_volumes"].push_back(m_max_flush_volume);
|
||||
}
|
||||
|
||||
|
|
@ -421,9 +426,9 @@ WipingDialog::WipingDialog(wxWindow* parent, const std::vector<std::vector<int>>
|
|||
}
|
||||
|
||||
|
||||
int WipingDialog::CalcFlushingVolume(const wxColour& from, const wxColour& to, int min_flush_volume ,bool is_multi_extruder, NozzleVolumeType volume_type)
|
||||
int WipingDialog::CalcFlushingVolume(const wxColour& from, const wxColour& to, int min_flush_volume , int nozzle_flush_dataset)
|
||||
{
|
||||
Slic3r::FlushVolCalculator calculator(min_flush_volume, Slic3r::g_max_flush_volume, is_multi_extruder, volume_type);
|
||||
Slic3r::FlushVolCalculator calculator(min_flush_volume, Slic3r::g_max_flush_volume, nozzle_flush_dataset);
|
||||
return calculator.calc_flush_vol(from.Alpha(), from.Red(), from.Green(), from.Blue(), to.Alpha(), to.Red(), to.Green(), to.Blue());
|
||||
}
|
||||
|
||||
|
|
@ -439,8 +444,7 @@ WipingDialog::VolumeMatrix WipingDialog::CalcFlushingVolumes(int extruder_id)
|
|||
for (auto color_str : filament_color_strs)
|
||||
filament_colors.emplace_back(color_str);
|
||||
|
||||
NozzleVolumeType volume_type = NozzleVolumeType(full_config.option<ConfigOptionEnumsGeneric>("nozzle_volume_type")->values[extruder_id]);
|
||||
bool is_multi_extruder = preset_bundle->get_printer_extruder_count() > 1;
|
||||
int flush_dataset_value = full_config.option<ConfigOptionIntsNullable>("nozzle_flush_dataset")->values[extruder_id];
|
||||
// Support for multi-color filament
|
||||
for (int i = 0; i < filament_colors.size(); ++i) {
|
||||
std::vector<wxColour> single_filament;
|
||||
|
|
@ -480,7 +484,7 @@ WipingDialog::VolumeMatrix WipingDialog::CalcFlushingVolumes(int extruder_id)
|
|||
const wxColour& from = multi_colors[from_idx][i];
|
||||
for (int j = 0; j < multi_colors[to_idx].size(); ++j) {
|
||||
const wxColour& to = multi_colors[to_idx][j];
|
||||
int volume = CalcFlushingVolume(from, to, m_extra_flush_volume[extruder_id][from_idx], is_multi_extruder, volume_type);
|
||||
int volume = CalcFlushingVolume(from, to, m_extra_flush_volume[extruder_id][from_idx], flush_dataset_value);
|
||||
flushing_volume = std::max(flushing_volume, volume);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ public:
|
|||
bool GetSubmitFlag() const { return m_submit_flag; }
|
||||
|
||||
private:
|
||||
int CalcFlushingVolume(const wxColour& from_, const wxColour& to_, int min_flush_volume, bool is_multi_extruder, Slic3r::NozzleVolumeType volume_type);
|
||||
int CalcFlushingVolume(const wxColour& from_, const wxColour& to_, int min_flush_volume, int nozzle_flush_dataset);
|
||||
wxString BuildTableObjStr();
|
||||
wxString BuildTextObjStr(bool multi_language = true);
|
||||
void StoreFlushData(int extruder_num, const std::vector<std::vector<double>>& flush_volume_vecs, const std::vector<double>& flush_multipliers);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue