Fixed regression of the gyroid infill.

This commit is contained in:
bubnikv 2018-04-05 10:31:53 +02:00
parent 00324a14b8
commit 4611b5094e
2 changed files with 12 additions and 13 deletions

View File

@ -55,10 +55,10 @@ static inline Polyline make_wave_horizontal(
return polyline; return polyline;
} }
static Polylines make_gyroid_waves(double gridZ, double density, double layer_width, double width, double height) static Polylines make_gyroid_waves(double gridZ, double density_adjusted, double line_spacing, double width, double height)
{ {
double scaleFactor = scale_(layer_width) / density; double scaleFactor = scale_(line_spacing) / density_adjusted;
double segmentSize = 0.5 * density; double segmentSize = 0.5 * density_adjusted;
//scale factor for 5% : 8 712 388 //scale factor for 5% : 8 712 388
// 1z = 10^-6 mm ? // 1z = 10^-6 mm ?
double z = gridZ / scaleFactor; double z = gridZ / scaleFactor;
@ -74,7 +74,7 @@ static Polylines make_gyroid_waves(double gridZ, double density, double layer_wi
} else { } else {
// Horizontal wave // Horizontal wave
bool flip = true; bool flip = true;
for (double y0 = 0.; y0 < width; y0 += M_PI, flip = !flip) for (double y0 = 0.; y0 < height; y0 += M_PI, flip = !flip)
result.emplace_back(make_wave_horizontal(width, height, y0, segmentSize, scaleFactor, z_cos, z_sin, flip)); result.emplace_back(make_wave_horizontal(width, height, y0, segmentSize, scaleFactor, z_cos, z_sin, flip));
} }
return result; return result;
@ -87,17 +87,20 @@ void FillGyroid::_fill_surface_single(
ExPolygon &expolygon, ExPolygon &expolygon,
Polylines &polylines_out) Polylines &polylines_out)
{ {
// no rotation is supported for this infill pattern // no rotation is supported for this infill pattern (yet)
BoundingBox bb = expolygon.contour.bounding_box(); BoundingBox bb = expolygon.contour.bounding_box();
coord_t distance = coord_t(scale_(this->spacing) / (params.density*this->scaling)); // Density adjusted to have a good %of weight.
double density_adjusted = params.density * 1.75;
// Distance between the gyroid waves in scaled coordinates.
coord_t distance = coord_t(scale_(this->spacing) / density_adjusted);
// align bounding box to a multiple of our grid module // align bounding box to a multiple of our grid module
bb.merge(_align_to_grid(bb.min, Point(2*M_PI*distance, 2*M_PI*distance))); bb.merge(_align_to_grid(bb.min, Point(2.*M_PI*distance, 2.*M_PI*distance)));
// generate pattern // generate pattern
Polylines polylines = make_gyroid_waves( Polylines polylines = make_gyroid_waves(
scale_(this->z), scale_(this->z),
params.density*this->scaling, density_adjusted,
this->spacing, this->spacing,
ceil(bb.size().x / distance) + 1., ceil(bb.size().x / distance) + 1.,
ceil(bb.size().y / distance) + 1.); ceil(bb.size().y / distance) + 1.);

View File

@ -17,10 +17,6 @@ public:
virtual bool use_bridge_flow() const { return true; } virtual bool use_bridge_flow() const { return true; }
protected: protected:
// mult of density, to have a good %of weight for each density parameter
float scaling = 1.75;
virtual void _fill_surface_single( virtual void _fill_surface_single(
const FillParams &params, const FillParams &params,
unsigned int thickness_layers, unsigned int thickness_layers,