Refactoring: moved direction-specific methods to new role class Slic3r::Fill::WithDirection
This commit is contained in:
parent
c4d70bcb85
commit
d508be5ae8
@ -1,12 +1,27 @@
|
||||
package Slic3r::Fill::Base;
|
||||
use Moo;
|
||||
|
||||
use Slic3r::Geometry qw(PI rad2deg);
|
||||
|
||||
has 'layer_id' => (is => 'rw');
|
||||
has 'angle' => (is => 'rw'); # in radians, ccw, 0 = East
|
||||
has 'bounding_box' => (is => 'ro', required => 0); # Slic3r::Geometry::BoundingBox object
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
package Slic3r::Fill::WithDirection;
|
||||
use Moo::Role;
|
||||
|
||||
use Slic3r::Geometry qw(PI rad2deg);
|
||||
|
||||
sub angles () { [0, PI/2] }
|
||||
|
||||
sub infill_direction {
|
||||
@ -67,15 +82,4 @@ sub rotate_points_back {
|
||||
$_->rotate(@$rotate) for @$paths;
|
||||
}
|
||||
|
||||
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;
|
||||
|
@ -2,6 +2,7 @@ package Slic3r::Fill::Honeycomb;
|
||||
use Moo;
|
||||
|
||||
extends 'Slic3r::Fill::Base';
|
||||
with qw(Slic3r::Fill::WithDirection);
|
||||
|
||||
has 'cache' => (is => 'rw', default => sub {{}});
|
||||
|
||||
|
@ -2,6 +2,7 @@ package Slic3r::Fill::PlanePath;
|
||||
use Moo;
|
||||
|
||||
extends 'Slic3r::Fill::Base';
|
||||
with qw(Slic3r::Fill::WithDirection);
|
||||
|
||||
use Slic3r::Geometry qw(scale X1 Y1 X2 Y2);
|
||||
use Slic3r::Geometry::Clipper qw(intersection_pl);
|
||||
|
@ -2,6 +2,7 @@ package Slic3r::Fill::Rectilinear;
|
||||
use Moo;
|
||||
|
||||
extends 'Slic3r::Fill::Base';
|
||||
with qw(Slic3r::Fill::WithDirection);
|
||||
|
||||
has 'cache' => (is => 'rw', default => sub {{}});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user