From 855c3d61ffd1ffcafadc0c8d1c22771616a23b0c Mon Sep 17 00:00:00 2001 From: Arthur Date: Wed, 6 Sep 2023 15:27:19 +0800 Subject: [PATCH] FIX: tree support + raft may fail to slice Do not skip generate_toolpaths if has no overhang but has raft. Jira: STUDIO-4341 Change-Id: I0bdadb5f778e0e1fda686341c0860d0f0c160f0f --- src/libslic3r/TreeSupport.cpp | 40 ++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/src/libslic3r/TreeSupport.cpp b/src/libslic3r/TreeSupport.cpp index a650fb1b5..830a3934c 100644 --- a/src/libslic3r/TreeSupport.cpp +++ b/src/libslic3r/TreeSupport.cpp @@ -1183,19 +1183,25 @@ void TreeSupport::detect_overhangs(bool detect_first_sharp_tail_only) void TreeSupport::create_tree_support_layers() { - int layer_id = 0; - coordf_t raft_print_z = 0.f; - coordf_t raft_slice_z = 0.f; - for (; layer_id < m_slicing_params.base_raft_layers; layer_id++) { - raft_print_z += m_slicing_params.base_raft_layer_height; - raft_slice_z = raft_print_z - m_slicing_params.base_raft_layer_height / 2; - m_object->add_tree_support_layer(layer_id, m_slicing_params.base_raft_layer_height, raft_print_z, raft_slice_z); - } - - for (; layer_id < m_slicing_params.base_raft_layers + m_slicing_params.interface_raft_layers; layer_id++) { - raft_print_z += m_slicing_params.interface_raft_layer_height; - raft_slice_z = raft_print_z - m_slicing_params.interface_raft_layer_height / 2; - m_object->add_tree_support_layer(layer_id, m_slicing_params.base_raft_layer_height, raft_print_z, raft_slice_z); + { //create raft layers + int layer_id = 0; + coordf_t raft_print_z = 0.f; + coordf_t raft_slice_z = 0.f; + // Insert the base layers. + for (size_t i = 0; i < m_slicing_params.base_raft_layers; i++, layer_id++) { + // 1st layer should use first_print_layer_height + coordf_t height = i == 0 ? m_slicing_params.first_print_layer_height : m_slicing_params.base_raft_layer_height; + raft_print_z += height; + raft_slice_z = raft_print_z - height / 2; + m_object->add_tree_support_layer(layer_id, height, raft_print_z, raft_slice_z); + } + // Insert the interface layers. + for (size_t i = 0; i < m_slicing_params.interface_raft_layers; i++, layer_id++) { + coordf_t height = m_slicing_params.interface_raft_layer_height; + raft_print_z += height; + raft_slice_z = raft_print_z - height / 2; + m_object->add_tree_support_layer(layer_id, height, raft_print_z, raft_slice_z); + } } for (Layer *layer : m_object->layers()) { @@ -1885,8 +1891,6 @@ void TreeSupport::generate() detect_overhangs(); profiler.stage_finish(STAGE_DETECT_OVERHANGS); - if (!has_overhangs) return; - m_ts_data = m_object->alloc_tree_support_preview_cache(); m_ts_data->is_slim = is_slim; @@ -1915,10 +1919,8 @@ void TreeSupport::generate() draw_circles(contact_nodes); profiler.stage_finish(STAGE_DRAW_CIRCLES); - for (auto& layer : contact_nodes) - { - for (Node* p_node : layer) - { + for (auto& layer : contact_nodes) { + for (Node* p_node : layer) { delete p_node; } layer.clear();