diff --git a/src/FffGcodeWriter.cpp b/src/FffGcodeWriter.cpp index 6008826fbf..db6cb931e0 100644 --- a/src/FffGcodeWriter.cpp +++ b/src/FffGcodeWriter.cpp @@ -1643,7 +1643,10 @@ 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 +1710,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); diff --git a/src/FffPolygonGenerator.cpp b/src/FffPolygonGenerator.cpp index 384093794c..4b79053174 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 @@ -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 (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 @@ -640,8 +640,12 @@ void FffPolygonGenerator::processInfillMesh(SliceDataStorage& storage, const siz } layer.parts.clear(); - for (PolygonsPart& part : new_parts) + for (const PolygonsPart& part : new_parts) { + if (part.empty()) + { + continue; + } layer.parts.emplace_back(); layer.parts.back().outline = part; layer.parts.back().boundaryBox.calculate(part); 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..842a6e576f 100644 --- a/src/skin.cpp +++ b/src/skin.cpp @@ -154,8 +154,12 @@ 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()) + { + 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