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-11-13 17:14:02 +00:00
|
|
|
use Slic3r::Fill::ArchimedeanChords;
|
2011-10-06 11:43:32 +00:00
|
|
|
use Slic3r::Fill::Base;
|
2011-11-13 17:14:02 +00:00
|
|
|
use Slic3r::Fill::Flowsnake;
|
|
|
|
use Slic3r::Fill::HilbertCurve;
|
|
|
|
use Slic3r::Fill::OctagramSpiral;
|
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-11-13 17:14:02 +00:00
|
|
|
archimedeanchords => 'Slic3r::Fill::ArchimedeanChords',
|
|
|
|
rectilinear => 'Slic3r::Fill::Rectilinear',
|
|
|
|
rectilinear2 => 'Slic3r::Fill::Rectilinear2',
|
|
|
|
flowsnake => 'Slic3r::Fill::Flowsnake',
|
|
|
|
octagramspiral => 'Slic3r::Fill::OctagramSpiral',
|
|
|
|
hilbertcurve => 'Slic3r::Fill::HilbertCurve',
|
2011-10-06 11:43:32 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
sub BUILD {
|
|
|
|
my $self = shift;
|
|
|
|
$self->fillers->{$_} ||= $FillTypes{$_}->new(print => $self->print)
|
2011-11-13 17:14:02 +00:00
|
|
|
for ('rectilinear', $Slic3r::fill_pattern, $Slic3r::solid_fill_pattern);
|
2011-10-06 11:43:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2011-10-15 09:36:05 +00:00
|
|
|
foreach my $surfaces (@{ $layer->fill_surfaces }) {
|
2011-10-06 11:43:32 +00:00
|
|
|
my @path_collection = ();
|
|
|
|
|
2011-10-15 09:36:05 +00:00
|
|
|
SURFACE: foreach my $surface (@$surfaces) {
|
2011-10-06 11:43:32 +00:00
|
|
|
Slic3r::debugf " Processing surface %s:\n", $surface->id;
|
|
|
|
|
2011-11-13 17:21:25 +00:00
|
|
|
my $filler = $Slic3r::fill_pattern;
|
|
|
|
my $density = $Slic3r::fill_density;
|
|
|
|
my $flow_width = $Slic3r::flow_width;
|
2011-10-06 11:43:32 +00:00
|
|
|
|
|
|
|
# force 100% density and rectilinear fill for external surfaces
|
|
|
|
if ($surface->surface_type ne 'internal') {
|
2011-11-13 17:21:25 +00:00
|
|
|
my $is_bridge = $surface->isa('Slic3r::Surface::Bridge');
|
2011-10-06 11:43:32 +00:00
|
|
|
$density = 1;
|
2011-11-13 17:21:25 +00:00
|
|
|
$filler = $is_bridge ? 'rectilinear' : $Slic3r::solid_fill_pattern;
|
|
|
|
$flow_width = $Slic3r::nozzle_diameter if $is_bridge;
|
2011-11-09 08:21:09 +00:00
|
|
|
} else {
|
|
|
|
next SURFACE unless $density > 0;
|
2011-10-06 11:43:32 +00:00
|
|
|
}
|
|
|
|
|
2011-10-18 13:57:53 +00:00
|
|
|
my @paths = $self->fillers->{$filler}->fill_surface(
|
|
|
|
$surface,
|
2011-11-13 17:21:25 +00:00
|
|
|
density => $density,
|
|
|
|
flow_width => $flow_width,
|
2011-10-06 11:43:32 +00:00
|
|
|
);
|
2011-10-18 13:57:53 +00:00
|
|
|
|
|
|
|
push @path_collection, map Slic3r::ExtrusionPath->cast(
|
|
|
|
[ @$_ ],
|
|
|
|
depth_layers => $surface->depth_layers,
|
|
|
|
), @paths;
|
2011-10-06 11:43:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# save into layer
|
|
|
|
push @{ $layer->fills }, Slic3r::ExtrusionPath::Collection->new(
|
2011-10-18 13:57:53 +00:00
|
|
|
paths => [ @path_collection ],
|
2011-10-06 11:43:32 +00:00
|
|
|
);
|
|
|
|
$layer->fills->[-1]->cleanup;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-05 10:21:27 +00:00
|
|
|
1;
|