From a1c3a9901174c600473677aac63b338cd49c6889 Mon Sep 17 00:00:00 2001 From: "zhimin.zeng" Date: Tue, 27 Aug 2024 11:28:36 +0800 Subject: [PATCH] FIX: crash when top_shell_layer = 0 and is sinking github: 4673 Change-Id: I260b48e833f47383c582f813d979a4fdc2926dd2 --- src/libslic3r/MultiMaterialSegmentation.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/libslic3r/MultiMaterialSegmentation.cpp b/src/libslic3r/MultiMaterialSegmentation.cpp index cd2bc0061..eb6d80389 100644 --- a/src/libslic3r/MultiMaterialSegmentation.cpp +++ b/src/libslic3r/MultiMaterialSegmentation.cpp @@ -1365,14 +1365,17 @@ static inline std::vector> mmu_segmentation_top_and_bott Slic3r::append(zs_sinking, zs); slice_mesh_slabs(painted, zs_sinking, volume_trafo, max_top_layers > 0 ? &top : nullptr, max_bottom_layers > 0 ? &bottom : nullptr, throw_on_cancel_callback); - MeshSlicingParams slicing_params; - slicing_params.trafo = volume_trafo; - Polygons bottom_slice = slice_mesh(painted, zs[0], slicing_params); + if (top.size() > 0) + top.erase(top.begin()); - top.erase(top.begin()); - bottom.erase(bottom.begin()); + if (bottom.size() > 1) { + MeshSlicingParams slicing_params; + slicing_params.trafo = volume_trafo; + Polygons bottom_slice = slice_mesh(painted, zs[0], slicing_params); - bottom[0] = union_(bottom[0], bottom_slice); + bottom.erase(bottom.begin()); + bottom[0] = union_(bottom[0], bottom_slice); + } } else slice_mesh_slabs(painted, zs, volume_trafo, max_top_layers > 0 ? &top : nullptr, max_bottom_layers > 0 ? &bottom : nullptr, throw_on_cancel_callback); auto merge = [](std::vector &&src, std::vector &dst) {