Assign extruders and flows to materials

This commit is contained in:
Alessandro Ranellucci 2012-09-23 02:40:25 +02:00
parent e2ab340edb
commit e696764af8
10 changed files with 161 additions and 120 deletions

View file

@ -4,15 +4,14 @@ use Moo;
use Slic3r::Geometry::Clipper qw(union_ex);
has 'id' => (is => 'rw', required => 1); # sequential number of layer, 0-based
has 'object' => (is => 'ro', weak_ref => 1, required => 1);
has 'materials' => (is => 'ro', default => sub { [] });
has 'slicing_errors' => (is => 'rw');
has 'slice_z' => (is => 'lazy');
has 'print_z' => (is => 'lazy');
has 'height' => (is => 'lazy');
has 'flow' => (is => 'lazy');
has 'perimeter_flow' => (is => 'lazy');
has 'infill_flow' => (is => 'lazy');
has 'flow' => (is => 'ro', default => sub { $Slic3r::flow });
# collection of expolygons generated by slicing the original geometry;
# also known as 'islands' (all materials are merged here)
@ -43,34 +42,14 @@ sub _build_height {
return $self->id == 0 ? $Slic3r::Config->get_value('first_layer_height') : $Slic3r::Config->layer_height;
}
sub _build_flow {
my $self = shift;
return $self->id == 0 && $Slic3r::first_layer_flow
? $Slic3r::first_layer_flow
: $Slic3r::flow;
}
sub _build_perimeter_flow {
my $self = shift;
return $self->id == 0 && $Slic3r::first_layer_flow
? $Slic3r::first_layer_flow
: $Slic3r::perimeter_flow;
}
sub _build_infill_flow {
my $self = shift;
return $self->id == 0 && $Slic3r::first_layer_flow
? $Slic3r::first_layer_flow
: $Slic3r::infill_flow;
}
sub material {
my $self = shift;
my ($material_idx) = @_;
if (!defined $self->materials->[$material_idx]) {
$self->materials->[$material_idx] = Slic3r::Layer::Material->new(
layer => $self,
layer => $self,
material => $self->object->print->materials->[$material_idx],
);
}
return $self->materials->[$material_idx];