Skip to content

Commit

Permalink
Organic supports: Fixing crashes with invalid tip diameter or branch
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bubnikv committed Sep 1, 2023
1 parent f32859c commit 96b3ae8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/libslic3r/Print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ std::string Print::validate(std::vector<std::string>* 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) {
Expand Down Expand Up @@ -723,6 +723,17 @@ std::string Print::validate(std::vector<std::string>* 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?
Expand Down
6 changes: 5 additions & 1 deletion src/libslic3r/Support/TreeSupportCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<coord_t>::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<coord_t>::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)),
Expand All @@ -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) {
Expand Down

0 comments on commit 96b3ae8

Please sign in to comment.