Get rid of max_print_dimension in filler objects
This commit is contained in:
parent
6c97e588b1
commit
20e73face2
4 changed files with 9 additions and 23 deletions
|
@ -144,6 +144,11 @@ sub bounding_box_polygon {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub bounding_box_center {
|
||||||
|
my $self = shift;
|
||||||
|
return Slic3r::Geometry::bounding_box_center($self->contour);
|
||||||
|
}
|
||||||
|
|
||||||
sub clip_line {
|
sub clip_line {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my ($line) = @_; # line must be a Slic3r::Line object
|
my ($line) = @_; # line must be a Slic3r::Line object
|
||||||
|
|
|
@ -18,7 +18,6 @@ use Slic3r::Surface ':types';
|
||||||
|
|
||||||
|
|
||||||
has 'print' => (is => 'ro', required => 1);
|
has 'print' => (is => 'ro', required => 1);
|
||||||
has 'max_print_dimension' => (is => 'rw');
|
|
||||||
has 'fillers' => (is => 'rw', default => sub { {} });
|
has 'fillers' => (is => 'rw', default => sub { {} });
|
||||||
|
|
||||||
our %FillTypes = (
|
our %FillTypes = (
|
||||||
|
@ -32,26 +31,13 @@ our %FillTypes = (
|
||||||
honeycomb => 'Slic3r::Fill::Honeycomb',
|
honeycomb => 'Slic3r::Fill::Honeycomb',
|
||||||
);
|
);
|
||||||
|
|
||||||
sub BUILD {
|
|
||||||
my $self = shift;
|
|
||||||
|
|
||||||
my $print_size = $self->print->size;
|
|
||||||
my $max_print_dimension = ($print_size->[X] > $print_size->[Y] ? $print_size->[X] : $print_size->[Y]) * sqrt(2);
|
|
||||||
$self->max_print_dimension($max_print_dimension);
|
|
||||||
|
|
||||||
$self->filler($_) for ('rectilinear', $Slic3r::Config->fill_pattern, $Slic3r::Config->solid_fill_pattern);
|
|
||||||
}
|
|
||||||
|
|
||||||
sub filler {
|
sub filler {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my ($filler) = @_;
|
my ($filler) = @_;
|
||||||
|
|
||||||
if (!$self->fillers->{$filler}) {
|
if (!$self->fillers->{$filler}) {
|
||||||
my $f = $FillTypes{$filler}->new(
|
my $f = $self->fillers->{$filler} = $FillTypes{$filler}->new;
|
||||||
max_print_dimension => $self->max_print_dimension
|
|
||||||
);
|
|
||||||
$f->bounding_box([ $self->print->bounding_box ]) if $filler->can('bounding_box');
|
$f->bounding_box([ $self->print->bounding_box ]) if $filler->can('bounding_box');
|
||||||
$self->fillers->{$filler} = $f;
|
|
||||||
}
|
}
|
||||||
return $self->fillers->{$filler};
|
return $self->fillers->{$filler};
|
||||||
}
|
}
|
||||||
|
@ -155,7 +141,7 @@ sub make_fill {
|
||||||
next SURFACE unless $density > 0;
|
next SURFACE unless $density > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
my @paths = $self->fillers->{$filler}->fill_surface(
|
my @paths = $self->filler($filler)->fill_surface(
|
||||||
$surface,
|
$surface,
|
||||||
density => $density,
|
density => $density,
|
||||||
flow_spacing => $flow_spacing,
|
flow_spacing => $flow_spacing,
|
||||||
|
|
|
@ -3,9 +3,7 @@ use Moo;
|
||||||
|
|
||||||
use Slic3r::Geometry qw(PI);
|
use Slic3r::Geometry qw(PI);
|
||||||
|
|
||||||
has 'print' => (is => 'rw');
|
|
||||||
has 'layer_id' => (is => 'rw');
|
has 'layer_id' => (is => 'rw');
|
||||||
has 'max_print_dimension' => (is => 'rw');
|
|
||||||
has 'angle' => (is => 'rw', default => sub { $Slic3r::Config->fill_angle });
|
has 'angle' => (is => 'rw', default => sub { $Slic3r::Config->fill_angle });
|
||||||
|
|
||||||
sub angles () { [0, PI/2] }
|
sub angles () { [0, PI/2] }
|
||||||
|
@ -17,7 +15,7 @@ sub infill_direction {
|
||||||
# set infill angle
|
# set infill angle
|
||||||
my (@rotate, @shift);
|
my (@rotate, @shift);
|
||||||
$rotate[0] = Slic3r::Geometry::deg2rad($self->angle);
|
$rotate[0] = Slic3r::Geometry::deg2rad($self->angle);
|
||||||
$rotate[1] = [ $self->max_print_dimension * sqrt(2) / 2, $self->max_print_dimension * sqrt(2) / 2 ];
|
$rotate[1] = $surface->expolygon->bounding_box_center;
|
||||||
@shift = @{$rotate[1]};
|
@shift = @{$rotate[1]};
|
||||||
|
|
||||||
if (defined $self->layer_id) {
|
if (defined $self->layer_id) {
|
||||||
|
|
5
t/fill.t
5
t/fill.t
|
@ -29,10 +29,7 @@ sub scale_points (@) { map [scale $_->[X], scale $_->[Y]], @_ }
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
my $filler = Slic3r::Fill::Rectilinear->new(
|
my $filler = Slic3r::Fill::Rectilinear->new;
|
||||||
print => Slic3r::Print->new,
|
|
||||||
max_print_dimension => scale 100,
|
|
||||||
);
|
|
||||||
my $surface = Slic3r::Surface->new(
|
my $surface = Slic3r::Surface->new(
|
||||||
surface_type => S_TYPE_TOP,
|
surface_type => S_TYPE_TOP,
|
||||||
expolygon => Slic3r::ExPolygon->new([ scale_points [0,0], [50,0], [50,50], [0,50] ]),
|
expolygon => Slic3r::ExPolygon->new([ scale_points [0,0], [50,0], [50,50], [0,50] ]),
|
||||||
|
|
Loading…
Reference in a new issue