2012-09-23 00:52:31 +00:00
|
|
|
package Slic3r::Print::Region;
|
2014-06-10 14:01:57 +00:00
|
|
|
use strict;
|
|
|
|
use warnings;
|
2012-09-23 00:40:25 +00:00
|
|
|
|
2013-12-30 17:28:41 +00:00
|
|
|
use Slic3r::Extruder ':roles';
|
|
|
|
use Slic3r::Flow ':roles';
|
|
|
|
|
|
|
|
# A Print::Region object represents a group of volumes to print
|
|
|
|
# sharing the same config (including the same assigned extruder(s))
|
|
|
|
|
|
|
|
sub flow {
|
2014-04-25 17:39:27 +00:00
|
|
|
my ($self, $role, $layer_height, $bridge, $first_layer, $width, $object) = @_;
|
2013-12-30 17:28:41 +00:00
|
|
|
|
|
|
|
$bridge //= 0;
|
|
|
|
$first_layer //= 0;
|
|
|
|
|
|
|
|
# use the supplied custom width, if any
|
|
|
|
my $config_width = $width;
|
|
|
|
if (!defined $config_width) {
|
|
|
|
# get extrusion width from configuration
|
|
|
|
# (might be an absolute value, or a percent value, or zero for auto)
|
2014-01-02 23:34:30 +00:00
|
|
|
if ($first_layer && $self->print->config->first_layer_extrusion_width) {
|
|
|
|
$config_width = $self->print->config->first_layer_extrusion_width;
|
2014-06-09 19:14:48 +00:00
|
|
|
} elsif ($role == FLOW_ROLE_EXTERNAL_PERIMETER) {
|
|
|
|
$config_width = $self->config->external_perimeter_extrusion_width;
|
2013-12-30 17:28:41 +00:00
|
|
|
} elsif ($role == FLOW_ROLE_PERIMETER) {
|
|
|
|
$config_width = $self->config->perimeter_extrusion_width;
|
|
|
|
} elsif ($role == FLOW_ROLE_INFILL) {
|
|
|
|
$config_width = $self->config->infill_extrusion_width;
|
|
|
|
} elsif ($role == FLOW_ROLE_SOLID_INFILL) {
|
|
|
|
$config_width = $self->config->solid_infill_extrusion_width;
|
|
|
|
} elsif ($role == FLOW_ROLE_TOP_SOLID_INFILL) {
|
|
|
|
$config_width = $self->config->top_infill_extrusion_width;
|
|
|
|
} else {
|
|
|
|
die "Unknown role $role";
|
|
|
|
}
|
|
|
|
}
|
2014-04-25 17:39:27 +00:00
|
|
|
if ($config_width eq '0') {
|
|
|
|
$config_width = $object->config->extrusion_width;
|
|
|
|
}
|
2013-12-30 17:28:41 +00:00
|
|
|
|
|
|
|
# get the configured nozzle_diameter for the extruder associated
|
|
|
|
# to the flow role requested
|
|
|
|
my $extruder; # 1-based
|
2014-06-09 19:14:48 +00:00
|
|
|
if ($role == FLOW_ROLE_PERIMETER || $role == FLOW_ROLE_EXTERNAL_PERIMETER) {
|
2014-01-02 09:44:54 +00:00
|
|
|
$extruder = $self->config->perimeter_extruder;
|
2013-12-30 17:28:41 +00:00
|
|
|
} elsif ($role == FLOW_ROLE_INFILL || $role == FLOW_ROLE_SOLID_INFILL || $role == FLOW_ROLE_TOP_SOLID_INFILL) {
|
2014-01-02 09:44:54 +00:00
|
|
|
$extruder = $self->config->infill_extruder;
|
2013-12-30 17:28:41 +00:00
|
|
|
} else {
|
|
|
|
die "Unknown role $role";
|
|
|
|
}
|
2014-06-10 14:01:57 +00:00
|
|
|
my $nozzle_diameter = $self->print->config->get_at('nozzle_diameter', $extruder-1);
|
2013-12-30 17:28:41 +00:00
|
|
|
|
2014-01-03 17:27:46 +00:00
|
|
|
return Slic3r::Flow->new_from_width(
|
2013-12-30 17:28:41 +00:00
|
|
|
width => $config_width,
|
|
|
|
role => $role,
|
|
|
|
nozzle_diameter => $nozzle_diameter,
|
|
|
|
layer_height => $layer_height,
|
2014-06-11 20:10:33 +00:00
|
|
|
bridge_flow_ratio => ($bridge ? $self->config->bridge_flow_ratio : 0),
|
2013-12-30 17:28:41 +00:00
|
|
|
);
|
|
|
|
}
|
2012-09-23 00:40:25 +00:00
|
|
|
|
|
|
|
1;
|