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.
This commit is contained in:
Lukáš Hejl 2023-08-10 11:20:51 +02:00
parent 9bce0fcf9b
commit a469f6aaa1
3 changed files with 11 additions and 5 deletions

View File

@ -1275,10 +1275,11 @@ static void cut_segmented_layers(const std::vector<ExPolygons> &input_exp
const std::function<void()> &throw_on_cancel_callback)
{
BOOST_LOG_TRIVIAL(debug) << "MMU segmentation - cutting segmented layers in parallel - begin";
tbb::parallel_for(tbb::blocked_range<size_t>(0, segmented_regions.size()),[&segmented_regions, &input_expolygons, &cut_width, &interlocking_depth, &throw_on_cancel_callback](const tbb::blocked_range<size_t>& 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<size_t>(0, segmented_regions.size()),[&segmented_regions, &input_expolygons, &cut_width, &interlocking_cut_width, &throw_on_cancel_callback](const tbb::blocked_range<size_t>& 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<ExPolygons> segmented_regions_cuts(num_extruders_plus_one); // Indexed by extruder_id
@ -1895,7 +1896,7 @@ std::vector<std::vector<ExPolygons>> 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();
}

View File

@ -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");

View File

@ -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"));