SPE-2484: Restrict interlocking beam width parameter to meaningful values.

This commit is contained in:
Lukáš Hejl 2025-02-13 10:18:17 +01:00 committed by Lukas Matena
parent 3017ea0051
commit 458efcc371
4 changed files with 17 additions and 15 deletions

View File

@ -23,18 +23,20 @@ template<> struct hash<Slic3r::GridPoint3>
namespace Slic3r { namespace Slic3r {
void InterlockingGenerator::generate_interlocking_structure(PrintObject* print_object) void InterlockingGenerator::generate_interlocking_structure(PrintObject &print_object)
{ {
const auto& config = print_object->config(); const PrintObjectConfig &config = print_object.config();
if (!config.interlocking_beam) { if (!config.interlocking_beam) {
return; return;
} }
const float rotation = Geometry::deg2rad(config.interlocking_orientation.value); const std::vector<double> &nozzle_diameters = print_object.print()->config().nozzle_diameter.values;
const coord_t beam_layer_count = config.interlocking_beam_layer_count; double min_nozzle_diameter = *std::min_element(nozzle_diameters.begin(), nozzle_diameters.end());
const int interface_depth = config.interlocking_depth; const float rotation = Geometry::deg2rad(config.interlocking_orientation.value);
const int boundary_avoidance = config.interlocking_boundary_avoidance; const coord_t beam_layer_count = config.interlocking_beam_layer_count;
const coord_t beam_width = scaled(config.interlocking_beam_width.value); const int interface_depth = config.interlocking_depth;
const int boundary_avoidance = config.interlocking_boundary_avoidance;
const coord_t beam_width = scaled<coord_t>(std::max(min_nozzle_diameter, config.interlocking_beam_width.value));
const DilationKernel interface_dilation(GridPoint3(interface_depth, interface_depth, interface_depth), DilationKernel::Type::PRISM); const DilationKernel interface_dilation(GridPoint3(interface_depth, interface_depth, interface_depth), DilationKernel::Type::PRISM);
@ -44,18 +46,18 @@ void InterlockingGenerator::generate_interlocking_structure(PrintObject* print_o
const coord_t cell_width = beam_width + beam_width; const coord_t cell_width = beam_width + beam_width;
const Vec3crd cell_size(cell_width, cell_width, 2 * beam_layer_count); const Vec3crd cell_size(cell_width, cell_width, 2 * beam_layer_count);
for (size_t region_a_index = 0; region_a_index < print_object->num_printing_regions(); region_a_index++) { for (size_t region_a_index = 0; region_a_index < print_object.num_printing_regions(); region_a_index++) {
const PrintRegion& region_a = print_object->printing_region(region_a_index); const PrintRegion& region_a = print_object.printing_region(region_a_index);
const auto extruder_nr_a = region_a.extruder(FlowRole::frExternalPerimeter); const auto extruder_nr_a = region_a.extruder(FlowRole::frExternalPerimeter);
for (size_t region_b_index = region_a_index + 1; region_b_index < print_object->num_printing_regions(); region_b_index++) { for (size_t region_b_index = region_a_index + 1; region_b_index < print_object.num_printing_regions(); region_b_index++) {
const PrintRegion& region_b = print_object->printing_region(region_b_index); const PrintRegion& region_b = print_object.printing_region(region_b_index);
const auto extruder_nr_b = region_b.extruder(FlowRole::frExternalPerimeter); const auto extruder_nr_b = region_b.extruder(FlowRole::frExternalPerimeter);
if (extruder_nr_a == extruder_nr_b) { if (extruder_nr_a == extruder_nr_b) {
continue; continue;
} }
InterlockingGenerator gen(*print_object, region_a_index, region_b_index, beam_width, boundary_avoidance, rotation, cell_size, beam_layer_count, InterlockingGenerator gen(print_object, region_a_index, region_b_index, beam_width, boundary_avoidance, rotation, cell_size, beam_layer_count,
interface_dilation, air_dilation, air_filtering); interface_dilation, air_dilation, air_filtering);
gen.generateInterlockingStructure(); gen.generateInterlockingStructure();
} }

View File

@ -45,7 +45,7 @@ public:
/*! /*!
* Generate an interlocking structure between each two adjacent meshes. * Generate an interlocking structure between each two adjacent meshes.
*/ */
static void generate_interlocking_structure(PrintObject* print_object); static void generate_interlocking_structure(PrintObject &print_object);
private: private:
/*! /*!

View File

@ -2011,7 +2011,7 @@ void PrintConfigDef::init_fff_params()
def->label = L("Interlocking beam width"); def->label = L("Interlocking beam width");
def->tooltip = L("The width of the interlocking structure beams."); def->tooltip = L("The width of the interlocking structure beams.");
def->sidetext = L("mm"); def->sidetext = L("mm");
def->min = 0.01; def->min = 0.1f;
def->category = L("Advanced"); def->category = L("Advanced");
def->mode = comAdvanced; def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloat(0.8)); def->set_default_value(new ConfigOptionFloat(0.8));

View File

@ -926,7 +926,7 @@ void PrintObject::slice_volumes()
if (m_config.interlocking_beam) { if (m_config.interlocking_beam) {
BOOST_LOG_TRIVIAL(debug) << "Slicing volumes - Applying multi-material interlocking"; BOOST_LOG_TRIVIAL(debug) << "Slicing volumes - Applying multi-material interlocking";
InterlockingGenerator::generate_interlocking_structure(this); InterlockingGenerator::generate_interlocking_structure(*this);
m_print->throw_if_canceled(); m_print->throw_if_canceled();
} }