Allow user to turn adaptive layer height for tree support.

Signed-off-by: SoftFever <softfeverever@gmail.com>
#257
This commit is contained in:
SoftFever 2023-03-06 19:57:09 +08:00
parent 6ed219fb65
commit a6cd32fe72
11 changed files with 32 additions and 15 deletions

View file

@ -753,7 +753,8 @@ static std::vector<std::string> s_Preset_print_options {
"default_jerk", "outer_wall_jerk", "inner_wall_jerk", "infill_jerk", "top_surface_jerk", "initial_layer_jerk","travel_jerk",
"top_solid_infill_flow_ratio","bottom_solid_infill_flow_ratio","only_one_wall_first_layer", "print_flow_ratio", "seam_gap",
"role_based_wipe_speed", "wipe_speed", "accel_to_decel_enable", "accel_to_decel_factor", "wipe_on_loops",
"bridge_density", "precise_outer_wall", "overhang_speed_classic", "bridge_acceleration", "sparse_infill_acceleration", "internal_solid_infill_acceleration"
"bridge_density", "precise_outer_wall", "overhang_speed_classic", "bridge_acceleration",
"sparse_infill_acceleration", "internal_solid_infill_acceleration", "tree_support_adaptive_layer_height"
};

View file

@ -2994,6 +2994,12 @@ void PrintConfigDef::init_fff_params()
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloat(5.));
def = this->add("tree_support_adaptive_layer_height", coBool);
def->label = L("Adaptive layer height");
def->category = L("Quality");
def->tooltip = L("Enabling this option means the height of tree support layer except the first will be automatically calculated ");
def->set_default_value(new ConfigOptionBool(1));
def = this->add("tree_support_branch_diameter", coFloat);
def->label = L("Tree support branch diameter");
def->category = L("Support");

View file

@ -679,6 +679,7 @@ PRINT_CONFIG_CLASS_DEFINE(
((ConfigOptionFloat, tree_support_branch_diameter))
((ConfigOptionFloat, tree_support_branch_angle))
((ConfigOptionInt, tree_support_wall_count))
((ConfigOptionBool, tree_support_adaptive_layer_height))
((ConfigOptionBool, detect_narrow_internal_solid_infill))
// ((ConfigOptionBool, adaptive_layer_height))
((ConfigOptionFloat, support_bottom_interface_spacing))

View file

@ -756,6 +756,7 @@ bool PrintObject::invalidate_state_by_config_options(
|| opt_key == "bridge_no_support"
|| opt_key == "max_bridge_length"
|| opt_key == "initial_layer_line_width"
|| opt_key == "tree_support_adaptive_layer_height"
|| opt_key == "tree_support_branch_distance"
|| opt_key == "tree_support_branch_diameter"
|| opt_key == "tree_support_branch_angle"

View file

@ -16,7 +16,6 @@
#define _L(s) Slic3r::I18N::translate(s)
#define USE_PLAN_LAYER_HEIGHTS 1
#define HEIGHT_TO_SWITCH_INFILL_DIRECTION 30 // change infill direction every 20mm
#ifndef M_PI
@ -1917,10 +1916,10 @@ void TreeSupport::generate_support_areas()
smooth_nodes(contact_nodes);
#if !USE_PLAN_LAYER_HEIGHTS
// Adjust support layer heights
adjust_layer_heights(contact_nodes);
#endif
if (!m_object->config().tree_support_adaptive_layer_height)
// Adjust support layer heights
adjust_layer_heights(contact_nodes);
//Generate support areas.
profiler.stage_start(STAGE_DRAW_CIRCLES);
@ -3209,7 +3208,7 @@ std::vector<std::pair<coordf_t, coordf_t>> TreeSupport::plan_layer_heights(std::
std::vector<std::pair<coordf_t, coordf_t>> layer_heights(contact_nodes.size(), std::pair<coordf_t, coordf_t>(0.0, 0.0));
std::vector<int> bounds;
if (!USE_PLAN_LAYER_HEIGHTS || layer_height == max_layer_height || !print_config.independent_support_layer_height) {
if (!config.tree_support_adaptive_layer_height || layer_height == max_layer_height || !print_config.independent_support_layer_height) {
for (int layer_nr = 0; layer_nr < contact_nodes.size(); layer_nr++) {
layer_heights[layer_nr].first = m_object->get_layer(layer_nr)->print_z;
layer_heights[layer_nr].second = m_object->get_layer(layer_nr)->height;

View file

@ -485,7 +485,8 @@ void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, con
void ConfigManipulation::apply_null_fff_config(DynamicPrintConfig *config, std::vector<std::string> const &keys, std::map<ObjectBase *, ModelConfig *> const &configs)
{
for (auto &k : keys) {
if (/*k == "adaptive_layer_height" || */k == "independent_support_layer_height" || k == "enable_support" || k == "detect_thin_wall")
if (/*k == "adaptive_layer_height" || */ k == "independent_support_layer_height" || k == "enable_support" ||
k == "detect_thin_wall" || k == "tree_support_adaptive_layer_height")
config->set_key_value(k, new ConfigOptionBool(true));
else if (k == "wall_loops")
config->set_key_value(k, new ConfigOptionInt(0));
@ -587,11 +588,13 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig *config, co
//toggle_field("support_closing_radius", have_support_material && support_style == smsSnug);
bool support_is_tree = config->opt_bool("enable_support") && is_tree(support_type);
for (auto el : {"tree_support_branch_angle", "tree_support_wall_count", "tree_support_branch_distance", "tree_support_branch_diameter"})
for (auto el : {"tree_support_branch_angle", "tree_support_wall_count", "tree_support_branch_distance",
"tree_support_branch_diameter", "tree_support_adaptive_layer_height"})
toggle_field(el, support_is_tree);
// hide tree support settings when normal is selected
for (auto el : {"tree_support_branch_angle", "tree_support_wall_count", "tree_support_branch_distance", "tree_support_branch_diameter", "max_bridge_length"})
for (auto el : {"tree_support_branch_angle", "tree_support_wall_count", "tree_support_branch_distance",
"tree_support_branch_diameter", "max_bridge_length", "tree_support_adaptive_layer_height"})
toggle_line(el, support_is_tree);
// tree support use max_bridge_length instead of bridge_no_support

View file

@ -1992,6 +1992,7 @@ void TabPrint::build()
optgroup->append_single_option_line("tree_support_branch_diameter", "support#tree-support-only-options");
optgroup->append_single_option_line("tree_support_branch_angle", "support#tree-support-only-options");
optgroup->append_single_option_line("tree_support_wall_count");
optgroup->append_single_option_line("tree_support_adaptive_layer_height");
optgroup->append_single_option_line("support_top_z_distance", "support#top-z-distance");
optgroup->append_single_option_line("support_bottom_z_distance", "support#bottom-z-distance");
optgroup->append_single_option_line("support_base_pattern", "support#base-pattern");