From 6c97e588b1d1fcc6ebbf915e8e977b8a2f16a376 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Tue, 30 Oct 2012 14:34:41 +0100 Subject: [PATCH] Don't require the print object in filler objects --- lib/Slic3r/Fill.pm | 8 ++++++-- lib/Slic3r/Fill/Honeycomb.pm | 8 ++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/Slic3r/Fill.pm b/lib/Slic3r/Fill.pm index e3a447d75..0449a68b2 100644 --- a/lib/Slic3r/Fill.pm +++ b/lib/Slic3r/Fill.pm @@ -45,9 +45,13 @@ sub BUILD { sub filler { my $self = shift; my ($filler) = @_; + if (!$self->fillers->{$filler}) { - $self->fillers->{$filler} = $FillTypes{$filler}->new(print => $self->print); - $self->fillers->{$filler}->max_print_dimension($self->max_print_dimension); + my $f = $FillTypes{$filler}->new( + max_print_dimension => $self->max_print_dimension + ); + $f->bounding_box([ $self->print->bounding_box ]) if $filler->can('bounding_box'); + $self->fillers->{$filler} = $f; } return $self->fillers->{$filler}; } diff --git a/lib/Slic3r/Fill/Honeycomb.pm b/lib/Slic3r/Fill/Honeycomb.pm index 6698fb8e6..5db50c301 100644 --- a/lib/Slic3r/Fill/Honeycomb.pm +++ b/lib/Slic3r/Fill/Honeycomb.pm @@ -3,7 +3,8 @@ use Moo; extends 'Slic3r::Fill::Base'; -has 'cache' => (is => 'rw', default => sub {{}}); +has 'bounding_box' => (is => 'rw'); +has 'cache' => (is => 'rw', default => sub {{}}); use Slic3r::Geometry qw(PI X1 Y1 X2 Y2 X Y scale); use Slic3r::Geometry::Clipper qw(intersection_ex); @@ -39,8 +40,8 @@ sub fill_surface { # adjust actual bounding box to the nearest multiple of our hex pattern # and align it so that it matches across layers - my $print_bounding_box = [ $self->print->bounding_box ]; - my $bounding_box = [ 0, 0, $print_bounding_box->[X2], $print_bounding_box->[Y2] ]; + $self->bounding_box([ $expolygon->bounding_box ]) if !defined $self->bounding_box; + my $bounding_box = [ 0, 0, $self->bounding_box->[X2], $self->bounding_box->[Y2] ]; { my $bb_polygon = Slic3r::Polygon->new([ [ $bounding_box->[X1], $bounding_box->[Y1] ], @@ -92,7 +93,6 @@ sub fill_surface { )}; return { flow_spacing => $params{flow_spacing} }, - map $_->polyline, Slic3r::Polyline::Collection->new(polylines => \@paths)->shortest_path; }