From 32399c9ff2c134034ce1da2116a2f16cc546ef9f Mon Sep 17 00:00:00 2001 From: "zhimin.zeng" Date: Mon, 19 Feb 2024 12:08:46 +0800 Subject: [PATCH] FIX: unexpected layers in multi color print github: 3131 Change-Id: I2a42e3bbd2247fbc0957022e1baae43c9375a8fb --- src/libslic3r/MultiMaterialSegmentation.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/libslic3r/MultiMaterialSegmentation.cpp b/src/libslic3r/MultiMaterialSegmentation.cpp index e7e232962..7e08a0ca9 100644 --- a/src/libslic3r/MultiMaterialSegmentation.cpp +++ b/src/libslic3r/MultiMaterialSegmentation.cpp @@ -1525,6 +1525,20 @@ static inline std::vector> mmu_segmentation_top_and_bott } #endif // MMU_SEGMENTATION_DEBUG_TOP_BOTTOM + // When the upper surface of an object is occluded, it should no longer be considered the upper surface + { + for (size_t extruder_idx = 0; extruder_idx < num_extruders; ++extruder_idx) { + for (size_t layer_idx = 0; layer_idx < layers.size(); ++layer_idx) { + if (!top_raw[extruder_idx].empty() && !top_raw[extruder_idx][layer_idx].empty() && layer_idx + 1 < layers.size()) { + top_raw[extruder_idx][layer_idx] = diff(top_raw[extruder_idx][layer_idx], input_expolygons[layer_idx + 1]); + } + if (!bottom_raw[extruder_idx].empty() && !bottom_raw[extruder_idx][layer_idx].empty() && layer_idx > 0) { + bottom_raw[extruder_idx][layer_idx] = diff(bottom_raw[extruder_idx][layer_idx], input_expolygons[layer_idx - 1]); + } + } + } + } + std::vector> triangles_by_color_bottom(num_extruders); std::vector> triangles_by_color_top(num_extruders); triangles_by_color_bottom.assign(num_extruders, std::vector(num_layers * 2));