mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-05-21 20:18:17 +08:00
Adjust flow for solid surfaces when using concentric infill too. #120
This commit is contained in:
parent
6a3eeef83b
commit
eca6d0b6d0
@ -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;
|
1;
|
||||||
|
@ -3,7 +3,7 @@ use Moo;
|
|||||||
|
|
||||||
extends 'Slic3r::Fill::Base';
|
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;
|
use XXX;
|
||||||
|
|
||||||
sub fill_surface {
|
sub fill_surface {
|
||||||
@ -12,21 +12,25 @@ sub fill_surface {
|
|||||||
|
|
||||||
# no rotation is supported for this infill pattern
|
# 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 $min_spacing = scale $params{flow_spacing};
|
||||||
my $distance = $scaled_flow_spacing / $params{density};
|
my $distance = $min_spacing / $params{density};
|
||||||
# TODO: adjust distance and flow width for solid surfaces
|
|
||||||
# using the same logic as Rectilinear infill
|
$distance = $self->adjust_solid_spacing(
|
||||||
# (factor it out to parent class)
|
width => $bounding_box->[X2] - $bounding_box->[X1],
|
||||||
|
distance => $distance,
|
||||||
|
) if $params{density} == 1;
|
||||||
|
my $flow_spacing = unscale $distance;
|
||||||
|
|
||||||
my @contour_loops = ();
|
my @contour_loops = ();
|
||||||
my @hole_loops = ();
|
my @hole_loops = ();
|
||||||
my @last_offsets = ($surface->expolygon->offset_ex($distance));
|
my @last_offsets = ($expolygon->offset_ex($distance));
|
||||||
while (@last_offsets) {
|
while (@last_offsets) {
|
||||||
my @new_offsets = ();
|
my @new_offsets = ();
|
||||||
foreach my $expolygon (@last_offsets) {
|
foreach my $last_expolygon (@last_offsets) {
|
||||||
my @offsets = $expolygon->offset_ex(-$distance);
|
my @offsets = $last_expolygon->offset_ex(-$distance);
|
||||||
foreach my $offset (@offsets) {
|
foreach my $offset (@offsets) {
|
||||||
push @new_offsets, $offset;
|
push @new_offsets, $offset;
|
||||||
push @contour_loops, $offset->contour;
|
push @contour_loops, $offset->contour;
|
||||||
@ -57,7 +61,7 @@ sub fill_surface {
|
|||||||
push @paths, $path->p if @{$path->points};
|
push @paths, $path->p if @{$path->points};
|
||||||
}
|
}
|
||||||
|
|
||||||
return {}, @paths;
|
return { flow_spacing => $flow_spacing }, @paths;
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -23,19 +23,18 @@ sub fill_surface {
|
|||||||
my $distance_between_lines = $min_spacing / $params{density};
|
my $distance_between_lines = $min_spacing / $params{density};
|
||||||
my $line_oscillation = $distance_between_lines - $min_spacing;
|
my $line_oscillation = $distance_between_lines - $min_spacing;
|
||||||
|
|
||||||
my $number_of_lines = int(($bounding_box->[X2] - $bounding_box->[X1]) / $distance_between_lines) + 1;
|
$distance_between_lines = $self->adjust_solid_spacing(
|
||||||
my $flow_spacing = undef;
|
width => $bounding_box->[X2] - $bounding_box->[X1],
|
||||||
if ($params{density} == 1) {
|
distance => $distance_between_lines,
|
||||||
my $extra_space = ($bounding_box->[X2] - $bounding_box->[X1]) % $distance_between_lines;
|
) if $params{density} == 1;
|
||||||
$distance_between_lines += $extra_space / ($number_of_lines - 1) if $number_of_lines > 1;
|
my $flow_spacing = unscale $distance_between_lines;
|
||||||
$flow_spacing = unscale $distance_between_lines;
|
|
||||||
}
|
|
||||||
my $overlap_distance = $Slic3r::nozzle_diameter * 0.20;
|
my $overlap_distance = $Slic3r::nozzle_diameter * 0.20;
|
||||||
|
|
||||||
my @paths = ();
|
my @paths = ();
|
||||||
my $x = $bounding_box->[X1];
|
my $x = $bounding_box->[X1];
|
||||||
my $is_line_pattern = $self->isa('Slic3r::Fill::Line');
|
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]] ];
|
my $vertical_line = [ [$x, $bounding_box->[Y2]], [$x, $bounding_box->[Y1]] ];
|
||||||
if ($is_line_pattern && $i % 2) {
|
if ($is_line_pattern && $i % 2) {
|
||||||
$vertical_line->[A][X] -= $line_oscillation;
|
$vertical_line->[A][X] -= $line_oscillation;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user