mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-12 15:19:03 +08:00
Fix of #8436 - Crash in the lightning infill when some region has zero infill density.
This commit is contained in:
parent
7783915a34
commit
5d557ed32f
@ -26,9 +26,9 @@ void GeneratorDeleter::operator()(Generator *p) {
|
|||||||
delete p;
|
delete p;
|
||||||
}
|
}
|
||||||
|
|
||||||
GeneratorPtr build_generator(const PrintObject &print_object, const std::function<void()> &throw_on_cancel_callback)
|
GeneratorPtr build_generator(const PrintObject &print_object, const coordf_t fill_density, const std::function<void()> &throw_on_cancel_callback)
|
||||||
{
|
{
|
||||||
return GeneratorPtr(new Generator(print_object, throw_on_cancel_callback));
|
return GeneratorPtr(new Generator(print_object, fill_density, throw_on_cancel_callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Slic3r::FillAdaptive
|
} // namespace Slic3r::FillAdaptive
|
||||||
|
@ -14,7 +14,7 @@ class Generator;
|
|||||||
struct GeneratorDeleter { void operator()(Generator *p); };
|
struct GeneratorDeleter { void operator()(Generator *p); };
|
||||||
using GeneratorPtr = std::unique_ptr<Generator, GeneratorDeleter>;
|
using GeneratorPtr = std::unique_ptr<Generator, GeneratorDeleter>;
|
||||||
|
|
||||||
GeneratorPtr build_generator(const PrintObject &print_object, const std::function<void()> &throw_on_cancel_callback);
|
GeneratorPtr build_generator(const PrintObject &print_object, const coordf_t fill_density, const std::function<void()> &throw_on_cancel_callback);
|
||||||
|
|
||||||
class Filler : public Slic3r::Fill
|
class Filler : public Slic3r::Fill
|
||||||
{
|
{
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
namespace Slic3r::FillLightning {
|
namespace Slic3r::FillLightning {
|
||||||
|
|
||||||
Generator::Generator(const PrintObject &print_object, const std::function<void()> &throw_on_cancel_callback)
|
Generator::Generator(const PrintObject &print_object, const coordf_t fill_density, const std::function<void()> &throw_on_cancel_callback)
|
||||||
{
|
{
|
||||||
const PrintConfig &print_config = print_object.print()->config();
|
const PrintConfig &print_config = print_object.print()->config();
|
||||||
const PrintObjectConfig &object_config = print_object.config();
|
const PrintObjectConfig &object_config = print_object.config();
|
||||||
@ -39,7 +39,7 @@ Generator::Generator(const PrintObject &print_object, const std::function<void()
|
|||||||
m_infill_extrusion_width = scaled<float>(region_config.infill_extrusion_width.percent ? default_infill_extrusion_width * 0.01 * region_config.infill_extrusion_width :
|
m_infill_extrusion_width = scaled<float>(region_config.infill_extrusion_width.percent ? default_infill_extrusion_width * 0.01 * region_config.infill_extrusion_width :
|
||||||
region_config.infill_extrusion_width != 0. ? region_config.infill_extrusion_width :
|
region_config.infill_extrusion_width != 0. ? region_config.infill_extrusion_width :
|
||||||
default_infill_extrusion_width);
|
default_infill_extrusion_width);
|
||||||
m_supporting_radius = coord_t(m_infill_extrusion_width) * 100 / coord_t(region_config.fill_density.value);
|
m_supporting_radius = coord_t(m_infill_extrusion_width * 100. / fill_density);
|
||||||
|
|
||||||
const double lightning_infill_overhang_angle = M_PI / 4; // 45 degrees
|
const double lightning_infill_overhang_angle = M_PI / 4; // 45 degrees
|
||||||
const double lightning_infill_prune_angle = M_PI / 4; // 45 degrees
|
const double lightning_infill_prune_angle = M_PI / 4; // 45 degrees
|
||||||
|
@ -44,7 +44,7 @@ public:
|
|||||||
* Lightning Infill for the infill areas in that mesh. The infill areas must
|
* Lightning Infill for the infill areas in that mesh. The infill areas must
|
||||||
* already be calculated at this point.
|
* already be calculated at this point.
|
||||||
*/
|
*/
|
||||||
explicit Generator(const PrintObject &print_object, const std::function<void()> &throw_on_cancel_callback);
|
explicit Generator(const PrintObject &print_object, const coordf_t fill_density, const std::function<void()> &throw_on_cancel_callback);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Get a tree of paths generated for a certain layer of the mesh.
|
* Get a tree of paths generated for a certain layer of the mesh.
|
||||||
|
@ -457,14 +457,20 @@ std::pair<FillAdaptive::OctreePtr, FillAdaptive::OctreePtr> PrintObject::prepare
|
|||||||
|
|
||||||
FillLightning::GeneratorPtr PrintObject::prepare_lightning_infill_data()
|
FillLightning::GeneratorPtr PrintObject::prepare_lightning_infill_data()
|
||||||
{
|
{
|
||||||
bool has_lightning_infill = false;
|
bool has_lightning_infill = false;
|
||||||
|
coordf_t lightning_density = 0.;
|
||||||
|
size_t lightning_cnt = 0;
|
||||||
for (size_t region_id = 0; region_id < this->num_printing_regions(); ++region_id)
|
for (size_t region_id = 0; region_id < this->num_printing_regions(); ++region_id)
|
||||||
if (const PrintRegionConfig &config = this->printing_region(region_id).config(); config.fill_density > 0 && config.fill_pattern == ipLightning) {
|
if (const PrintRegionConfig &config = this->printing_region(region_id).config(); config.fill_density > 0 && config.fill_pattern == ipLightning) {
|
||||||
has_lightning_infill = true;
|
has_lightning_infill = true;
|
||||||
break;
|
lightning_density += config.fill_density;
|
||||||
|
++lightning_cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
return has_lightning_infill ? FillLightning::build_generator(std::as_const(*this), [this]() -> void { this->throw_if_canceled(); }) : FillLightning::GeneratorPtr();
|
if (has_lightning_infill)
|
||||||
|
lightning_density /= coordf_t(lightning_cnt);
|
||||||
|
|
||||||
|
return has_lightning_infill ? FillLightning::build_generator(std::as_const(*this), lightning_density, [this]() -> void { this->throw_if_canceled(); }) : FillLightning::GeneratorPtr();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintObject::clear_layers()
|
void PrintObject::clear_layers()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user