Implemented a new "line" fill pattern. #20

This commit is contained in:
Alessandro Ranellucci 2011-11-14 10:31:07 +01:00
parent d47a7bebbc
commit 86f3e4fcd2
4 changed files with 21 additions and 3 deletions

View File

@ -89,7 +89,7 @@ our $Options = {
'fill_pattern' => { 'fill_pattern' => {
label => 'Fill pattern', label => 'Fill pattern',
type => 'select', type => 'select',
values => [qw(rectilinear hilbertcurve archimedeanchords octagramspiral)], values => [qw(rectilinear line hilbertcurve archimedeanchords octagramspiral)],
}, },
'solid_fill_pattern' => { 'solid_fill_pattern' => {
label => 'Solid fill pattern', label => 'Solid fill pattern',

View File

@ -5,6 +5,7 @@ use Slic3r::Fill::ArchimedeanChords;
use Slic3r::Fill::Base; use Slic3r::Fill::Base;
use Slic3r::Fill::Flowsnake; use Slic3r::Fill::Flowsnake;
use Slic3r::Fill::HilbertCurve; use Slic3r::Fill::HilbertCurve;
use Slic3r::Fill::Line;
use Slic3r::Fill::OctagramSpiral; use Slic3r::Fill::OctagramSpiral;
use Slic3r::Fill::Rectilinear; use Slic3r::Fill::Rectilinear;
use Slic3r::Fill::Rectilinear2; use Slic3r::Fill::Rectilinear2;
@ -22,6 +23,7 @@ our %FillTypes = (
flowsnake => 'Slic3r::Fill::Flowsnake', flowsnake => 'Slic3r::Fill::Flowsnake',
octagramspiral => 'Slic3r::Fill::OctagramSpiral', octagramspiral => 'Slic3r::Fill::OctagramSpiral',
hilbertcurve => 'Slic3r::Fill::HilbertCurve', hilbertcurve => 'Slic3r::Fill::HilbertCurve',
line => 'Slic3r::Fill::Line',
); );
sub BUILD { sub BUILD {

8
lib/Slic3r/Fill/Line.pm Normal file
View File

@ -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;

View File

@ -3,7 +3,7 @@ use Moo;
extends 'Slic3r::Fill::Base'; 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; use XXX;
sub fill_surface { sub fill_surface {
@ -16,14 +16,22 @@ sub fill_surface {
$self->rotate_points($expolygon, $rotate_vector); $self->rotate_points($expolygon, $rotate_vector);
my $bounding_box = [ $expolygon->bounding_box ]; 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 @paths = ();
my $x = $bounding_box->[X1]; my $x = $bounding_box->[X1];
my $is_line_pattern = $self->isa('Slic3r::Fill::Line');
my $i = 0;
while ($x < $bounding_box->[X2]) { while ($x < $bounding_box->[X2]) {
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) {
$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) }; push @paths, @{ $expolygon->clip_line($vertical_line) };
$x += int($distance_between_lines); $x += int($distance_between_lines);
$i++;
} }
# paths must be rotated back # paths must be rotated back