From 0b42139e5492eae5ab74e11e3f99c481b180c4aa Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Mon, 7 Nov 2011 16:04:27 +0100 Subject: [PATCH] Print first layer at Z = 1 * layer_height instead of zero like it was until now. #17 --- lib/Slic3r/Layer.pm | 9 ++++++++- lib/Slic3r/Print.pm | 2 +- lib/Slic3r/STL.pm | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/Slic3r/Layer.pm b/lib/Slic3r/Layer.pm index aa0448dda..d826b1df5 100644 --- a/lib/Slic3r/Layer.pm +++ b/lib/Slic3r/Layer.pm @@ -76,11 +76,18 @@ has 'fills' => ( default => sub { [] }, ); -sub z { +# Z used for slicing +sub slice_z { my $self = shift; return ($self->id * $Slic3r::layer_height + $Slic3r::layer_height/2) / $Slic3r::resolution; } +# Z used for printing +sub print_z { + my $self = shift; + return ($self->id + 1) * $Slic3r::layer_height / $Slic3r::resolution; +} + sub add_surface { my $self = shift; my (@vertices) = @_; diff --git a/lib/Slic3r/Print.pm b/lib/Slic3r/Print.pm index f05e5eef2..dd8ded327 100644 --- a/lib/Slic3r/Print.pm +++ b/lib/Slic3r/Print.pm @@ -431,7 +431,7 @@ sub export_gcode { # write gcode commands layer by layer foreach my $layer (@{ $self->layers }) { # go to layer - printf $fh $extruder->move_z($Slic3r::z_offset + $layer->z * $Slic3r::resolution); + printf $fh $extruder->move_z($Slic3r::z_offset + $layer->print_z * $Slic3r::resolution); # extrude skirts printf $fh $extruder->extrude_loop($_, 'skirt') for @{ $layer->skirts }; diff --git a/lib/Slic3r/STL.pm b/lib/Slic3r/STL.pm index cc1d692ad..d0fd9e0e4 100644 --- a/lib/Slic3r/STL.pm +++ b/lib/Slic3r/STL.pm @@ -127,7 +127,7 @@ sub _facet { for (my $layer_id = $min_layer; $layer_id <= $max_layer; $layer_id++) { my $layer = $print->layer($layer_id); - $layer->add_line($_) for $self->intersect_facet(\@vertices, $layer->z); + $layer->add_line($_) for $self->intersect_facet(\@vertices, $layer->slice_z); } }