2011-09-05 10:21:27 +00:00
|
|
|
package Slic3r::Fill;
|
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
|
|
|
use Slic3r::Fill::Base;
|
2011-09-05 10:21:27 +00:00
|
|
|
use Slic3r::Fill::Rectilinear;
|
2011-10-06 13:24:21 +00:00
|
|
|
use Slic3r::Fill::Rectilinear2;
|
2011-09-05 10:21:27 +00:00
|
|
|
|
2011-10-07 17:07:57 +00:00
|
|
|
use XXX;
|
|
|
|
|
2011-10-06 11:43:32 +00:00
|
|
|
has 'print' => (is => 'ro', required => 1);
|
|
|
|
has 'fillers' => (is => 'rw', default => sub { {} });
|
|
|
|
|
|
|
|
our %FillTypes = (
|
2011-10-06 13:24:21 +00:00
|
|
|
rectilinear => 'Slic3r::Fill::Rectilinear',
|
|
|
|
rectilinear2 => 'Slic3r::Fill::Rectilinear2',
|
2011-10-06 11:43:32 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
sub BUILD {
|
|
|
|
my $self = shift;
|
|
|
|
$self->fillers->{$_} ||= $FillTypes{$_}->new(print => $self->print)
|
|
|
|
for ('rectilinear', $Slic3r::fill_type);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub make_fill {
|
|
|
|
my $self = shift;
|
|
|
|
my ($layer) = @_;
|
|
|
|
|
|
|
|
my $max_print_dimension = $self->print->max_length * sqrt(2);
|
|
|
|
for (values %{$self->fillers}) {
|
|
|
|
$_->layer($layer);
|
|
|
|
$_->max_print_dimension($max_print_dimension);
|
|
|
|
}
|
|
|
|
|
|
|
|
printf "Filling layer %d:\n", $layer->id;
|
|
|
|
foreach my $surface_collection (@{ $layer->fill_surfaces }) {
|
|
|
|
my @path_collection = ();
|
|
|
|
|
|
|
|
SURFACE: foreach my $surface (@{ $surface_collection->surfaces }) {
|
|
|
|
Slic3r::debugf " Processing surface %s:\n", $surface->id;
|
|
|
|
|
|
|
|
my $filler = $Slic3r::fill_type;
|
|
|
|
my $density = $Slic3r::fill_density;
|
|
|
|
next SURFACE unless $density > 0;
|
|
|
|
|
|
|
|
# force 100% density and rectilinear fill for external surfaces
|
|
|
|
if ($surface->surface_type ne 'internal') {
|
|
|
|
$density = 1;
|
|
|
|
$filler = 'rectilinear';
|
|
|
|
}
|
|
|
|
|
|
|
|
push @path_collection, $self->fillers->{$filler}->fill_surface($surface,
|
|
|
|
density => $density,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
# save into layer
|
|
|
|
push @{ $layer->fills }, Slic3r::ExtrusionPath::Collection->new(
|
|
|
|
paths => [ map Slic3r::ExtrusionPath->cast([ @$_ ]), @path_collection ],
|
|
|
|
);
|
|
|
|
$layer->fills->[-1]->cleanup;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-05 10:21:27 +00:00
|
|
|
1;
|