[Bug fix] Fixes lightning infill with sparse infill width set to 0 causes "divide by zero" fatal error (#3592)

* Fix issue #3567 - Lightning infill with sparse infill width set to 0 causes "divide by zero" fatal error

* Merge branch 'SoftFever:main' into Fix-#3567---Lightning-infill-with-sparse-infill-width-set-to-0-causes-divide-by-zero-fatal-error

* Merge branch 'main' into Fix-#3567---Lightning-infill-with-sparse-infill-width-set-to-0-causes-divide-by-zero-fatal-error
This commit is contained in:
Ioannis Giannakas 2024-01-14 17:38:34 +02:00 committed by GitHub
parent c26a73a1ca
commit a996188e38
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -76,6 +76,16 @@ Generator::Generator(const PrintObject &print_object, const std::function<void()
const double layer_thickness = scaled<double>(object_config.layer_height.value);
m_infill_extrusion_width = scaled<float>(region_config.sparse_infill_line_width.get_abs_value(max_nozzle_diameter));
// Orca: fix lightning infill divide by zero when infill line width is set to 0.
// firstly attempt to set it to the default line width. If that is not provided either, set it to a sane default
// based on the nozzle diameter.
if (m_infill_extrusion_width < EPSILON)
m_infill_extrusion_width = scaled<float>(
object_config.line_width.get_abs_value(max_nozzle_diameter) < EPSILON ?
default_infill_extrusion_width :
object_config.line_width.get_abs_value(max_nozzle_diameter)
);
m_supporting_radius = coord_t(m_infill_extrusion_width) * 100 / region_config.sparse_infill_density;
const double lightning_infill_overhang_angle = M_PI / 4; // 45 degrees
@ -102,6 +112,15 @@ Generator::Generator(PrintObject* m_object, std::vector<Polygons>& contours, std
const double layer_thickness = scaled<double>(object_config.layer_height.value);
m_infill_extrusion_width = scaled<float>(region_config.sparse_infill_line_width.get_abs_value(max_nozzle_diameter));
// Orca: fix lightning infill divide by zero when infill line width is set to 0.
// firstly attempt to set it to the default line width. If that is not provided either, set it to a sane default
// based on the nozzle diameter.
if (m_infill_extrusion_width < EPSILON)
m_infill_extrusion_width = scaled<float>(
object_config.line_width.get_abs_value(max_nozzle_diameter) < EPSILON ?
default_infill_extrusion_width :
object_config.line_width.get_abs_value(max_nozzle_diameter)
);
//m_supporting_radius: against to the density of lightning, failures may happen if set to high density
//higher density lightning makes support harder, more time-consuming on computing and printing, but more reliable on supporting overhangs
//lower density lightning performs opposite