ENH: wipe tower support filaments that do not adhere to each other

jira:none

Change-Id: Ia52340f4e8bdb34791cb2019e9763bddfbc8dc5f
This commit is contained in:
zhimin.zeng 2024-12-16 19:41:45 +08:00 committed by lane.wei
parent 43a65adb2f
commit e1e0de6efb
7 changed files with 1106 additions and 6 deletions

File diff suppressed because it is too large Load Diff

View File

@ -8,6 +8,7 @@
#include <algorithm>
#include "libslic3r/Point.hpp"
#include <unordered_set>
namespace Slic3r
{
@ -145,6 +146,13 @@ public:
bool is_finish,
float purge_volume) const;
ToolChangeResult construct_block_tcr(WipeTowerWriter& writer,
bool priming,
size_t filament_id,
bool is_finish,
float purge_volume) const;
// x -- x coordinates of wipe tower in mm ( left bottom corner )
// y -- y coordinates of wipe tower in mm ( left bottom corner )
// width -- width of wipe tower in mm ( default 60 mm - leave as it is )
@ -163,7 +171,7 @@ public:
// Iterates through prepared m_plan, generates ToolChangeResults and appends them to "result"
void generate(std::vector<std::vector<ToolChangeResult>> &result);
WipeTower::ToolChangeResult only_generate_out_wall();
WipeTower::ToolChangeResult only_generate_out_wall(bool is_new_mode = false);
float get_depth() const { return m_wipe_tower_depth; }
float get_brim_width() const { return m_wipe_tower_brim_width_real; }
@ -264,6 +272,7 @@ public:
struct FilamentParameters {
std::string material = "PLA";
int category;
bool is_soluble = false;
// BBS
bool is_support = false;
@ -286,6 +295,55 @@ public:
float filament_area;
};
void set_used_filament_ids(const std::vector<int> &used_filament_ids) { m_used_filament_ids = used_filament_ids; };
void set_filament_categories(const std::vector<int> & filament_categories) { m_filament_categories = filament_categories;};
std::vector<int> m_used_filament_ids;
std::vector<int> m_filament_categories;
struct WipeTowerBlock
{
int block_id{0};
int filament_category{0};
std::vector<float> layer_depths;
float depth{0};
float start_depth{0};
float cur_depth{0};
int last_filament_change_id{-1};
int last_nozzle_change_id{-1};
};
struct BlockDepthInfo
{
int category{-1};
float depth{0};
float nozzle_change_depth{0};
};
std::vector<std::vector<BlockDepthInfo>> m_all_layers_depth;
std::vector<WipeTowerBlock> m_wipe_tower_blocks;
int m_last_block_id;
// help function
WipeTowerBlock& get_block_by_category(int filament_category);
void add_depth_to_block(int filament_id, int filament_category, float depth, bool is_nozzle_change = false);
int get_filament_category(int filament_id);
bool is_in_same_extruder(int filament_id_1, int filament_id_2);
void reset_block_status();
int get_wall_filament_for_all_layer();
// for generate new wipe tower
void generate_new(std::vector<std::vector<WipeTower::ToolChangeResult>> &result);
void plan_tower_new();
void generate_wipe_tower_blocks();
void update_start_depth_for_blocks();
ToolChangeResult tool_change_new(size_t new_tool);
NozzleChangeResult nozzle_change_new(int old_filament_id, int new_filament_id);
ToolChangeResult finish_layer_new(bool extrude_perimeter = true, bool extrude_fill = true, bool extrude_fill_wall = true);
ToolChangeResult finish_block(int filament_id, bool extrude_perimeter = true, bool extrude_fill = true);
void toolchange_wipe_new(WipeTowerWriter &writer, const box_coordinates &cleaning_box, float wipe_length);
private:
enum wipe_shape // A fill-in direction
{
@ -372,6 +430,7 @@ private:
bool m_current_layer_finished = false;
bool m_left_to_right = true;
float m_extra_spacing = 1.f;
float m_tpu_fixed_spacing = 2;
bool is_first_layer() const { return size_t(m_layer_info - m_plan.begin()) == m_first_layer_idx; }

View File

@ -906,7 +906,7 @@ static std::vector<std::string> s_Preset_print_options {
static std::vector<std::string> s_Preset_filament_options {
/*"filament_colour", */ "default_filament_colour","required_nozzle_HRC","filament_diameter", "filament_type", "filament_soluble", "filament_is_support","filament_scarf_seam_type", "filament_scarf_height", "filament_scarf_gap","filament_scarf_length",
"filament_max_volumetric_speed",
"filament_flow_ratio", "filament_density", "filament_cost", "filament_minimal_purge_on_wipe_tower",
"filament_flow_ratio", "filament_density", "filament_category", "filament_cost", "filament_minimal_purge_on_wipe_tower",
"nozzle_temperature", "nozzle_temperature_initial_layer",
// BBS
"cool_plate_temp", "eng_plate_temp", "hot_plate_temp", "textured_plate_temp", "cool_plate_temp_initial_layer", "eng_plate_temp_initial_layer", "hot_plate_temp_initial_layer","textured_plate_temp_initial_layer",

View File

@ -262,6 +262,7 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n
|| opt_key == "filament_map_mode"
|| opt_key == "filament_map"
|| opt_key == "unprintable_filament_map"
|| opt_key == "filament_category"
//|| opt_key == "wipe_tower_bridging"
|| opt_key == "wipe_tower_no_sparse_layers"
|| opt_key == "flush_volumes_matrix"
@ -2537,6 +2538,8 @@ void Print::_make_wipe_tower()
//m_wipe_tower_data.priming = Slic3r::make_unique<std::vector<WipeTower::ToolChangeResult>>(
// wipe_tower.prime((float)this->skirt_first_layer_height(), m_wipe_tower_data.tool_ordering.all_extruders(), false));
std::set<int> used_filament_ids;
// Lets go through the wipe tower layers and determine pairs of extruder changes for each
// to pass to wipe_tower (so that it can use it for planning the layout of the tower)
{
@ -2566,6 +2569,8 @@ void Print::_make_wipe_tower()
bool first_layer = &layer_tools == &m_wipe_tower_data.tool_ordering.front();
wipe_tower.plan_toolchange((float)layer_tools.print_z, (float)layer_tools.wipe_tower_layer_height, current_filament_id, current_filament_id);
used_filament_ids.insert(layer_tools.extruders.begin(), layer_tools.extruders.end());
for (const auto filament_id : layer_tools.extruders) {
if (filament_id == current_filament_id)
continue;
@ -2603,9 +2608,17 @@ void Print::_make_wipe_tower()
}
}
wipe_tower.set_used_filament_ids(std::vector<int>(used_filament_ids.begin(), used_filament_ids.end()));
std::vector<int> categories;
for (size_t i = 0; i < m_config.filament_category.values.size(); ++i) {
categories.push_back(m_config.filament_category.get_at(i));
}
wipe_tower.set_filament_categories(categories);
// Generate the wipe tower layers.
m_wipe_tower_data.tool_changes.reserve(m_wipe_tower_data.tool_ordering.layer_tools().size());
wipe_tower.generate(m_wipe_tower_data.tool_changes);
wipe_tower.generate_new(m_wipe_tower_data.tool_changes);
m_wipe_tower_data.depth = wipe_tower.get_depth();
m_wipe_tower_data.brim_width = wipe_tower.get_brim_width();

View File

@ -1732,6 +1732,13 @@ void PrintConfigDef::init_fff_params()
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionPercents{ 100 });
def = this->add("filament_category", coInts);
def->label = L("Category");
def->tooltip = L("Filament category");
def->min = 0;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionInts{0});
def = this->add("filament_density", coFloats);
def->label = L("Density");
def->tooltip = L("Filament density. For statistics only");

View File

@ -991,6 +991,7 @@ PRINT_CONFIG_CLASS_DEFINE(
((ConfigOptionBools, enable_pressure_advance))
((ConfigOptionFloats, pressure_advance))
((ConfigOptionFloats, filament_diameter))
((ConfigOptionInts, filament_category))
((ConfigOptionFloats, filament_density))
((ConfigOptionStrings, filament_type))
((ConfigOptionBools, filament_soluble))

View File

@ -3153,6 +3153,7 @@ void TabFilament::build()
optgroup->append_single_option_line("required_nozzle_HRC");
optgroup->append_single_option_line("default_filament_colour");
optgroup->append_single_option_line("filament_diameter");
optgroup->append_single_option_line("filament_category");
optgroup->append_single_option_line("filament_flow_ratio", "", 0);
optgroup->append_single_option_line("enable_pressure_advance");
optgroup->append_single_option_line("pressure_advance");