Adjust flow for solid surfaces when using concentric infill too. #120
This commit is contained in:
parent
6a3eeef83b
commit
eca6d0b6d0
3 changed files with 33 additions and 19 deletions
|
@ -58,4 +58,15 @@ sub rotate_points_back {
|
|||
}
|
||||
}
|
||||
|
||||
sub adjust_solid_spacing {
|
||||
my $self = shift;
|
||||
my %params = @_;
|
||||
|
||||
my $number_of_lines = int($params{width} / $params{distance}) + 1;
|
||||
return $params{distance} if $number_of_lines <= 1;
|
||||
|
||||
my $extra_space = $params{width} % $params{distance};
|
||||
return $params{distance} + $extra_space / ($number_of_lines - 1);
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -3,7 +3,7 @@ use Moo;
|
|||
|
||||
extends 'Slic3r::Fill::Base';
|
||||
|
||||
use Slic3r::Geometry qw(scale X1 Y1 X2 Y2);
|
||||
use Slic3r::Geometry qw(scale unscale X1 Y1 X2 Y2);
|
||||
use XXX;
|
||||
|
||||
sub fill_surface {
|
||||
|
@ -12,21 +12,25 @@ sub fill_surface {
|
|||
|
||||
# no rotation is supported for this infill pattern
|
||||
|
||||
my $bounding_box = [ $surface->expolygon->bounding_box ];
|
||||
my $expolygon = $surface->expolygon;
|
||||
my $bounding_box = [ $expolygon->bounding_box ];
|
||||
|
||||
my $scaled_flow_spacing = scale $params{flow_spacing};
|
||||
my $distance = $scaled_flow_spacing / $params{density};
|
||||
# TODO: adjust distance and flow width for solid surfaces
|
||||
# using the same logic as Rectilinear infill
|
||||
# (factor it out to parent class)
|
||||
my $min_spacing = scale $params{flow_spacing};
|
||||
my $distance = $min_spacing / $params{density};
|
||||
|
||||
$distance = $self->adjust_solid_spacing(
|
||||
width => $bounding_box->[X2] - $bounding_box->[X1],
|
||||
distance => $distance,
|
||||
) if $params{density} == 1;
|
||||
my $flow_spacing = unscale $distance;
|
||||
|
||||
my @contour_loops = ();
|
||||
my @hole_loops = ();
|
||||
my @last_offsets = ($surface->expolygon->offset_ex($distance));
|
||||
my @last_offsets = ($expolygon->offset_ex($distance));
|
||||
while (@last_offsets) {
|
||||
my @new_offsets = ();
|
||||
foreach my $expolygon (@last_offsets) {
|
||||
my @offsets = $expolygon->offset_ex(-$distance);
|
||||
foreach my $last_expolygon (@last_offsets) {
|
||||
my @offsets = $last_expolygon->offset_ex(-$distance);
|
||||
foreach my $offset (@offsets) {
|
||||
push @new_offsets, $offset;
|
||||
push @contour_loops, $offset->contour;
|
||||
|
@ -57,7 +61,7 @@ sub fill_surface {
|
|||
push @paths, $path->p if @{$path->points};
|
||||
}
|
||||
|
||||
return {}, @paths;
|
||||
return { flow_spacing => $flow_spacing }, @paths;
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -23,19 +23,18 @@ sub fill_surface {
|
|||
my $distance_between_lines = $min_spacing / $params{density};
|
||||
my $line_oscillation = $distance_between_lines - $min_spacing;
|
||||
|
||||
my $number_of_lines = int(($bounding_box->[X2] - $bounding_box->[X1]) / $distance_between_lines) + 1;
|
||||
my $flow_spacing = undef;
|
||||
if ($params{density} == 1) {
|
||||
my $extra_space = ($bounding_box->[X2] - $bounding_box->[X1]) % $distance_between_lines;
|
||||
$distance_between_lines += $extra_space / ($number_of_lines - 1) if $number_of_lines > 1;
|
||||
$flow_spacing = unscale $distance_between_lines;
|
||||
}
|
||||
$distance_between_lines = $self->adjust_solid_spacing(
|
||||
width => $bounding_box->[X2] - $bounding_box->[X1],
|
||||
distance => $distance_between_lines,
|
||||
) if $params{density} == 1;
|
||||
my $flow_spacing = unscale $distance_between_lines;
|
||||
|
||||
my $overlap_distance = $Slic3r::nozzle_diameter * 0.20;
|
||||
|
||||
my @paths = ();
|
||||
my $x = $bounding_box->[X1];
|
||||
my $is_line_pattern = $self->isa('Slic3r::Fill::Line');
|
||||
for (my $i = 0; $i < $number_of_lines; $i++) {
|
||||
for (my $i = 0; $x <= $bounding_box->[X2]; $i++) {
|
||||
my $vertical_line = [ [$x, $bounding_box->[Y2]], [$x, $bounding_box->[Y1]] ];
|
||||
if ($is_line_pattern && $i % 2) {
|
||||
$vertical_line->[A][X] -= $line_oscillation;
|
||||
|
|
Loading…
Add table
Reference in a new issue