FIX: variable layer height prompt an error when enable the prime tower

Change-Id: I80b3965d25a9e1faaff1298f42b171660974463e
(cherry picked from commit a519f82ce7c1b169ad995d10a28e873e133f2373)
This commit is contained in:
zhimin.zeng 2022-11-08 12:54:17 +08:00 committed by Lane.Wei
parent 4671aed03b
commit 118a13200b
6 changed files with 39 additions and 30 deletions

View file

@ -727,7 +727,7 @@ static std::vector<std::string> s_Preset_print_options {
"tree_support_branch_angle", "tree_support_with_infill", "tree_support_wall_count", "tree_support_branch_distance", "tree_support_branch_angle", "tree_support_with_infill", "tree_support_wall_count", "tree_support_branch_distance",
"tree_support_branch_diameter", "tree_support_branch_diameter",
"detect_narrow_internal_solid_infill", "detect_narrow_internal_solid_infill",
"gcode_add_line_number", "enable_arc_fitting", "infill_combination", "adaptive_layer_height", "gcode_add_line_number", "enable_arc_fitting", "infill_combination", /*"adaptive_layer_height",*/
"support_bottom_interface_spacing", "enable_overhang_speed", "overhang_1_4_speed", "overhang_2_4_speed", "overhang_3_4_speed", "overhang_4_4_speed", "support_bottom_interface_spacing", "enable_overhang_speed", "overhang_1_4_speed", "overhang_2_4_speed", "overhang_3_4_speed", "overhang_4_4_speed",
"initial_layer_infill_speed", "only_one_wall_top", "initial_layer_infill_speed", "only_one_wall_top",
"timelapse_type" "timelapse_type"

View file

@ -947,16 +947,25 @@ StringObjectException Print::validate(StringObjectException *warning, Polygons*
} }
// BBS: remove obsolete logics and _L() // BBS: remove obsolete logics and _L()
#if 0
if (has_custom_layering) { if (has_custom_layering) {
for (size_t idx_object = 0; idx_object < m_objects.size(); ++ idx_object) { for (size_t idx_object = 0; idx_object < m_objects.size(); ++idx_object) {
if (idx_object == tallest_object_idx) if (idx_object == tallest_object_idx) continue;
continue; // Check that the layer height profiles are equal. This will happen when one object is
if (layer_height_profiles[idx_object] != layer_height_profiles[tallest_object_idx]) // a copy of another, or when a layer height modifier is used the same way on both objects.
return {("The prime tower is only supported if all objects have the same variable layer height"), m_objects[idx_object]}; // The latter case might create a floating point inaccuracy mismatch, so compare
// element-wise using an epsilon check.
size_t i = 0;
const coordf_t eps = 0.5 * EPSILON; // layers closer than EPSILON will be merged later. Let's make
// this check a bit more sensitive to make sure we never consider two different layers as one.
while (i < layer_height_profiles[idx_object].size() && i < layer_height_profiles[tallest_object_idx].size()) {
if (i % 2 == 0 && layer_height_profiles[tallest_object_idx][i] > layer_height_profiles[idx_object][layer_height_profiles[idx_object].size() - 2])
break;
if (std::abs(layer_height_profiles[idx_object][i] - layer_height_profiles[tallest_object_idx][i]) > eps)
return {L("The prime tower is only supported if all objects have the same variable layer height")};
++i;
}
} }
} }
#endif
} }
} }

View file

@ -1401,7 +1401,7 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_
// BBS // BBS
for (PrintObject* object : m_objects) { for (PrintObject* object : m_objects) {
auto ept_iter = std::find(print_diff.begin(), print_diff.end(), "enable_prime_tower"); auto ept_iter = std::find(print_diff.begin(), print_diff.end(), "enable_prime_tower");
if (object->config().adaptive_layer_height && ept_iter != print_diff.end()) { if (/*object->config().adaptive_layer_height &&*/ ept_iter != print_diff.end()) {
update_apply_status(object->invalidate_step(posSlice)); update_apply_status(object->invalidate_step(posSlice));
} }
} }

View file

@ -1328,13 +1328,13 @@ void PrintConfigDef::init_fff_params()
def->min = 0; def->min = 0;
def->set_default_value(new ConfigOptionFloat(0.2)); def->set_default_value(new ConfigOptionFloat(0.2));
def = this->add("adaptive_layer_height", coBool); //def = this->add("adaptive_layer_height", coBool);
def->label = L("Adaptive layer height"); //def->label = L("Adaptive layer height");
def->category = L("Quality"); //def->category = L("Quality");
def->tooltip = L("Enabling this option means the height of every layer except the first will be automatically calculated " //def->tooltip = L("Enabling this option means the height of every layer except the first will be automatically calculated "
"during slicing according to the slope of the models surface.\n" // "during slicing according to the slope of the models surface.\n"
"Note that this option only takes effect if no prime tower is generated in current plate."); // "Note that this option only takes effect if no prime tower is generated in current plate.");
def->set_default_value(new ConfigOptionBool(0)); //def->set_default_value(new ConfigOptionBool(0));
def = this->add("initial_layer_speed", coFloat); def = this->add("initial_layer_speed", coFloat);
def->label = L("Initial layer"); def->label = L("Initial layer");
@ -3720,7 +3720,7 @@ void PrintConfigDef::handle_legacy(t_config_option_key &opt_key, std::string &va
"support_bottom_z_distance", "support_closing_radius", "support_bottom_z_distance", "support_closing_radius",
"remove_freq_sweep", "remove_bed_leveling", "remove_extrusion_calibration", "remove_freq_sweep", "remove_bed_leveling", "remove_extrusion_calibration",
"support_transition_line_width", "support_transition_speed", "bed_temperature", "bed_temperature_initial_layer", "support_transition_line_width", "support_transition_speed", "bed_temperature", "bed_temperature_initial_layer",
"can_switch_nozzle_type", "can_add_auxiliary_fan", "extra_flush_volume", "spaghetti_detector", "adaptive_layer_height" "can_switch_nozzle_type", "can_add_auxiliary_fan", "extra_flush_volume", "spaghetti_detector"/*, "adaptive_layer_height"*/
}; };
if (ignore.find(opt_key) != ignore.end()) { if (ignore.find(opt_key) != ignore.end()) {
@ -3826,7 +3826,7 @@ void DynamicPrintConfig::normalize_fdm(int used_filaments)
ConfigOptionBool* ept_opt = this->option<ConfigOptionBool>("enable_prime_tower"); ConfigOptionBool* ept_opt = this->option<ConfigOptionBool>("enable_prime_tower");
if (used_filaments > 0 && ept_opt != nullptr) { if (used_filaments > 0 && ept_opt != nullptr) {
ConfigOptionBool* islh_opt = this->option<ConfigOptionBool>("independent_support_layer_height", true); ConfigOptionBool* islh_opt = this->option<ConfigOptionBool>("independent_support_layer_height", true);
ConfigOptionBool* alh_opt = this->option<ConfigOptionBool>("adaptive_layer_height"); //ConfigOptionBool* alh_opt = this->option<ConfigOptionBool>("adaptive_layer_height");
ConfigOptionEnum<PrintSequence>* ps_opt = this->option<ConfigOptionEnum<PrintSequence>>("print_sequence"); ConfigOptionEnum<PrintSequence>* ps_opt = this->option<ConfigOptionEnum<PrintSequence>>("print_sequence");
ConfigOptionEnum<TimelapseType>* timelapse_opt = this->option<ConfigOptionEnum<TimelapseType>>("timelapse_type"); ConfigOptionEnum<TimelapseType>* timelapse_opt = this->option<ConfigOptionEnum<TimelapseType>>("timelapse_type");
@ -3838,8 +3838,8 @@ void DynamicPrintConfig::normalize_fdm(int used_filaments)
if (ept_opt->value) { if (ept_opt->value) {
if (islh_opt) if (islh_opt)
islh_opt->value = false; islh_opt->value = false;
if (alh_opt) //if (alh_opt)
alh_opt->value = false; // alh_opt->value = false;
} }
else { else {
if (islh_opt) if (islh_opt)
@ -3901,7 +3901,7 @@ t_config_option_keys DynamicPrintConfig::normalize_fdm_2(int used_filaments)
ConfigOptionBool* ept_opt = this->option<ConfigOptionBool>("enable_prime_tower"); ConfigOptionBool* ept_opt = this->option<ConfigOptionBool>("enable_prime_tower");
if (used_filaments > 0 && ept_opt != nullptr) { if (used_filaments > 0 && ept_opt != nullptr) {
ConfigOptionBool* islh_opt = this->option<ConfigOptionBool>("independent_support_layer_height", true); ConfigOptionBool* islh_opt = this->option<ConfigOptionBool>("independent_support_layer_height", true);
ConfigOptionBool* alh_opt = this->option<ConfigOptionBool>("adaptive_layer_height"); //ConfigOptionBool* alh_opt = this->option<ConfigOptionBool>("adaptive_layer_height");
ConfigOptionEnum<PrintSequence>* ps_opt = this->option<ConfigOptionEnum<PrintSequence>>("print_sequence"); ConfigOptionEnum<PrintSequence>* ps_opt = this->option<ConfigOptionEnum<PrintSequence>>("print_sequence");
ConfigOptionEnum<TimelapseType>* timelapse_opt = this->option<ConfigOptionEnum<TimelapseType>>("timelapse_type"); ConfigOptionEnum<TimelapseType>* timelapse_opt = this->option<ConfigOptionEnum<TimelapseType>>("timelapse_type");
@ -3922,13 +3922,13 @@ t_config_option_keys DynamicPrintConfig::normalize_fdm_2(int used_filaments)
} }
//islh_opt->value = false; //islh_opt->value = false;
} }
if (alh_opt) { //if (alh_opt) {
if (alh_opt->value) { // if (alh_opt->value) {
alh_opt->value = false; // alh_opt->value = false;
changed_keys.push_back("adaptive_layer_height"); // changed_keys.push_back("adaptive_layer_height");
} // }
//alh_opt->value = false; // //alh_opt->value = false;
} //}
} }
else { else {
if (islh_opt) { if (islh_opt) {

View file

@ -654,7 +654,7 @@ PRINT_CONFIG_CLASS_DEFINE(
((ConfigOptionInt, tree_support_wall_count)) ((ConfigOptionInt, tree_support_wall_count))
((ConfigOptionBool, tree_support_with_infill)) ((ConfigOptionBool, tree_support_with_infill))
((ConfigOptionBool, detect_narrow_internal_solid_infill)) ((ConfigOptionBool, detect_narrow_internal_solid_infill))
((ConfigOptionBool, adaptive_layer_height)) // ((ConfigOptionBool, adaptive_layer_height))
((ConfigOptionFloat, support_bottom_interface_spacing)) ((ConfigOptionFloat, support_bottom_interface_spacing))
) )

View file

@ -447,7 +447,7 @@ 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) void ConfigManipulation::apply_null_fff_config(DynamicPrintConfig *config, std::vector<std::string> const &keys, std::map<ObjectBase *, ModelConfig *> const &configs)
{ {
for (auto &k : keys) { 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")
config->set_key_value(k, new ConfigOptionBool(true)); config->set_key_value(k, new ConfigOptionBool(true));
else if (k == "wall_loops") else if (k == "wall_loops")
config->set_key_value(k, new ConfigOptionInt(0)); config->set_key_value(k, new ConfigOptionInt(0));