From e1d1d3e8ca58b156fd05ce0db5a087c654252f90 Mon Sep 17 00:00:00 2001 From: "zhimin.zeng" Date: Tue, 11 Jun 2024 15:33:19 +0800 Subject: [PATCH] FIX: support more than 16 extruders jira: none Change-Id: I169f672b99088b0a0a0132265d958e3239051744 --- src/libslic3r/Model.hpp | 18 ++++++++++++++++- src/libslic3r/TriangleSelector.cpp | 31 ++++++++++++++++++++++-------- src/slic3r/GUI/Plater.cpp | 6 +++--- 3 files changed, 43 insertions(+), 12 deletions(-) diff --git a/src/libslic3r/Model.hpp b/src/libslic3r/Model.hpp index 71a563320..d377276bd 100644 --- a/src/libslic3r/Model.hpp +++ b/src/libslic3r/Model.hpp @@ -728,7 +728,23 @@ enum class EnforcerBlockerType : int8_t { Extruder14, Extruder15, Extruder16, - ExtruderMax = Extruder16 + Extruder17, + Extruder18, + Extruder19, + Extruder20, + Extruder21, + Extruder22, + Extruder23, + Extruder24, + Extruder25, + Extruder26, + Extruder27, + Extruder28, + Extruder29, + Extruder30, + Extruder31, + Extruder32, + ExtruderMax = Extruder32 }; enum class ConversionType : int { diff --git a/src/libslic3r/TriangleSelector.cpp b/src/libslic3r/TriangleSelector.cpp index addf3d73e..5f2b3fcb1 100644 --- a/src/libslic3r/TriangleSelector.cpp +++ b/src/libslic3r/TriangleSelector.cpp @@ -1667,14 +1667,15 @@ std::pair>, std::vector> TriangleSelector: // In case this is leaf, we better save information about its state. int n = int(tr.get_state()); if (n >= 3) { - assert(n <= 16); - if (n <= 16) { - // Store "11" plus 4 bits of (n-3). - data.second.insert(data.second.end(), { true, true }); - n -= 3; - for (size_t bit_idx = 0; bit_idx < 4; ++bit_idx) - data.second.push_back(n & (uint64_t(0b0001) << bit_idx)); + data.second.insert(data.second.end(), {true, true}); + n -= 3; + while (n >= 16) { + data.second.insert(data.second.end(), {true, true, true, true}); + n -= 16; } + + for (size_t bit_idx = 0; bit_idx < 4; ++bit_idx) + data.second.push_back(n & (uint64_t(0b0001) << bit_idx)); } else { // Simple case, compatible with PrusaSlicer 2.3.1 and older for storing paint on supports and seams. // Store 2 bits of n. @@ -1746,7 +1747,21 @@ void TriangleSelector::deserialize(const std::pair> 2); + auto state = EnforcerBlockerType::NONE; + if (!is_split) { + if ((code & 0b1100) == 0b1100){ + int next_code = next_nibble(); + int num = 0; + while (next_code == 0b1111) { + num++; + next_code = next_nibble(); + } + state = EnforcerBlockerType(next_code + 16 * num + (code >> 2)); + } + else { + state = EnforcerBlockerType(code >> 2); + } + } // BBS if (state > max_ebt) diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 815d7ca56..ee439b3fd 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -1618,8 +1618,8 @@ void Sidebar::on_filaments_change(size_t num_filaments) } void Sidebar::add_filament() { - // BBS: limit filament choices to 16 - if (p->combos_filament.size() >= 16) return; + // BBS: limit filament choices to ExtruderMax + if (p->combos_filament.size() >= size_t(EnforcerBlockerType::ExtruderMax)) return; wxColour new_col = Plater::get_next_color_for_filament(); add_custom_filament(new_col); } @@ -1643,7 +1643,7 @@ void Sidebar::delete_filament() { } void Sidebar::add_custom_filament(wxColour new_col) { - if (p->combos_filament.size() >= 16) return; + if (p->combos_filament.size() >= size_t(EnforcerBlockerType::ExtruderMax)) return; int filament_count = p->combos_filament.size() + 1; std::string new_color = new_col.GetAsString(wxC2S_HTML_SYNTAX).ToStdString();