From 8be88c26a10476832ccccebd8d0d1234d6fbc8d1 Mon Sep 17 00:00:00 2001 From: "saumya.jain" Date: Tue, 13 Feb 2024 15:04:54 +0100 Subject: [PATCH 1/9] in case of only single vertex is present In such a case path_order_optimisation is not needed. Slicing crash https://github.com/Ultimaker/Cura/issues/17499 CURA-11570 --- src/FffGcodeWriter.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/FffGcodeWriter.cpp b/src/FffGcodeWriter.cpp index 6008826fbf..f2a504e953 100644 --- a/src/FffGcodeWriter.cpp +++ b/src/FffGcodeWriter.cpp @@ -1643,7 +1643,8 @@ void FffGcodeWriter::addMeshLayerToGCode_meshSurfaceMode(const SliceMeshStorage& Polygons polygons; for (const SliceLayerPart& part : layer->parts) { - polygons.add(part.outline); + if(!part.outline.empty()) + polygons.add(part.outline); } polygons = Simplify(mesh.settings).polygon(polygons); @@ -1707,7 +1708,10 @@ void FffGcodeWriter::addMeshLayerToGCode( { part_order_optimizer.addPolygon(&part); } - part_order_optimizer.optimize(false); + if (part_order_optimizer.vertices_to_paths_.size() > 1) + { + part_order_optimizer.optimize(false); + } for (const PathOrdering& path : part_order_optimizer.paths_) { addMeshPartToGCode(storage, mesh, extruder_nr, mesh_config, *path.vertices_, gcode_layer); From 3303a52dcd53e5d4f5c5767483a6153dcafd2dfd Mon Sep 17 00:00:00 2001 From: saumyaj3 Date: Tue, 13 Feb 2024 14:05:39 +0000 Subject: [PATCH 2/9] Applied clang-format. --- src/FffGcodeWriter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FffGcodeWriter.cpp b/src/FffGcodeWriter.cpp index f2a504e953..705ecbebcb 100644 --- a/src/FffGcodeWriter.cpp +++ b/src/FffGcodeWriter.cpp @@ -1643,7 +1643,7 @@ void FffGcodeWriter::addMeshLayerToGCode_meshSurfaceMode(const SliceMeshStorage& Polygons polygons; for (const SliceLayerPart& part : layer->parts) { - if(!part.outline.empty()) + if (! part.outline.empty()) polygons.add(part.outline); } From b8f6bbfa1517c154f8d87e39ce705d387e6159c5 Mon Sep 17 00:00:00 2001 From: "saumya.jain" Date: Tue, 13 Feb 2024 15:07:45 +0100 Subject: [PATCH 3/9] preventing empty outline slicelayerpart preventive coading CURA-11570 --- src/FffPolygonGenerator.cpp | 145 +++++++++++++++++++----------------- src/layerPart.cpp | 8 ++ src/skin.cpp | 4 + src/sliceDataStorage.cpp | 5 +- src/support.cpp | 4 + 5 files changed, 98 insertions(+), 68 deletions(-) diff --git a/src/FffPolygonGenerator.cpp b/src/FffPolygonGenerator.cpp index 384093794c..a146db73cb 100644 --- a/src/FffPolygonGenerator.cpp +++ b/src/FffPolygonGenerator.cpp @@ -568,6 +568,10 @@ void FffPolygonGenerator::processInfillMesh(SliceDataStorage& storage, const siz // they have to be polylines, because they might break up further when doing the cutting for (SliceLayerPart& part : layer.parts) { + if(part.outline.empty()) + { + continue; + } for (PolygonRef poly : part.outline) { layer.openPolyLines.add(poly); @@ -642,6 +646,10 @@ void FffPolygonGenerator::processInfillMesh(SliceDataStorage& storage, const siz layer.parts.clear(); for (PolygonsPart& part : new_parts) { + if (part.empty()){ + spdlog::warn("ffp"); + continue; + } layer.parts.emplace_back(); layer.parts.back().outline = part; layer.parts.back().boundaryBox.calculate(part); @@ -1101,96 +1109,99 @@ void FffPolygonGenerator::processFuzzyWalls(SliceMeshStorage& mesh) SliceLayer& layer = mesh.layers[layer_nr]; for (SliceLayerPart& part : layer.parts) { - std::vector result_paths; - for (auto& toolpath : part.wall_toolpaths) + if (!part.outline.empty()) { - if (toolpath.front().inset_idx_ != 0) - { - result_paths.push_back(toolpath); - continue; - } - - auto& result_lines = result_paths.emplace_back(); - - if (apply_outside_only) + std::vector result_paths; + for (auto& toolpath : part.wall_toolpaths) { - hole_area = part.print_outline.getOutsidePolygons().offset(-line_width); - accumulate_is_in_hole = [&hole_area](const bool& prev_result, const ExtrusionJunction& junction) + if (toolpath.front().inset_idx_ != 0) { - return prev_result || hole_area.inside(junction.p_); - }; - } - for (auto& line : toolpath) - { - if (apply_outside_only && std::accumulate(line.begin(), line.end(), false, accumulate_is_in_hole)) - { - result_lines.push_back(line); + result_paths.push_back(toolpath); continue; } - auto& result = result_lines.emplace_back(line.inset_idx_, line.is_odd_, line.is_closed_); + auto& result_lines = result_paths.emplace_back(); - // generate points in between p0 and p1 - int64_t dist_left_over - = (min_dist_between_points / 4) + rand() % (min_dist_between_points / 4); // the distance to be traversed on the line before making the first new point - auto* p0 = &line.front(); - for (auto& p1 : line) + if (apply_outside_only) { - if (p0->p_ == p1.p_) // avoid seams + hole_area = part.print_outline.getOutsidePolygons().offset(-line_width); + accumulate_is_in_hole = [&hole_area](const bool& prev_result, const ExtrusionJunction& junction) { - result.emplace_back(p1.p_, p1.w_, p1.perimeter_index_); + return prev_result || hole_area.inside(junction.p_); + }; + } + for (auto& line : toolpath) + { + if (apply_outside_only && std::accumulate(line.begin(), line.end(), false, accumulate_is_in_hole)) + { + result_lines.push_back(line); continue; } - // 'a' is the (next) new point between p0 and p1 - const Point2LL p0p1 = p1.p_ - p0->p_; - const int64_t p0p1_size = vSize(p0p1); - int64_t p0pa_dist = dist_left_over; - if (p0pa_dist >= p0p1_size) + auto& result = result_lines.emplace_back(line.inset_idx_, line.is_odd_, line.is_closed_); + + // generate points in between p0 and p1 + int64_t dist_left_over + = (min_dist_between_points / 4) + rand() % (min_dist_between_points / 4); // the distance to be traversed on the line before making the first new point + auto* p0 = &line.front(); + for (auto& p1 : line) { - const Point2LL p = p1.p_ - (p0p1 / 2); - const double width = (p1.w_ * vSize(p1.p_ - p) + p0->w_ * vSize(p0->p_ - p)) / p0p1_size; - result.emplace_back(p, width, p1.perimeter_index_); + if (p0->p_ == p1.p_) // avoid seams + { + result.emplace_back(p1.p_, p1.w_, p1.perimeter_index_); + continue; + } + + // 'a' is the (next) new point between p0 and p1 + const Point2LL p0p1 = p1.p_ - p0->p_; + const int64_t p0p1_size = vSize(p0p1); + int64_t p0pa_dist = dist_left_over; + if (p0pa_dist >= p0p1_size) + { + const Point2LL p = p1.p_ - (p0p1 / 2); + const double width = (p1.w_ * vSize(p1.p_ - p) + p0->w_ * vSize(p0->p_ - p)) / p0p1_size; + result.emplace_back(p, width, p1.perimeter_index_); + } + for (; p0pa_dist < p0p1_size; p0pa_dist += min_dist_between_points + rand() % range_random_point_dist) + { + const int r = rand() % (fuzziness * 2) - fuzziness; + const Point2LL perp_to_p0p1 = turn90CCW(p0p1); + const Point2LL fuzz = normal(perp_to_p0p1, r); + const Point2LL pa = p0->p_ + normal(p0p1, p0pa_dist); + const double width = (p1.w_ * vSize(p1.p_ - pa) + p0->w_ * vSize(p0->p_ - pa)) / p0p1_size; + result.emplace_back(pa + fuzz, width, p1.perimeter_index_); + } + // p0pa_dist > p0p1_size now because we broke out of the for-loop + dist_left_over = p0pa_dist - p0p1_size; + + p0 = &p1; } - for (; p0pa_dist < p0p1_size; p0pa_dist += min_dist_between_points + rand() % range_random_point_dist) + while (result.size() < 3) { - const int r = rand() % (fuzziness * 2) - fuzziness; - const Point2LL perp_to_p0p1 = turn90CCW(p0p1); - const Point2LL fuzz = normal(perp_to_p0p1, r); - const Point2LL pa = p0->p_ + normal(p0p1, p0pa_dist); - const double width = (p1.w_ * vSize(p1.p_ - pa) + p0->w_ * vSize(p0->p_ - pa)) / p0p1_size; - result.emplace_back(pa + fuzz, width, p1.perimeter_index_); + size_t point_idx = line.size() - 2; + result.emplace_back(line[point_idx].p_, line[point_idx].w_, line[point_idx].perimeter_index_); + if (point_idx == 0) + { + break; + } + point_idx--; } - // p0pa_dist > p0p1_size now because we broke out of the for-loop - dist_left_over = p0pa_dist - p0p1_size; - - p0 = &p1; - } - while (result.size() < 3) - { - size_t point_idx = line.size() - 2; - result.emplace_back(line[point_idx].p_, line[point_idx].w_, line[point_idx].perimeter_index_); - if (point_idx == 0) + if (result.size() < 3) { - break; + result.clear(); + for (auto& p : line) + { + result.emplace_back(p.p_, p.w_, p.perimeter_index_); + } } - point_idx--; - } - if (result.size() < 3) - { - result.clear(); - for (auto& p : line) + if (line.back().p_ == line.front().p_) // avoid seams { - result.emplace_back(p.p_, p.w_, p.perimeter_index_); + result.back().p_ = result.front().p_; } } - if (line.back().p_ == line.front().p_) // avoid seams - { - result.back().p_ = result.front().p_; - } } + part.wall_toolpaths = result_paths; } - part.wall_toolpaths = result_paths; } } } diff --git a/src/layerPart.cpp b/src/layerPart.cpp index b0fb7ece93..db08a9a196 100644 --- a/src/layerPart.cpp +++ b/src/layerPart.cpp @@ -51,6 +51,10 @@ void createLayerWithParts(const Settings& settings, SliceLayer& storageLayer, Sl result.reserve(layer->polygons.size()); for (const PolygonRef poly : layer->polygons) { + if (poly.empty()) + { + continue; + } result.emplace_back(); result.back().add(poly); } @@ -63,6 +67,10 @@ void createLayerWithParts(const Settings& settings, SliceLayer& storageLayer, Sl for (auto& part : result) { storageLayer.parts.emplace_back(); + if (part.empty()) + { + continue; + } storageLayer.parts.back().outline = part; storageLayer.parts.back().boundaryBox.calculate(storageLayer.parts.back().outline); if (storageLayer.parts.back().outline.empty()) diff --git a/src/skin.cpp b/src/skin.cpp index 1f36864698..0fbd302541 100644 --- a/src/skin.cpp +++ b/src/skin.cpp @@ -156,6 +156,10 @@ void SkinInfillAreaComputation::generateSkinAndInfillAreas(SliceLayerPart& part) for (PolygonsPart& skin_area_part : skin.splitIntoParts()) { + if (skin_area_part.empty()) + { + continue; + } part.skin_parts.emplace_back(); part.skin_parts.back().outline = skin_area_part; } diff --git a/src/sliceDataStorage.cpp b/src/sliceDataStorage.cpp index e87250191b..3f94495d89 100644 --- a/src/sliceDataStorage.cpp +++ b/src/sliceDataStorage.cpp @@ -740,7 +740,10 @@ void SupportLayer::excludeAreasFromSupportInfillAreas(const Polygons& exclude_po { const size_t remove_idx = to_remove_part_indices.back(); to_remove_part_indices.pop_back(); - + if (support_infill_parts.empty()) + { + continue; + } if (remove_idx < support_infill_parts.size() - 1) { // move last element to the to-be-removed element so that we can erase the last place in the vector support_infill_parts[remove_idx] = std::move(support_infill_parts.back()); diff --git a/src/support.cpp b/src/support.cpp index 3ef52db616..3097afdbbb 100644 --- a/src/support.cpp +++ b/src/support.cpp @@ -1491,6 +1491,10 @@ void AreaSupport::detectOverhangPoints(const SliceDataStorage& storage, SliceMes for (const SliceLayerPart& part : layer.parts) { + if (part.outline.empty()) + { + continue; + } if (part.outline.outerPolygon().area() >= max_tower_supported_area) { // area is too big for support towers, should be supported by normal overhang detection From 8ae9aabf7e71f06b0e3557429b87b94c153b0acf Mon Sep 17 00:00:00 2001 From: saumyaj3 Date: Tue, 13 Feb 2024 14:08:37 +0000 Subject: [PATCH 4/9] Applied clang-format. --- src/FffPolygonGenerator.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/FffPolygonGenerator.cpp b/src/FffPolygonGenerator.cpp index a146db73cb..40dc3fe87f 100644 --- a/src/FffPolygonGenerator.cpp +++ b/src/FffPolygonGenerator.cpp @@ -568,7 +568,7 @@ void FffPolygonGenerator::processInfillMesh(SliceDataStorage& storage, const siz // they have to be polylines, because they might break up further when doing the cutting for (SliceLayerPart& part : layer.parts) { - if(part.outline.empty()) + if (part.outline.empty()) { continue; } @@ -646,7 +646,8 @@ void FffPolygonGenerator::processInfillMesh(SliceDataStorage& storage, const siz layer.parts.clear(); for (PolygonsPart& part : new_parts) { - if (part.empty()){ + if (part.empty()) + { spdlog::warn("ffp"); continue; } @@ -1109,7 +1110,7 @@ void FffPolygonGenerator::processFuzzyWalls(SliceMeshStorage& mesh) SliceLayer& layer = mesh.layers[layer_nr]; for (SliceLayerPart& part : layer.parts) { - if (!part.outline.empty()) + if (! part.outline.empty()) { std::vector result_paths; for (auto& toolpath : part.wall_toolpaths) From 5f7c0d78ed457a1d86f5a0945391fac846bf9409 Mon Sep 17 00:00:00 2001 From: "saumya.jain" Date: Tue, 13 Feb 2024 15:18:20 +0100 Subject: [PATCH 5/9] removing debug message CURA-11570 --- src/FffPolygonGenerator.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/FffPolygonGenerator.cpp b/src/FffPolygonGenerator.cpp index 40dc3fe87f..5be91a2bc6 100644 --- a/src/FffPolygonGenerator.cpp +++ b/src/FffPolygonGenerator.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2023 UltiMaker +// Copyright (c) 2024 UltiMaker // CuraEngine is released under the terms of the AGPLv3 or higher #include @@ -648,7 +648,6 @@ void FffPolygonGenerator::processInfillMesh(SliceDataStorage& storage, const siz { if (part.empty()) { - spdlog::warn("ffp"); continue; } layer.parts.emplace_back(); From 57d528ba6d453b5aaaf62514fbf170ba3584c92d Mon Sep 17 00:00:00 2001 From: "saumya.jain" Date: Tue, 13 Feb 2024 16:12:31 +0100 Subject: [PATCH 6/9] removing condition on fuzzy skin not needed CURA-11570 --- src/FffPolygonGenerator.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/FffPolygonGenerator.cpp b/src/FffPolygonGenerator.cpp index 5be91a2bc6..3a3ea6461c 100644 --- a/src/FffPolygonGenerator.cpp +++ b/src/FffPolygonGenerator.cpp @@ -1109,9 +1109,7 @@ void FffPolygonGenerator::processFuzzyWalls(SliceMeshStorage& mesh) SliceLayer& layer = mesh.layers[layer_nr]; for (SliceLayerPart& part : layer.parts) { - if (! part.outline.empty()) - { - std::vector result_paths; + std::vector result_paths; for (auto& toolpath : part.wall_toolpaths) { if (toolpath.front().inset_idx_ != 0) @@ -1201,7 +1199,6 @@ void FffPolygonGenerator::processFuzzyWalls(SliceMeshStorage& mesh) } } part.wall_toolpaths = result_paths; - } } } } From 1d1746d1f9e67b64ec9321537d2df31ed7a088dc Mon Sep 17 00:00:00 2001 From: saumyaj3 Date: Tue, 13 Feb 2024 15:13:42 +0000 Subject: [PATCH 7/9] Applied clang-format. --- src/FffPolygonGenerator.cpp | 136 ++++++++++++++++++------------------ 1 file changed, 68 insertions(+), 68 deletions(-) diff --git a/src/FffPolygonGenerator.cpp b/src/FffPolygonGenerator.cpp index 3a3ea6461c..ff36a1226c 100644 --- a/src/FffPolygonGenerator.cpp +++ b/src/FffPolygonGenerator.cpp @@ -1110,95 +1110,95 @@ void FffPolygonGenerator::processFuzzyWalls(SliceMeshStorage& mesh) for (SliceLayerPart& part : layer.parts) { std::vector result_paths; - for (auto& toolpath : part.wall_toolpaths) + for (auto& toolpath : part.wall_toolpaths) + { + if (toolpath.front().inset_idx_ != 0) + { + result_paths.push_back(toolpath); + continue; + } + + auto& result_lines = result_paths.emplace_back(); + + if (apply_outside_only) + { + hole_area = part.print_outline.getOutsidePolygons().offset(-line_width); + accumulate_is_in_hole = [&hole_area](const bool& prev_result, const ExtrusionJunction& junction) + { + return prev_result || hole_area.inside(junction.p_); + }; + } + for (auto& line : toolpath) { - if (toolpath.front().inset_idx_ != 0) + if (apply_outside_only && std::accumulate(line.begin(), line.end(), false, accumulate_is_in_hole)) { - result_paths.push_back(toolpath); + result_lines.push_back(line); continue; } - auto& result_lines = result_paths.emplace_back(); + auto& result = result_lines.emplace_back(line.inset_idx_, line.is_odd_, line.is_closed_); - if (apply_outside_only) + // generate points in between p0 and p1 + int64_t dist_left_over + = (min_dist_between_points / 4) + rand() % (min_dist_between_points / 4); // the distance to be traversed on the line before making the first new point + auto* p0 = &line.front(); + for (auto& p1 : line) { - hole_area = part.print_outline.getOutsidePolygons().offset(-line_width); - accumulate_is_in_hole = [&hole_area](const bool& prev_result, const ExtrusionJunction& junction) + if (p0->p_ == p1.p_) // avoid seams { - return prev_result || hole_area.inside(junction.p_); - }; - } - for (auto& line : toolpath) - { - if (apply_outside_only && std::accumulate(line.begin(), line.end(), false, accumulate_is_in_hole)) - { - result_lines.push_back(line); + result.emplace_back(p1.p_, p1.w_, p1.perimeter_index_); continue; } - auto& result = result_lines.emplace_back(line.inset_idx_, line.is_odd_, line.is_closed_); - - // generate points in between p0 and p1 - int64_t dist_left_over - = (min_dist_between_points / 4) + rand() % (min_dist_between_points / 4); // the distance to be traversed on the line before making the first new point - auto* p0 = &line.front(); - for (auto& p1 : line) + // 'a' is the (next) new point between p0 and p1 + const Point2LL p0p1 = p1.p_ - p0->p_; + const int64_t p0p1_size = vSize(p0p1); + int64_t p0pa_dist = dist_left_over; + if (p0pa_dist >= p0p1_size) { - if (p0->p_ == p1.p_) // avoid seams - { - result.emplace_back(p1.p_, p1.w_, p1.perimeter_index_); - continue; - } - - // 'a' is the (next) new point between p0 and p1 - const Point2LL p0p1 = p1.p_ - p0->p_; - const int64_t p0p1_size = vSize(p0p1); - int64_t p0pa_dist = dist_left_over; - if (p0pa_dist >= p0p1_size) - { - const Point2LL p = p1.p_ - (p0p1 / 2); - const double width = (p1.w_ * vSize(p1.p_ - p) + p0->w_ * vSize(p0->p_ - p)) / p0p1_size; - result.emplace_back(p, width, p1.perimeter_index_); - } - for (; p0pa_dist < p0p1_size; p0pa_dist += min_dist_between_points + rand() % range_random_point_dist) - { - const int r = rand() % (fuzziness * 2) - fuzziness; - const Point2LL perp_to_p0p1 = turn90CCW(p0p1); - const Point2LL fuzz = normal(perp_to_p0p1, r); - const Point2LL pa = p0->p_ + normal(p0p1, p0pa_dist); - const double width = (p1.w_ * vSize(p1.p_ - pa) + p0->w_ * vSize(p0->p_ - pa)) / p0p1_size; - result.emplace_back(pa + fuzz, width, p1.perimeter_index_); - } - // p0pa_dist > p0p1_size now because we broke out of the for-loop - dist_left_over = p0pa_dist - p0p1_size; - - p0 = &p1; + const Point2LL p = p1.p_ - (p0p1 / 2); + const double width = (p1.w_ * vSize(p1.p_ - p) + p0->w_ * vSize(p0->p_ - p)) / p0p1_size; + result.emplace_back(p, width, p1.perimeter_index_); } - while (result.size() < 3) + for (; p0pa_dist < p0p1_size; p0pa_dist += min_dist_between_points + rand() % range_random_point_dist) { - size_t point_idx = line.size() - 2; - result.emplace_back(line[point_idx].p_, line[point_idx].w_, line[point_idx].perimeter_index_); - if (point_idx == 0) - { - break; - } - point_idx--; + const int r = rand() % (fuzziness * 2) - fuzziness; + const Point2LL perp_to_p0p1 = turn90CCW(p0p1); + const Point2LL fuzz = normal(perp_to_p0p1, r); + const Point2LL pa = p0->p_ + normal(p0p1, p0pa_dist); + const double width = (p1.w_ * vSize(p1.p_ - pa) + p0->w_ * vSize(p0->p_ - pa)) / p0p1_size; + result.emplace_back(pa + fuzz, width, p1.perimeter_index_); } - if (result.size() < 3) + // p0pa_dist > p0p1_size now because we broke out of the for-loop + dist_left_over = p0pa_dist - p0p1_size; + + p0 = &p1; + } + while (result.size() < 3) + { + size_t point_idx = line.size() - 2; + result.emplace_back(line[point_idx].p_, line[point_idx].w_, line[point_idx].perimeter_index_); + if (point_idx == 0) { - result.clear(); - for (auto& p : line) - { - result.emplace_back(p.p_, p.w_, p.perimeter_index_); - } + break; } - if (line.back().p_ == line.front().p_) // avoid seams + point_idx--; + } + if (result.size() < 3) + { + result.clear(); + for (auto& p : line) { - result.back().p_ = result.front().p_; + result.emplace_back(p.p_, p.w_, p.perimeter_index_); } } + if (line.back().p_ == line.front().p_) // avoid seams + { + result.back().p_ = result.front().p_; + } } - part.wall_toolpaths = result_paths; + } + part.wall_toolpaths = result_paths; } } } From cd858c15c9cc50f77314863c611b1fe10c2b4207 Mon Sep 17 00:00:00 2001 From: "saumya.jain" Date: Tue, 13 Feb 2024 17:53:20 +0100 Subject: [PATCH 8/9] removing another non necessary condition CURA-11570 --- src/FffPolygonGenerator.cpp | 8 ++------ src/skin.cpp | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/FffPolygonGenerator.cpp b/src/FffPolygonGenerator.cpp index ff36a1226c..765492eee6 100644 --- a/src/FffPolygonGenerator.cpp +++ b/src/FffPolygonGenerator.cpp @@ -568,11 +568,7 @@ void FffPolygonGenerator::processInfillMesh(SliceDataStorage& storage, const siz // they have to be polylines, because they might break up further when doing the cutting for (SliceLayerPart& part : layer.parts) { - if (part.outline.empty()) - { - continue; - } - for (PolygonRef poly : part.outline) + for (const PolygonRef poly : part.outline) { layer.openPolyLines.add(poly); layer.openPolyLines.back().add(layer.openPolyLines.back()[0]); // add the segment which closes the polygon @@ -644,7 +640,7 @@ void FffPolygonGenerator::processInfillMesh(SliceDataStorage& storage, const siz } layer.parts.clear(); - for (PolygonsPart& part : new_parts) + for (const PolygonsPart& part : new_parts) { if (part.empty()) { diff --git a/src/skin.cpp b/src/skin.cpp index 0fbd302541..842a6e576f 100644 --- a/src/skin.cpp +++ b/src/skin.cpp @@ -154,7 +154,7 @@ void SkinInfillAreaComputation::generateSkinAndInfillAreas(SliceLayerPart& part) generateInfill(part); } - for (PolygonsPart& skin_area_part : skin.splitIntoParts()) + for (const PolygonsPart& skin_area_part : skin.splitIntoParts()) { if (skin_area_part.empty()) { From 1cac0af0d101c161a3a4555987b2b7afd7691ab5 Mon Sep 17 00:00:00 2001 From: Remco Burema Date: Wed, 14 Feb 2024 20:57:04 +0100 Subject: [PATCH 9/9] Code-style. + If const then it can also be a reference. done as part of CURA-11570 --- src/FffGcodeWriter.cpp | 2 ++ src/FffPolygonGenerator.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/FffGcodeWriter.cpp b/src/FffGcodeWriter.cpp index 705ecbebcb..db6cb931e0 100644 --- a/src/FffGcodeWriter.cpp +++ b/src/FffGcodeWriter.cpp @@ -1644,7 +1644,9 @@ void FffGcodeWriter::addMeshLayerToGCode_meshSurfaceMode(const SliceMeshStorage& for (const SliceLayerPart& part : layer->parts) { if (! part.outline.empty()) + { polygons.add(part.outline); + } } polygons = Simplify(mesh.settings).polygon(polygons); diff --git a/src/FffPolygonGenerator.cpp b/src/FffPolygonGenerator.cpp index 765492eee6..4b79053174 100644 --- a/src/FffPolygonGenerator.cpp +++ b/src/FffPolygonGenerator.cpp @@ -568,7 +568,7 @@ void FffPolygonGenerator::processInfillMesh(SliceDataStorage& storage, const siz // they have to be polylines, because they might break up further when doing the cutting for (SliceLayerPart& part : layer.parts) { - for (const PolygonRef poly : part.outline) + for (const PolygonRef& poly : part.outline) { layer.openPolyLines.add(poly); layer.openPolyLines.back().add(layer.openPolyLines.back()[0]); // add the segment which closes the polygon