1
package Slic3r::Print::Region;
4
use Slic3r::Extruder ':roles';
5
use Slic3r::Flow ':roles';
7
# A Print::Region object represents a group of volumes to print
8
# sharing the same config (including the same assigned extruder(s))
10
has 'print' => (is => 'ro', required => 1, weak_ref => 1);
11
has 'config' => (is => 'ro', default => sub { Slic3r::Config::PrintRegion->new});
14
my ($self, $role, $layer_height, $bridge, $first_layer, $width, $object) = @_;
19
# use the supplied custom width, if any
20
my $config_width = $width;
21
if (!defined $config_width) {
22
# get extrusion width from configuration
23
# (might be an absolute value, or a percent value, or zero for auto)
24
if ($first_layer && $self->print->config->first_layer_extrusion_width) {
25
$config_width = $self->print->config->first_layer_extrusion_width;
26
} elsif ($role == FLOW_ROLE_PERIMETER) {
27
$config_width = $self->config->perimeter_extrusion_width;
28
} elsif ($role == FLOW_ROLE_INFILL) {
29
$config_width = $self->config->infill_extrusion_width;
30
} elsif ($role == FLOW_ROLE_SOLID_INFILL) {
31
$config_width = $self->config->solid_infill_extrusion_width;
32
} elsif ($role == FLOW_ROLE_TOP_SOLID_INFILL) {
33
$config_width = $self->config->top_infill_extrusion_width;
35
die "Unknown role $role";
38
if ($config_width eq '0') {
39
$config_width = $object->config->extrusion_width;
42
# get the configured nozzle_diameter for the extruder associated
43
# to the flow role requested
44
my $extruder; # 1-based
45
if ($role == FLOW_ROLE_PERIMETER) {
46
$extruder = $self->config->perimeter_extruder;
47
} elsif ($role == FLOW_ROLE_INFILL || $role == FLOW_ROLE_SOLID_INFILL || $role == FLOW_ROLE_TOP_SOLID_INFILL) {
48
$extruder = $self->config->infill_extruder;
50
die "Unknown role $role";
52
my $nozzle_diameter = $self->print->config->get_at('nozzle_diameter', $extruder-1);
54
return Slic3r::Flow->new_from_width(
55
width => $config_width,
57
nozzle_diameter => $nozzle_diameter,
58
layer_height => $layer_height,
59
bridge_flow_ratio => ($bridge ? $self->print->config->bridge_flow_ratio : 0),