2011-09-05 10:21:27 +00:00
|
|
|
package Slic3r::Fill::Rectilinear;
|
2011-09-06 09:50:43 +00:00
|
|
|
use Moo;
|
2011-09-05 10:21:27 +00:00
|
|
|
|
2011-10-06 11:43:32 +00:00
|
|
|
extends 'Slic3r::Fill::Base';
|
|
|
|
|
2011-11-14 09:31:07 +00:00
|
|
|
use Slic3r::Geometry qw(X1 Y1 X2 Y2 A B X);
|
2011-09-05 10:21:27 +00:00
|
|
|
use XXX;
|
|
|
|
|
2011-10-06 11:43:32 +00:00
|
|
|
sub fill_surface {
|
2011-09-05 10:21:27 +00:00
|
|
|
my $self = shift;
|
2011-10-06 11:43:32 +00:00
|
|
|
my ($surface, %params) = @_;
|
|
|
|
|
|
|
|
# rotate polygons so that we can work with vertical lines here
|
2011-11-13 17:14:02 +00:00
|
|
|
my $expolygon = $surface->expolygon;
|
2011-10-07 17:07:57 +00:00
|
|
|
my $rotate_vector = $self->infill_direction($surface);
|
2011-11-13 17:14:02 +00:00
|
|
|
$self->rotate_points($expolygon, $rotate_vector);
|
2011-10-06 11:43:32 +00:00
|
|
|
|
2011-11-13 17:14:02 +00:00
|
|
|
my $bounding_box = [ $expolygon->bounding_box ];
|
2011-11-14 09:31:07 +00:00
|
|
|
my $flow_width_res = $params{flow_width} / $Slic3r::resolution;
|
|
|
|
my $distance_between_lines = $flow_width_res / $params{density};
|
2011-10-06 11:43:32 +00:00
|
|
|
|
2011-10-06 13:24:21 +00:00
|
|
|
my @paths = ();
|
|
|
|
my $x = $bounding_box->[X1];
|
2011-11-14 09:31:07 +00:00
|
|
|
my $is_line_pattern = $self->isa('Slic3r::Fill::Line');
|
|
|
|
my $i = 0;
|
2011-10-06 13:24:21 +00:00
|
|
|
while ($x < $bounding_box->[X2]) {
|
|
|
|
my $vertical_line = [ [$x, $bounding_box->[Y2]], [$x, $bounding_box->[Y1]] ];
|
2011-11-14 09:31:07 +00:00
|
|
|
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);
|
|
|
|
}
|
2011-11-13 17:14:02 +00:00
|
|
|
push @paths, @{ $expolygon->clip_line($vertical_line) };
|
2011-10-06 13:24:21 +00:00
|
|
|
$x += int($distance_between_lines);
|
2011-11-14 09:31:07 +00:00
|
|
|
$i++;
|
2011-09-25 18:09:30 +00:00
|
|
|
}
|
2011-10-06 11:43:32 +00:00
|
|
|
|
|
|
|
# paths must be rotated back
|
|
|
|
$self->rotate_points_back(\@paths, $rotate_vector);
|
|
|
|
|
|
|
|
return @paths;
|
2011-09-05 10:21:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
1;
|