Skip to content

Commit

Permalink
Revert roofing logic
Browse files Browse the repository at this point in the history
We should later re-introduce this but at this moment the removed code caused too much of a performance decrease.

CURA-11388
  • Loading branch information
casperlamboo committed Jan 10, 2024
1 parent d73a2cb commit 29f7359
Showing 1 changed file with 1 addition and 92 deletions.
93 changes: 1 addition & 92 deletions src/FffGcodeWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2529,98 +2529,7 @@ bool FffGcodeWriter::processInsets(
}
else
{
// for layers that (partially) do not have any layers above we apply the roofing configuration
auto use_roofing_config = [&part, &mesh, &gcode_layer]()
{
const auto getOutlineOnLayer = [mesh](const SliceLayerPart& part_here, const LayerIndex layer2_nr) -> Polygons
{
Polygons result;
if (layer2_nr >= static_cast<int>(mesh.layers.size()))
{
return result;
}
const SliceLayer& layer2 = mesh.layers[layer2_nr];
for (const SliceLayerPart& part2 : layer2.parts)
{
if (part_here.boundaryBox.hit(part2.boundaryBox))
{
result.add(part2.outline);
}
}
return result;
};

const auto filled_area_above = [&getOutlineOnLayer, &part, &mesh, &gcode_layer]() -> Polygons
{
const size_t roofing_layer_count = std::min(mesh.settings.get<size_t>("roofing_layer_count"), mesh.settings.get<size_t>("top_layers"));
const bool no_small_gaps_heuristic = mesh.settings.get<bool>("skin_no_small_gaps_heuristic");
const int layer_nr = gcode_layer.getLayerNr();
auto filled_area_above_res = getOutlineOnLayer(part, layer_nr + roofing_layer_count);
if (! no_small_gaps_heuristic)
{
for (int layer_nr_above = layer_nr + 1; layer_nr_above < layer_nr + roofing_layer_count; layer_nr_above++)
{
Polygons outlines_above = getOutlineOnLayer(part, layer_nr_above);
filled_area_above_res = filled_area_above_res.intersection(outlines_above);
}
}
if (layer_nr > 0)
{
// if the skin has air below it then cutting it into regions could cause a region
// to be wholely or partly above air and it may not be printable so restrict
// the regions that have air above (the visible regions) to not include any area that
// has air below (fixes https://github.com/Ultimaker/Cura/issues/2656)

// set air_below to the skin area for the current layer that has air below it
Polygons air_below = getOutlineOnLayer(part, layer_nr).difference(getOutlineOnLayer(part, layer_nr - 1));

if (! air_below.empty())
{
// add the polygons that have air below to the no air above polygons
filled_area_above_res = filled_area_above_res.unionPolygons(air_below);
}
}

return filled_area_above_res;
}();

if (filled_area_above.empty())
{
return true;
}

const auto point_view = ranges::views::transform(
[](auto extrusion_junction)
{
return extrusion_junction.p_;
});

for (const auto& path : part.wall_toolpaths)
{
for (const auto& wall : path)
{
for (const auto& p : wall | point_view)
{
if (! filled_area_above.inside(p))
{
return true;
}
}

for (const auto& window : wall | point_view | ranges::views::sliding(2))
{
auto p0 = window[0];
auto p1 = window[1];
if (PolygonUtils::polygonCollidesWithLineSegment(filled_area_above, p0, p1))
{
return true;
}
}
}
}
return false;
}();

auto use_roofing_config = false;
const GCodePathConfig& inset0_config = use_roofing_config ? mesh_config.inset0_roofing_config : mesh_config.inset0_config;
const GCodePathConfig& insetX_config = use_roofing_config ? mesh_config.insetX_roofing_config : mesh_config.insetX_config;

Expand Down

0 comments on commit 29f7359

Please sign in to comment.