From af8e195532a9541305a527f8ef3c33fc48268a31 Mon Sep 17 00:00:00 2001 From: "qing.zhang" Date: Fri, 22 Mar 2024 10:35:47 +0800 Subject: [PATCH] FIX: crash while use conditional scarf and clip paths correctly while has 50% overhang on slope Jira: 6640 6639 Signed-off-by: qing.zhang Change-Id: I8abe43177c3965130514017eaaa75bc79ab7b2db --- src/libslic3r/ExtrusionEntity.cpp | 4 ++-- src/libslic3r/GCode.cpp | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/libslic3r/ExtrusionEntity.cpp b/src/libslic3r/ExtrusionEntity.cpp index 3fc9e8bb5..45e0ae5d3 100644 --- a/src/libslic3r/ExtrusionEntity.cpp +++ b/src/libslic3r/ExtrusionEntity.cpp @@ -322,7 +322,7 @@ void ExtrusionLoopSloped::clip_end(const double distance) { double clip_dist = distance; std::vector &ends_slope = this->ends; - while (clip_dist > 0) { + while (clip_dist > 0 && !ends_slope.empty()) { ExtrusionPathSloped &last_path = ends_slope.back(); double len = last_path.length(); if (len <= clip_dist) { @@ -345,7 +345,7 @@ void ExtrusionLoopSloped::clip_front(const double distance) std::vector &start_slope = this->starts; Polyline front_inward; - while (distance > 0) { + while (distance > 0 && !start_slope.empty()) { ExtrusionPathSloped &first_path = start_slope.front(); double len = first_path.length(); if (len <= clip_dist) { diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index f4829429e..9b6735e90 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -4081,13 +4081,14 @@ std::string GCode::extrude_loop(ExtrusionLoop loop, std::string description, dou paths.insert(paths.end(), new_loop.paths.begin(), new_loop.paths.end()); paths.insert(paths.end(), new_loop.ends.begin(), new_loop.ends.end()); } + } else { + paths.clear(); + loop.clip_end(clip_length, &paths); + if (paths.empty()) return ""; } } if (!enable_seam_slope || slope_has_overhang) { - if (enable_seam_slope) - paths.back().clip_end(seam_gap); - for (ExtrusionPaths::iterator path = paths.begin(); path != paths.end(); ++path) { gcode += this->_extrude(*path, description, speed_for_path(*path)); }