Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cura 11129 wall roofing #2024

Closed
wants to merge 10 commits into from
Closed
61 changes: 2 additions & 59 deletions src/LayerPlan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -774,69 +774,12 @@ void LayerPlan::addWallLine(
return roofing_mask_.empty() || PolygonUtils::polygonCollidesWithLineSegment(roofing_mask_, p0, p1) || ! roofing_mask_.inside(p1, true);
}();

if (use_roofing_config)
{
// The line segment is wholly or partially in the roofing area. The line is intersected
// with the roofing area into line segments. Each line segment left in this intersection
// will be printed using the roofing config, all removed segments will be printed using
// the default_config. Since the original line segment was straight we can simply print
// to the first and last point of the intersected line segments alternating between
// roofing and default_config's.
Polygons line_polys;
line_polys.addLine(p0, p1);
constexpr bool restitch = false; // only a single line doesn't need stitching
auto has_area_above_poly_lines = roofing_mask_.intersectionPolyLines(line_polys, restitch);

if (has_area_above_poly_lines.empty())
{
addExtrusionMove(p1, roofing_config, SpaceFillType::Polygons, flow, width_factor, spiralize, 1.0_r);
}
else
{
// reorder all the line segments so all lines start at p0 and end at p1
for (auto& line_poly : has_area_above_poly_lines)
{
const Point2LL& line_p0 = line_poly.front();
const Point2LL& line_p1 = line_poly.back();
if (vSize2(line_p1 - p0) < vSize2(line_p0 - p0))
{
std::reverse(line_poly.begin(), line_poly.end());
}
}
std::sort(
has_area_above_poly_lines.begin(),
has_area_above_poly_lines.end(),
[&](auto& a, auto& b)
{
return vSize2(a.front() - p0) < vSize2(b.front() - p0);
});

// add intersected line segments, alternating between roofing and default_config
for (const auto& line_poly : has_area_above_poly_lines)
{
// This is only relevant for the very fist iteration of the loop
// if the start of the line segment is already the same as p0 then no move is required
if (line_poly.front() != p0)
{
addExtrusionMove(line_poly.front(), roofing_config, SpaceFillType::Polygons, flow, width_factor, spiralize, 1.0_r);
}

addExtrusionMove(line_poly.back(), default_config, SpaceFillType::Polygons, flow, width_factor, spiralize, 1.0_r);
}

// if the last point is not yet at p1 then add a move to p1
if (has_area_above_poly_lines.back().back() != p1)
{
addExtrusionMove(p1, roofing_config, SpaceFillType::Polygons, flow, width_factor, spiralize, 1.0_r);
}
}
}
else if (bridge_wall_mask_.empty())
if (bridge_wall_mask_.empty())
{
// no bridges required
addExtrusionMove(
p1,
default_config,
roofing_config,
SpaceFillType::Polygons,
flow,
width_factor,
Expand Down
Loading