mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-12-11 16:00:17 -07:00
Incomplete work for refactoring regions and flows
This commit is contained in:
parent
231bffa99b
commit
beb1baa096
13 changed files with 297 additions and 148 deletions
|
|
@ -1,8 +1,60 @@
|
|||
package Slic3r::Print::Region;
|
||||
use Moo;
|
||||
|
||||
has 'extruders' => (is => 'rw', default => sub { {} }); # by role
|
||||
has 'flows' => (is => 'rw', default => sub { {} }); # by role
|
||||
has 'first_layer_flows' => (is => 'rw', default => sub { {} }); # by role
|
||||
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))
|
||||
|
||||
has 'print' => (is => 'ro', required => 1, weak_ref => 1);
|
||||
has 'config' => (is => 'ro', required => 1);
|
||||
|
||||
sub flow {
|
||||
my ($self, $role, $layer_height, $bridge, $first_layer, $width) = @_;
|
||||
|
||||
$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)
|
||||
if ($first_layer) {
|
||||
$config_width = $self->config->first_layer_extrusion_width;
|
||||
} 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";
|
||||
}
|
||||
}
|
||||
|
||||
# get the configured nozzle_diameter for the extruder associated
|
||||
# to the flow role requested
|
||||
my $extruder; # 1-based
|
||||
if ($role == FLOW_ROLE_PERIMETER) {
|
||||
$config_width = $self->config->perimeter_extruder;
|
||||
} elsif ($role == FLOW_ROLE_INFILL || $role == FLOW_ROLE_SOLID_INFILL || $role == FLOW_ROLE_TOP_SOLID_INFILL) {
|
||||
$config_width = $self->config->infill_extruder;
|
||||
} else {
|
||||
die "Unknown role $role";
|
||||
}
|
||||
my $nozzle_diameter = $self->print->config->nozzle_diameter->[$extruder-1];
|
||||
|
||||
return Slic3r::Flow->new(
|
||||
width => $config_width,
|
||||
role => $role,
|
||||
nozzle_diameter => $nozzle_diameter,
|
||||
layer_height => $layer_height,
|
||||
bridge_flow_ratio => ($bridge ? $self->config->bridge_flow_ratio : 0),
|
||||
);
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue