Fixing the infill order for concentric infill to outside-in.

Relies to:
Concentric Fill Start Point - New Feature Request #4948
Feature Request: Archimedean Chords - Option to define direction of travel (Inside-Out or Outside-In) #5214
This commit is contained in:
Vojtech Bubnik 2021-01-06 11:05:22 +01:00
parent 746729e4fa
commit 3c9f3d2b66
5 changed files with 21 additions and 36 deletions

View file

@ -24,22 +24,22 @@ void FillConcentric::_fill_surface_single(
this->spacing = unscale<double>(distance);
}
Polygons loops = (Polygons)expolygon;
Polygons loops = to_polygons(std::move(expolygon));
Polygons last = loops;
while (! last.empty()) {
last = offset2(last, -(distance + min_spacing/2), +min_spacing/2);
loops.insert(loops.end(), last.begin(), last.end());
append(loops, last);
}
// generate paths from the outermost to the innermost, to avoid
// adhesion problems of the first central tiny loops
loops = union_pt_chained(loops, false);
loops = union_pt_chained_outside_in(loops, false);
// split paths using a nearest neighbor search
size_t iPathFirst = polylines_out.size();
Point last_pos(0, 0);
for (const Polygon &loop : loops) {
polylines_out.push_back(loop.split_at_index(last_pos.nearest_point_index(loop.points)));
polylines_out.emplace_back(loop.split_at_index(last_pos.nearest_point_index(loop.points)));
last_pos = polylines_out.back().last_point();
}