Skip to content

Commit

Permalink
Cura 11570 engine crashes sentry (#2029)
Browse files Browse the repository at this point in the history
  • Loading branch information
rburema authored Feb 14, 2024
2 parents dca51ea + 1cac0af commit 3e76b8a
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 7 deletions.
10 changes: 8 additions & 2 deletions src/FffGcodeWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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<const SliceLayerPart*>& path : part_order_optimizer.paths_)
{
addMeshPartToGCode(storage, mesh, extruder_nr, mesh_config, *path.vertices_, gcode_layer);
Expand Down
10 changes: 7 additions & 3 deletions src/FffPolygonGenerator.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2023 UltiMaker
// Copyright (c) 2024 UltiMaker
// CuraEngine is released under the terms of the AGPLv3 or higher

#include <algorithm>
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions src/layerPart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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())
Expand Down
6 changes: 5 additions & 1 deletion src/skin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
5 changes: 4 additions & 1 deletion src/sliceDataStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
4 changes: 4 additions & 0 deletions src/support.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3e76b8a

Please sign in to comment.