Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlessandro Ranellucci <aar@cpan.org>2013-07-05 17:03:08 +0400
committerAlessandro Ranellucci <aar@cpan.org>2013-07-05 17:03:08 +0400
commitd074b98aba60c385ca298086661f764abdc298dd (patch)
tree7fd47a9e571ee1b52aedefe209e538d7746a269f /lib
parentbe4eb3762f765b6532afd45536bfa63c1b471e39 (diff)
Optimization: don't store wipe path if wipe is not requested
Diffstat (limited to 'lib')
-rw-r--r--lib/Slic3r/GCode.pm18
-rw-r--r--lib/Slic3r/Print.pm2
2 files changed, 16 insertions, 4 deletions
diff --git a/lib/Slic3r/GCode.pm b/lib/Slic3r/GCode.pm
index 5b7ca6d7a..2d6e27f81 100644
--- a/lib/Slic3r/GCode.pm
+++ b/lib/Slic3r/GCode.pm
@@ -8,7 +8,9 @@ use Slic3r::Geometry::Clipper qw(union_ex);
use Slic3r::Surface ':types';
has 'config' => (is => 'ro', required => 1);
-has 'multiple_extruders' => (is => 'ro', default => sub {0} );
+has 'extruders' => (is => 'ro', default => sub {0}, required => 1);
+has 'multiple_extruders' => (is => 'lazy');
+has 'enable_wipe' => (is => 'lazy'); # at least one extruder has wipe enabled
has 'layer_count' => (is => 'ro', required => 1 );
has 'layer' => (is => 'rw');
has '_layer_overhangs' => (is => 'rw');
@@ -63,6 +65,16 @@ my %role_speeds = (
&EXTR_ROLE_GAPFILL => 'gap_fill',
);
+sub _build_multiple_extruders {
+ my $self = shift;
+ return @{$self->extruders} > 1;
+}
+
+sub _build_enable_wipe {
+ my $self = shift;
+ return (first { $_->wipe } @{$self->extruders}) ? 1 : 0;
+}
+
sub set_shift {
my $self = shift;
my @shift = @_;
@@ -205,7 +217,7 @@ sub extrude_loop {
# extrude along the path
my $gcode = join '', map $self->extrude_path($_, $description, %params), @paths;
- $self->wipe_path($extrusion_path->polyline);
+ $self->wipe_path($extrusion_path->polyline) if $self->enable_wipe;
# make a little move inwards before leaving loop
if ($loop->role == EXTR_ROLE_EXTERNAL_PERIMETER && $self->config->perimeters > 1) {
@@ -296,7 +308,7 @@ sub extrude_path {
$gcode .= $self->G1($line->[B], undef, $e * $line_length, $description);
}
$self->wipe_path(Slic3r::Polyline->new(reverse @{$path->points}))
- if $self->extruder->wipe;
+ if $self->enable_wipe;
}
if ($self->config->cooling) {
diff --git a/lib/Slic3r/Print.pm b/lib/Slic3r/Print.pm
index d62e84f08..531197582 100644
--- a/lib/Slic3r/Print.pm
+++ b/lib/Slic3r/Print.pm
@@ -711,7 +711,7 @@ sub write_gcode {
# set up our extruder object
my $gcodegen = Slic3r::GCode->new(
config => $self->config,
- multiple_extruders => (@{$self->extruders} > 1),
+ extruders => $self->extruders,
layer_count => $self->layer_count,
);
print $fh "G21 ; set units to millimeters\n" if $Slic3r::Config->gcode_flavor ne 'makerware';