From 96b3ae85013ac363cd1c3e98ec6b7938aeacf46d Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Fri, 1 Sep 2023 15:02:03 +0200 Subject: [PATCH] Organic supports: Fixing crashes with invalid tip diameter or branch diameter. Fixes SPE-1451 GH#9555 Fixed by reporting invalid combination of support extrusion width and tip + branch diameter: Organic support tree tip diameter must not be smaller than support material extrusion width. Organic support branch diameter must not be smaller than 2x support material extrusion width. Organic support branch diameter must not be smaller than support tree tip diameter. --- src/libslic3r/Print.cpp | 13 ++++++++++++- src/libslic3r/Support/TreeSupportCommon.cpp | 6 +++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index f0d4d0aac77..8ac58aad8d2 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -689,7 +689,7 @@ std::string Print::validate(std::vector* warnings) const // double extrusion_width_min = config.get_abs_value(opt_key, min_nozzle_diameter); // double extrusion_width_max = config.get_abs_value(opt_key, max_nozzle_diameter); double extrusion_width_min = config.get_abs_value(opt_key, layer_height); - double extrusion_width_max = config.get_abs_value(opt_key, layer_height); + double extrusion_width_max = extrusion_width_min; if (extrusion_width_min == 0) { // Default "auto-generated" extrusion width is always valid. } else if (extrusion_width_min <= layer_height) { @@ -723,6 +723,17 @@ std::string Print::validate(std::vector* warnings) const "(both support_material_extruder and support_material_interface_extruder need to be set to 0)."); } } + if (object->config().support_material_style == smsOrganic) { + float extrusion_width = std::min( + support_material_flow(object).width(), + support_material_interface_flow(object).width()); + if (object->config().support_tree_tip_diameter < extrusion_width - EPSILON) + return _u8L("Organic support tree tip diameter must not be smaller than support material extrusion width."); + if (object->config().support_tree_branch_diameter < 2. * extrusion_width - EPSILON) + return _u8L("Organic support branch diameter must not be smaller than 2x support material extrusion width."); + if (object->config().support_tree_branch_diameter < object->config().support_tree_tip_diameter) + return _u8L("Organic support branch diameter must not be smaller than support tree tip diameter."); + } } // Do we have custom support data that would not be used? diff --git a/src/libslic3r/Support/TreeSupportCommon.cpp b/src/libslic3r/Support/TreeSupportCommon.cpp index f41be11bdf3..711a91f0f01 100644 --- a/src/libslic3r/Support/TreeSupportCommon.cpp +++ b/src/libslic3r/Support/TreeSupportCommon.cpp @@ -89,7 +89,8 @@ TreeSupportSettings::TreeSupportSettings(const TreeSupportMeshGroupSettings &mes maximum_move_distance((mesh_group_settings.support_tree_angle < M_PI / 2.) ? (coord_t)(tan(mesh_group_settings.support_tree_angle) * layer_height) : std::numeric_limits::max()), maximum_move_distance_slow((mesh_group_settings.support_tree_angle_slow < M_PI / 2.) ? (coord_t)(tan(mesh_group_settings.support_tree_angle_slow) * layer_height) : std::numeric_limits::max()), support_bottom_layers(mesh_group_settings.support_bottom_enable ? (mesh_group_settings.support_bottom_height + layer_height / 2) / layer_height : 0), - tip_layers(std::max((branch_radius - min_radius) / (support_line_width / 3), branch_radius / layer_height)), // Ensure lines always stack nicely even if layer height is large + // Ensure lines always stack nicely even if layer height is large. + tip_layers(std::max((branch_radius - min_radius) / (support_line_width / 3), branch_radius / layer_height)), branch_radius_increase_per_layer(tan(mesh_group_settings.support_tree_branch_diameter_angle) * layer_height), max_to_model_radius_increase(mesh_group_settings.support_tree_max_diameter_increase_by_merges_when_support_to_model / 2), min_dtt_to_model(round_up_divide(mesh_group_settings.support_tree_min_height_to_model, layer_height)), @@ -116,6 +117,9 @@ TreeSupportSettings::TreeSupportSettings(const TreeSupportMeshGroupSettings &mes settings(mesh_group_settings), min_feature_size(mesh_group_settings.min_feature_size) { + // At least one tip layer must be defined. + assert(tip_layers > 0); + layer_start_bp_radius = (bp_radius - branch_radius) / bp_radius_increase_per_layer; if (TreeSupportSettings::soluble) {