optimize cross hatch infill to enchance strength (#5495)

Optimize the cross-hatch infill pattern to improve strength when low infill density is used.
This commit is contained in:
SoftFever 2024-05-29 23:03:47 +08:00 committed by GitHub
parent c14ae13788
commit 8b1bf13021
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,6 +1,7 @@
#include "../ClipperUtils.hpp"
#include "../ShortestPath.hpp"
#include "../Surface.hpp"
#include <cmath>
#include "FillCrossHatch.hpp"
@ -193,7 +194,12 @@ void FillCrossHatch ::_fill_surface_single(
bb.merge(align_to_grid(bb.min, Point(line_spacing * 4, line_spacing * 4)));
// generate pattern
Polylines polylines = generate_infill_layers(scale_(this->z), 1, line_spacing, bb.size()(0), bb.size()(1));
//Orca: optimize the cross-hatch infill pattern to improve strength when low infill density is used.
double repeat_ratio = 1.0;
if (params.density < 0.3)
repeat_ratio = std::clamp(1.0 - std::exp(-5 * params.density), 0.2, 1.0);
Polylines polylines = generate_infill_layers(scale_(this->z), repeat_ratio, line_spacing, bb.size()(0), bb.size()(1));
// shift the pattern to the actual space
for (Polyline &pl : polylines) { pl.translate(bb.min); }