From 3d70bdc3e1224c9f9c0a6c0808af2003ae30d04d Mon Sep 17 00:00:00 2001 From: Arthur Date: Thu, 23 May 2024 22:01:01 +0800 Subject: [PATCH] FIX: top z distance incorrect with adaptive layer height This bug causes supports difficult to remove. Rule to remmeber: never decrease the top z distance, you can only increase it SLIGHTLY. jira: STUDIO-7103, STUDIO-7001 Change-Id: I24f71cd67d182d4e2c0902f244a8ca8f4c3ee982 (cherry picked from commit 461af9e8f6f98a8e0b363436276f225183365998) --- src/libslic3r/Support/TreeSupport.cpp | 35 ++++++--------------------- 1 file changed, 7 insertions(+), 28 deletions(-) diff --git a/src/libslic3r/Support/TreeSupport.cpp b/src/libslic3r/Support/TreeSupport.cpp index 914a0ed667..1a8a86ea58 100644 --- a/src/libslic3r/Support/TreeSupport.cpp +++ b/src/libslic3r/Support/TreeSupport.cpp @@ -1910,9 +1910,8 @@ void TreeSupport::draw_circles(const std::vector>& con continue; } - SupportNode* first_node = curr_layer_nodes.front(); - ts_layer->print_z = first_node->print_z; - ts_layer->height = first_node->height; + ts_layer->print_z = m_ts_data->layer_heights[layer_nr].print_z; + ts_layer->height = m_ts_data->layer_heights[layer_nr].height; if (ts_layer->height < EPSILON) { continue; } @@ -2951,20 +2950,11 @@ std::vector TreeSupport::plan_layer_heights(std::vectorget_layer(0)->print_z, m_object->get_layer(0)->height, 0 }; // Collect top contact layers - coordf_t print_z = layer_heights[0].print_z; for (int layer_nr = 1; layer_nr < contact_nodes.size(); layer_nr++) { if (!contact_nodes[layer_nr].empty()) { bounds.push_back(layer_nr); layer_heights[layer_nr].print_z = contact_nodes[layer_nr].front()->print_z; layer_heights[layer_nr].height = contact_nodes[layer_nr].front()->height; - if (layer_heights[layer_nr].bottom_z() - print_z < m_slicing_params.min_layer_height) { - layer_heights[layer_nr].height = layer_heights[layer_nr].print_z - print_z; - for (auto& node : contact_nodes[layer_nr]) { - node->height = layer_heights[layer_nr].height; - } - } - print_z = layer_heights[layer_nr].print_z; - BOOST_LOG_TRIVIAL(trace) << "plan_layer_heights0 print_z, height, layer_nr: " << layer_heights[layer_nr].print_z << " " << layer_heights[layer_nr].height << " " << layer_nr; } @@ -3008,34 +2998,23 @@ std::vector TreeSupport::plan_layer_heights(std::vector= 0; i = j) { + for (; i >= 0; i--) { if (layer_heights[i].height < EPSILON) { - j--; continue; } for (j = i - 1; j >= 0; j--) { - if (layer_heights[j].height > EPSILON) { + if (layer_heights[j].height > EPSILON && layer_heights[j].print_z0.01) // there is a gap more than 0.01mm, increase the top z distance to fill the gap + layer_heights[i].height = layer_heights[i].print_z - layer_heights[j].print_z; break; } } } - - for (i = 0; i < layer_heights.size(); i++) { - // there might be gap between layers due to non-integer interfaces - if (size_t next_layer_nr = layer_heights[i].next_layer_nr; - next_layer_nr > 0 && layer_heights[i].height + EPSILON < layer_heights[i].print_z - layer_heights[next_layer_nr].print_z) { - layer_heights[i].height = layer_heights[i].print_z - layer_heights[next_layer_nr].print_z; - } - - } } - // update interfaces' height + // log layer_heights for (size_t i = 0; i < layer_heights.size(); i++) { - for (auto& node : contact_nodes[i]) { - node->height = layer_heights[i].height; - } if (layer_heights[i].height > EPSILON) BOOST_LOG_TRIVIAL(trace) << "plan_layer_heights print_z, height, lower_layer_nr->layer_nr: " << layer_heights[i].print_z << " " << layer_heights[i].height << " " << layer_heights[i].next_layer_nr << "->" << i;