From d3326f9f0c7f9868adc7231d5912f616dc406615 Mon Sep 17 00:00:00 2001 From: SoftFever Date: Wed, 9 Nov 2022 22:04:03 +0800 Subject: [PATCH] wip --- src/libslic3r/PerimeterGenerator.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/libslic3r/PerimeterGenerator.cpp b/src/libslic3r/PerimeterGenerator.cpp index 47d6eeda32..e9dcdf387a 100644 --- a/src/libslic3r/PerimeterGenerator.cpp +++ b/src/libslic3r/PerimeterGenerator.cpp @@ -612,13 +612,18 @@ void PerimeterGenerator::process() } // nest loops: holes first - for (int d = 0; d <= loop_number; ++ d) { - PerimeterGeneratorLoops &holes_d = holes[d]; + int idx; + for (int d = -1; d < loop_number; ++ d) { + idx = d; + if (idx == -1) + idx = loop_number; + + PerimeterGeneratorLoops &holes_d = holes[idx]; // loop through all holes having depth == d for (int i = 0; i < (int)holes_d.size(); ++ i) { const PerimeterGeneratorLoop &loop = holes_d[i]; // find the hole loop that contains this one, if any - for (int t = d + 1; t <= loop_number; ++ t) { + for (int t = idx + 1; t <= loop_number; ++ t) { for (int j = 0; j < (int)holes[t].size(); ++ j) { PerimeterGeneratorLoop &candidate_parent = holes[t][j]; if (candidate_parent.polygon.contains(loop.polygon.first_point())) { @@ -645,13 +650,16 @@ void PerimeterGenerator::process() } } // nest contour loops - for (int d = loop_number; d >= 1; -- d) { - PerimeterGeneratorLoops &contours_d = contours[d]; + for (int d = loop_number-1; d >= 0; -- d) { + idx = d; + if (idx == 0) + idx = loop_number; + PerimeterGeneratorLoops &contours_d = contours[idx]; // loop through all contours having depth == d for (int i = 0; i < (int)contours_d.size(); ++ i) { const PerimeterGeneratorLoop &loop = contours_d[i]; // find the contour loop that contains it - for (int t = d - 1; t >= 0; -- t) { + for (int t = idx - 1; t >= 0; -- t) { for (size_t j = 0; j < contours[t].size(); ++ j) { PerimeterGeneratorLoop &candidate_parent = contours[t][j]; if (candidate_parent.polygon.contains(loop.polygon.first_point())) {