From fd17dd63828fabe877998d45b77cda06c6b21994 Mon Sep 17 00:00:00 2001 From: "jiangkai.zhao" Date: Wed, 4 Jun 2025 14:34:09 +0800 Subject: [PATCH] FIX:Crash caused by wipe_tower depth = 0 and remove useless assert jira: STUDIO-12514,STUDIO-12474,github#7064 Change-Id: I8faf498251c8f7ca2c1eead463f38e8a3d836299 (cherry picked from commit 723e2d7ced6b466f2166085b8ca007762aaf17aa) --- src/libslic3r/GCode/WipeTower.cpp | 4 +++- src/libslic3r/Print.cpp | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/libslic3r/GCode/WipeTower.cpp b/src/libslic3r/GCode/WipeTower.cpp index beb9efc113..17cf52dab1 100644 --- a/src/libslic3r/GCode/WipeTower.cpp +++ b/src/libslic3r/GCode/WipeTower.cpp @@ -1430,9 +1430,10 @@ TriangleMesh WipeTower::its_make_rib_tower(float width, float depth, float heigh Polygon bottom = rib_section(width, depth, rib_length, rib_width, fillet_wall); Polygon top = rib_section(width, depth, std::sqrt(width * width + depth * depth), rib_width, fillet_wall); if (fillet_wall) - assert(bottom.points.size() == top.points.size()); + assert(bottom.points.size() == top.points.size()); int offset = bottom.points.size(); res.its.vertices.reserve(offset * 2); + if (bottom.area() < scaled(EPSILON) || top.area() < scaled(EPSILON) || bottom.points.size() != top.points.size()) return res; auto faces_bottom = Triangulation::triangulate(bottom); auto faces_top = Triangulation::triangulate(top); res.its.indices.reserve(offset * 2 + faces_bottom.size() + faces_top.size()); @@ -1455,6 +1456,7 @@ TriangleMesh WipeTower::its_make_rib_tower(float width, float depth, float heigh TriangleMesh WipeTower::its_make_rib_brim(const Polygon& brim, float layer_height) { TriangleMesh res; + if (brim.area() < scaled(EPSILON))return res; int offset = brim.size(); res.its.vertices.reserve(brim.size() * 2); auto faces= Triangulation::triangulate(brim); diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index 44c41f5343..fc835a2124 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -4705,6 +4705,7 @@ void WipeTowerData::construct_mesh(float width, float depth, float height, float { wipe_tower_mesh_data = WipeTowerMeshData{}; float first_layer_height=0.08; //brim height + if (width < EPSILON || depth < EPSILON || height < EPSILON) return; if (!is_rib_wipe_tower) { wipe_tower_mesh_data->real_wipe_tower_mesh = make_cube(width, depth, height); wipe_tower_mesh_data->real_brim_mesh = make_cube(width + 2 * brim_width, depth + 2 * brim_width, first_layer_height); @@ -4714,7 +4715,9 @@ void WipeTowerData::construct_mesh(float width, float depth, float height, float } else { wipe_tower_mesh_data->real_wipe_tower_mesh = WipeTower::its_make_rib_tower(width, depth, height, rib_length, rib_width, fillet_wall); wipe_tower_mesh_data->bottom = WipeTower::rib_section(width, depth, rib_length, rib_width, fillet_wall); - wipe_tower_mesh_data->bottom = offset(wipe_tower_mesh_data->bottom, scaled(brim_width)).front(); + auto brim_bottom = offset(wipe_tower_mesh_data->bottom, scaled(brim_width)); + if (!brim_bottom.empty()) + wipe_tower_mesh_data->bottom = brim_bottom.front(); wipe_tower_mesh_data->real_brim_mesh = WipeTower::its_make_rib_brim(wipe_tower_mesh_data->bottom, first_layer_height); wipe_tower_mesh_data->real_wipe_tower_mesh.translate(Vec3f(rib_offset[0], rib_offset[1],0)); wipe_tower_mesh_data->real_brim_mesh.translate(Vec3f(rib_offset[0], rib_offset[1], 0));