diff --git a/src/libslic3r/Fill/Fill3DHoneycomb.cpp b/src/libslic3r/Fill/Fill3DHoneycomb.cpp index 6c8c099c4..4fcb1ed05 100644 --- a/src/libslic3r/Fill/Fill3DHoneycomb.cpp +++ b/src/libslic3r/Fill/Fill3DHoneycomb.cpp @@ -186,15 +186,18 @@ static Polylines makeGrid(coordf_t z, coordf_t gridSize, coordf_t boundWidth, co // dont_adjust [avoid filling space evenly] // monotonic [fill strictly left to right] // complete [complete each loop] - + void Fill3DHoneycomb::_fill_surface_single( - const FillParams ¶ms, + const FillParams ¶ms, unsigned int thickness_layers, - const std::pair &direction, + const std::pair &direction, ExPolygon expolygon, Polylines &polylines_out) { // no rotation is supported for this infill pattern + // BBL: add support for rotation + auto infill_angle = float(this->angle); + if (std::abs(infill_angle) >= EPSILON) expolygon.rotate(-infill_angle); BoundingBox bb = expolygon.contour.bounding_box(); // Note: with equally-scaled X/Y/Z, the pattern will create a vertically-stretched @@ -216,7 +219,7 @@ void Fill3DHoneycomb::_fill_surface_single( // Z scale is adjusted to make the layer patterns consistent / symmetric // This means that the resultant infill won't be an ideal truncated octahedron, // but it should look better than the equivalent quantised version - + coordf_t layerHeight = scale_(thickness_layers); // ceiling to an integer value of layers per Z // (with a little nudge in case it's close to perfect) @@ -248,7 +251,7 @@ void Fill3DHoneycomb::_fill_surface_single( // (a module is 2*$gridSize since one $gridSize half-module is // growing while the other $gridSize half-module is shrinking) bb.merge(align_to_grid(bb.min, Point(gridSize*4, gridSize*4))); - + // generate pattern Polylines polylines = makeGrid( @@ -257,7 +260,7 @@ void Fill3DHoneycomb::_fill_surface_single( bb.size()(0), bb.size()(1), !params.dont_adjust); - + // move pattern in place for (Polyline &pl : polylines){ pl.translate(bb.min); @@ -266,11 +269,21 @@ void Fill3DHoneycomb::_fill_surface_single( // clip pattern to boundaries, chain the clipped polylines polylines = intersection_pl(polylines, to_polygons(expolygon)); - // connect lines if needed - if (params.dont_connect() || polylines.size() <= 1) + // copy from fliplines + if (!polylines.empty()) { + int infill_start_idx = polylines_out.size(); // only rotate what belongs to us. + // connect lines + if (params.dont_connect() || polylines.size() <= 1) append(polylines_out, chain_polylines(std::move(polylines))); - else + else this->connect_infill(std::move(polylines), expolygon, polylines_out, this->spacing, params); + + // rotate back + if (std::abs(infill_angle) >= EPSILON) { + for (auto it = polylines_out.begin() + infill_start_idx; it != polylines_out.end(); ++it) + it->rotate(infill_angle); + } + } } } // namespace Slic3r \ No newline at end of file