FIX: modify unprintable_filament_ids should regroup

jira: none
Change-Id: Ifb8105f6e301aaed9ca4e62a37b9d3a1616e755b
(cherry picked from commit fec7129437fc781b918ae1819c280440ea3fb54b)
This commit is contained in:
zhimin.zeng
2024-09-12 12:25:04 +08:00
committed by Noisyfox
parent 42f8070fc9
commit 72d758c3b0
10 changed files with 199 additions and 22 deletions

View File

@@ -1078,7 +1078,7 @@ bool GLVolumeCollection::check_outside_state(const BuildVolume &build_volume, Mo
BuildVolume plate_build_volume(pp_bed_shape, build_volume.printable_height(), build_volume.extruder_areas());
const std::vector<BoundingBoxf3>& exclude_areas = curr_plate->get_exclude_areas();
curr_plate->clear_unprintable_filament_ids();
std::vector<std::set<int>> unprintable_filament_ids;
for (GLVolume* volume : this->volumes)
{
if (! volume->is_modifier && (volume->shader_outside_printer_detection_enabled || (! volume->is_wipe_tower && volume->composite_id.volume_id >= 0))) {
@@ -1096,13 +1096,14 @@ bool GLVolumeCollection::check_outside_state(const BuildVolume &build_volume, Mo
std::vector<bool> inside_extruders;
state = plate_build_volume.check_volume_bbox_state_with_extruder_areas(bb, inside_extruders);
if (state == BuildVolume::ObjectState::Limited) {
unprintable_filament_ids.resize(inside_extruders.size());
const ModelObjectPtrs &model_objects = model.objects;
ModelObject *model_object = model_objects[volume->object_idx()];
ModelVolume *model_volume = model_object->volumes[volume->volume_idx()];
for (size_t i = 0; i < inside_extruders.size(); ++i) {
if (!inside_extruders[i]) {
std::vector<int> extruders = model_volume->get_extruders();
curr_plate->append_unprintable_filament_ids(i, extruders);
unprintable_filament_ids[i].insert(extruders.begin(), extruders.end());
}
}
}
@@ -1181,6 +1182,13 @@ bool GLVolumeCollection::check_outside_state(const BuildVolume &build_volume, Mo
}
}
std::vector<std::vector<int>> unprintable_filament_vec;
for (const std::set<int>& filamnt_ids : unprintable_filament_ids) {
unprintable_filament_vec.emplace_back(std::vector<int>(filamnt_ids.begin(), filamnt_ids.end()));
}
curr_plate->set_unprintable_filament_ids(unprintable_filament_vec);
/*for (GLVolume* volume : this->volumes)
{
if (! volume->is_modifier && (volume->shader_outside_printer_detection_enabled || (! volume->is_wipe_tower && volume->composite_id.volume_id >= 0)))

View File

@@ -2898,7 +2898,6 @@ void PartPlate::update_slice_context(BackgroundSlicingProcess & process)
process.select_technology(this->printer_technology);
process.set_current_plate(this);
m_print->set_status_callback(statuscb);
m_print->set_unprintable_filament_ids(m_unprintable_filament_ids);
process.switch_print_preprocess();
return;
@@ -3224,21 +3223,24 @@ std::vector<int> PartPlate::get_filament_maps()
return filament_maps;
}
void PartPlate::append_unprintable_filament_ids(int extruder_id, const std::vector<int> &filament_ids)
{
if (extruder_id > m_unprintable_filament_ids.size()) {
m_unprintable_filament_ids.resize(extruder_id + 1);
}
m_unprintable_filament_ids[extruder_id].insert(m_unprintable_filament_ids[extruder_id].end(), filament_ids.begin(), filament_ids.end());
}
void PartPlate::set_filament_maps(const std::vector<int>& f_maps)
{
std::vector<int>& filament_maps = m_config.option<ConfigOptionInts>("filament_map", true)->values;
filament_maps = f_maps;
}
const std::vector<std::vector<int>>& PartPlate::get_unprintable_filament_ids()
{
std::vector<std::vector<int>> & unprintabel_filament_maps = m_config.option<ConfigOptionIntsGroups>("unprintable_filament_map", true)->values;
return unprintabel_filament_maps;
}
void PartPlate::set_unprintable_filament_ids(const std::vector<std::vector<int>> &filament_ids)
{
std::vector<std::vector<int>> &unprintabel_filament_maps = m_config.option<ConfigOptionIntsGroups>("unprintable_filament_map", true)->values;
unprintabel_filament_maps = filament_ids;
}
void PartPlate::on_extruder_count_changed(int extruder_count)
{
std::vector<int>& filament_maps = m_config.option<ConfigOptionInts>("filament_map", true)->values;

View File

@@ -112,9 +112,6 @@ private:
std::vector<FilamentInfo> slice_filaments_info;
int m_print_index;
// filament ids of extruder
std::vector<std::vector<int>> m_unprintable_filament_ids;
std::string m_tmp_gcode_path; //use a temp path to store the gcode
std::string m_temp_config_3mf_path; //use a temp path to store the config 3mf
std::string m_gcode_path_from_3mf; //use a path to store the gcode loaded from 3mf
@@ -500,10 +497,8 @@ public:
std::vector<int> get_filament_maps();
void set_filament_maps(const std::vector<int>& f_maps);
const std::vector<std::vector<int>> &get_unprintable_filament_ids() const { return m_unprintable_filament_ids; }
void set_unprintable_filament_ids(const std::vector<std::vector<int>> &filament_ids) { m_unprintable_filament_ids = filament_ids; }
void clear_unprintable_filament_ids() { m_unprintable_filament_ids.clear(); }
void append_unprintable_filament_ids(int extruder_id, const std::vector<int> &filament_ids);
const std::vector<std::vector<int>> &get_unprintable_filament_ids();
void set_unprintable_filament_ids(const std::vector<std::vector<int>> &filament_ids);
void on_extruder_count_changed(int extruder_count);
void set_filament_count(int filament_count);