diff --git a/lib/Slic3r/Config.pm b/lib/Slic3r/Config.pm index 430e872b4..6d5f081db 100644 --- a/lib/Slic3r/Config.pm +++ b/lib/Slic3r/Config.pm @@ -89,7 +89,7 @@ our $Options = { 'fill_pattern' => { label => 'Fill pattern', type => 'select', - values => [qw(rectilinear hilbertcurve archimedeanchords octagramspiral)], + values => [qw(rectilinear line hilbertcurve archimedeanchords octagramspiral)], }, 'solid_fill_pattern' => { label => 'Solid fill pattern', diff --git a/lib/Slic3r/Fill.pm b/lib/Slic3r/Fill.pm index c6dc88d65..6a20f11b2 100644 --- a/lib/Slic3r/Fill.pm +++ b/lib/Slic3r/Fill.pm @@ -5,6 +5,7 @@ use Slic3r::Fill::ArchimedeanChords; use Slic3r::Fill::Base; use Slic3r::Fill::Flowsnake; use Slic3r::Fill::HilbertCurve; +use Slic3r::Fill::Line; use Slic3r::Fill::OctagramSpiral; use Slic3r::Fill::Rectilinear; use Slic3r::Fill::Rectilinear2; @@ -22,6 +23,7 @@ our %FillTypes = ( flowsnake => 'Slic3r::Fill::Flowsnake', octagramspiral => 'Slic3r::Fill::OctagramSpiral', hilbertcurve => 'Slic3r::Fill::HilbertCurve', + line => 'Slic3r::Fill::Line', ); sub BUILD { diff --git a/lib/Slic3r/Fill/Line.pm b/lib/Slic3r/Fill/Line.pm new file mode 100644 index 000000000..97dc17cfd --- /dev/null +++ b/lib/Slic3r/Fill/Line.pm @@ -0,0 +1,8 @@ +package Slic3r::Fill::Line; +use Moo; + +extends 'Slic3r::Fill::Rectilinear'; + +# Sorry for breaking OOP, but Line is implemented inside Rectilinear. + +1; diff --git a/lib/Slic3r/Fill/Rectilinear.pm b/lib/Slic3r/Fill/Rectilinear.pm index 039865312..d1f23b392 100644 --- a/lib/Slic3r/Fill/Rectilinear.pm +++ b/lib/Slic3r/Fill/Rectilinear.pm @@ -3,7 +3,7 @@ use Moo; extends 'Slic3r::Fill::Base'; -use Slic3r::Geometry qw(X1 Y1 X2 Y2); +use Slic3r::Geometry qw(X1 Y1 X2 Y2 A B X); use XXX; sub fill_surface { @@ -16,14 +16,22 @@ sub fill_surface { $self->rotate_points($expolygon, $rotate_vector); my $bounding_box = [ $expolygon->bounding_box ]; - my $distance_between_lines = $params{flow_width} / $Slic3r::resolution / $params{density}; + my $flow_width_res = $params{flow_width} / $Slic3r::resolution; + my $distance_between_lines = $flow_width_res / $params{density}; my @paths = (); my $x = $bounding_box->[X1]; + my $is_line_pattern = $self->isa('Slic3r::Fill::Line'); + my $i = 0; while ($x < $bounding_box->[X2]) { my $vertical_line = [ [$x, $bounding_box->[Y2]], [$x, $bounding_box->[Y1]] ]; + if ($is_line_pattern && $i % 2) { + $vertical_line->[A][X] -= ($distance_between_lines - $flow_width_res); + $vertical_line->[B][X] += ($distance_between_lines - $flow_width_res); + } push @paths, @{ $expolygon->clip_line($vertical_line) }; $x += int($distance_between_lines); + $i++; } # paths must be rotated back