~ubuntu-branches/ubuntu/utopic/slic3r/utopic

« back to all changes in this revision

Viewing changes to lib/Slic3r/Print/Region.pm

  • Committer: Package Import Robot
  • Author(s): Chow Loong Jin
  • Date: 2014-06-17 01:27:26 UTC
  • Revision ID: package-import@ubuntu.com-20140617012726-2wrs4zdo251nr4vg
Tags: upstream-1.1.4+dfsg
ImportĀ upstreamĀ versionĀ 1.1.4+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package Slic3r::Print::Region;
 
2
use Moo;
 
3
 
 
4
use Slic3r::Extruder ':roles';
 
5
use Slic3r::Flow ':roles';
 
6
 
 
7
# A Print::Region object represents a group of volumes to print
 
8
# sharing the same config (including the same assigned extruder(s))
 
9
 
 
10
has 'print'             => (is => 'ro', required => 1, weak_ref => 1);
 
11
has 'config'            => (is => 'ro', default => sub { Slic3r::Config::PrintRegion->new});
 
12
 
 
13
sub flow {
 
14
    my ($self, $role, $layer_height, $bridge, $first_layer, $width, $object) = @_;
 
15
    
 
16
    $bridge         //= 0;
 
17
    $first_layer    //= 0;
 
18
    
 
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;
 
34
        } else {
 
35
            die "Unknown role $role";
 
36
        }
 
37
    }
 
38
    if ($config_width eq '0') {
 
39
        $config_width = $object->config->extrusion_width;
 
40
    }
 
41
    
 
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;
 
49
    } else {
 
50
        die "Unknown role $role";
 
51
    }
 
52
    my $nozzle_diameter = $self->print->config->get_at('nozzle_diameter', $extruder-1);
 
53
    
 
54
    return Slic3r::Flow->new_from_width(
 
55
        width               => $config_width,
 
56
        role                => $role,
 
57
        nozzle_diameter     => $nozzle_diameter,
 
58
        layer_height        => $layer_height,
 
59
        bridge_flow_ratio   => ($bridge ? $self->print->config->bridge_flow_ratio : 0),
 
60
    );
 
61
}
 
62
 
 
63
1;