From a469f6aaa1a1e408d110f7b05d3bd84f7faefc89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hejl?= Date: Thu, 10 Aug 2023 11:20:51 +0200 Subject: [PATCH] SPE-1796: Made interlocking to be applied as offset computed from mmu_segmented_region_max_width. Also, interlocking input is disabled when mmu_segmented_region_max_width is equal to zero. --- src/libslic3r/MultiMaterialSegmentation.cpp | 7 ++++--- src/libslic3r/PrintConfig.cpp | 6 ++++-- src/slic3r/GUI/ConfigManipulation.cpp | 3 +++ 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/libslic3r/MultiMaterialSegmentation.cpp b/src/libslic3r/MultiMaterialSegmentation.cpp index f2c79fcc21..7b986d6afc 100644 --- a/src/libslic3r/MultiMaterialSegmentation.cpp +++ b/src/libslic3r/MultiMaterialSegmentation.cpp @@ -1275,10 +1275,11 @@ static void cut_segmented_layers(const std::vector &input_exp const std::function &throw_on_cancel_callback) { BOOST_LOG_TRIVIAL(debug) << "MMU segmentation - cutting segmented layers in parallel - begin"; - tbb::parallel_for(tbb::blocked_range(0, segmented_regions.size()),[&segmented_regions, &input_expolygons, &cut_width, &interlocking_depth, &throw_on_cancel_callback](const tbb::blocked_range& range) { + const float interlocking_cut_width = interlocking_depth > 0.f ? std::max(cut_width - interlocking_depth, 0.f) : 0.f; + tbb::parallel_for(tbb::blocked_range(0, segmented_regions.size()),[&segmented_regions, &input_expolygons, &cut_width, &interlocking_cut_width, &throw_on_cancel_callback](const tbb::blocked_range& range) { for (size_t layer_idx = range.begin(); layer_idx < range.end(); ++layer_idx) { throw_on_cancel_callback(); - const float region_cut_width = (layer_idx % 2 == 0 && interlocking_depth != 0.f) ? interlocking_depth : cut_width; + const float region_cut_width = (layer_idx % 2 == 0 && interlocking_cut_width > 0.f) ? interlocking_cut_width : cut_width; const size_t num_extruders_plus_one = segmented_regions[layer_idx].size(); if (region_cut_width > 0.f) { std::vector segmented_regions_cuts(num_extruders_plus_one); // Indexed by extruder_id @@ -1895,7 +1896,7 @@ std::vector> multi_material_segmentation_by_painting(con BOOST_LOG_TRIVIAL(debug) << "MMU segmentation - layers segmentation in parallel - end"; throw_on_cancel_callback(); - if (auto max_width = print_object.config().mmu_segmented_region_max_width, interlocking_depth = print_object.config().mmu_segmented_region_interlocking_depth; max_width > 0.f || interlocking_depth > 0.f) { + if (auto max_width = print_object.config().mmu_segmented_region_max_width, interlocking_depth = print_object.config().mmu_segmented_region_interlocking_depth; max_width > 0.f) { cut_segmented_layers(input_expolygons, segmented_regions, float(scale_(max_width)), float(scale_(interlocking_depth)), throw_on_cancel_callback); throw_on_cancel_callback(); } diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 2ebe5d4e08..4b17e2c3d5 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -1622,8 +1622,10 @@ void PrintConfigDef::init_fff_params() def->set_default_value(new ConfigOptionFloat(0.)); def = this->add("mmu_segmented_region_interlocking_depth", coFloat); - def->label = L("Maximum interlocking depth of a segmented region"); - def->tooltip = L("Maximum interlocking depth of a segmented region. Zero disables this feature."); + def->label = L("Interlocking depth of a segmented region"); + def->tooltip = L("Interlocking depth of a segmented region. It will be ignored if " + "\"mmu_segmented_region_max_width\" is zero or if \"mmu_segmented_region_interlocking_depth\"" + "is bigger then \"mmu_segmented_region_max_width\". Zero disables this feature."); def->sidetext = L("mm (zero to disable)"); def->min = 0; def->category = L("Advanced"); diff --git a/src/slic3r/GUI/ConfigManipulation.cpp b/src/slic3r/GUI/ConfigManipulation.cpp index f645e8a0dd..8126576b79 100644 --- a/src/slic3r/GUI/ConfigManipulation.cpp +++ b/src/slic3r/GUI/ConfigManipulation.cpp @@ -324,6 +324,9 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig* config) "wipe_tower_extra_spacing", "wipe_tower_bridging", "wipe_tower_no_sparse_layers", "single_extruder_multi_material_priming" }) toggle_field(el, have_wipe_tower); + bool have_non_zero_mmu_segmented_region_max_width = config->opt_float("mmu_segmented_region_max_width") > 0.; + toggle_field("mmu_segmented_region_interlocking_depth", have_non_zero_mmu_segmented_region_max_width); + toggle_field("avoid_crossing_curled_overhangs", !config->opt_bool("avoid_crossing_perimeters")); toggle_field("avoid_crossing_perimeters", !config->opt_bool("avoid_crossing_curled_overhangs"));