Skip to content

Commit

Permalink
Refactor a little for DRY reasons.
Browse files Browse the repository at this point in the history
done as part of CURA-8076
  • Loading branch information
rburema committed Jun 11, 2024
1 parent a9c1d1b commit 9db7c74
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions src/FffGcodeWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2674,28 +2674,21 @@ bool FffGcodeWriter::processInsets(
gcode_layer.setBridgeWallMask(Shape());
}

const AngleDegrees overhang_angle = mesh.settings.get<AngleDegrees>("wall_overhang_angle");
Shape overhang_region; // keep empty to disable overhang detection
if (overhang_angle < 90)
const auto get_overhang_region = [&](const AngleDegrees overhang_angle) -> Shape
{
if (overhang_angle >= 90)
{
return Shape(); // keep empty to disable overhang detection
}
// the overhang mask is set to the area of the current part's outline minus the region that is considered to be supported
// the supported region is made up of those areas that really are supported by either model or support on the layer below
// expanded to take into account the overhang angle, the greater the overhang angle, the larger the supported area is
// considered to be
const coord_t overhang_width = layer_height * std::tan(overhang_angle / (180 / std::numbers::pi));
overhang_region = part.outline.offset(-half_outer_wall_width).difference(outlines_below.offset(10 + overhang_width - half_outer_wall_width)).offset(10);
}
gcode_layer.setOverhangMask(overhang_region);

// As above, but for the seam overhang mask instead of the wall one.
const AngleDegrees seam_overhang_angle = mesh.settings.get<AngleDegrees>("seam_overhang_angle");
Shape seam_overhang_region; // keep empty to disable overhang detection w.r.t. seams
if (seam_overhang_angle < 90)
{
const coord_t overhang_width = layer_height * std::tan(seam_overhang_angle / (180 / std::numbers::pi));
seam_overhang_region = part.outline.offset(-half_outer_wall_width).difference(outlines_below.offset(10 + overhang_width - half_outer_wall_width)).offset(10);
}
gcode_layer.setSeamOverhangMask(seam_overhang_region);
return part.outline.offset(-half_outer_wall_width).difference(outlines_below.offset(10 + overhang_width - half_outer_wall_width)).offset(10);
};
gcode_layer.setOverhangMask(get_overhang_region(mesh.settings.get<AngleDegrees>("wall_overhang_angle")));
gcode_layer.setSeamOverhangMask(get_overhang_region(mesh.settings.get<AngleDegrees>("seam_overhang_angle")));

const auto roofing_mask_fn = [&]() -> Shape
{
Expand Down

0 comments on commit 9db7c74

Please sign in to comment.