mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-06-13 07:23:03 +00: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:
@@ -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();
|
||||
}
|
||||
Reference in New Issue
Block a user