Skip to content

Commit

Permalink
Bugfix: z_offset was not applied in spiral_vase. Includes regression …
Browse files Browse the repository at this point in the history
…test #1343
  • Loading branch information
alranel committed Jul 29, 2013
1 parent 1210b89 commit b5907dc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/Slic3r/GCode/Layer.pm
Expand Up @@ -18,7 +18,7 @@ sub _build_spiralvase {
my $self = shift;

return $Slic3r::Config->spiral_vase
? Slic3r::GCode::SpiralVase->new
? Slic3r::GCode::SpiralVase->new(config => $self->gcodegen->config)
: undef;
}

Expand Down
4 changes: 3 additions & 1 deletion lib/Slic3r/GCode/SpiralVase.pm
@@ -1,6 +1,8 @@
package Slic3r::GCode::SpiralVase;
use Moo;

has 'config' => (is => 'ro', required => 1);

use Slic3r::Geometry qw(unscale);

sub process_layer {
Expand All @@ -16,7 +18,7 @@ sub process_layer {

my $new_gcode = "";
my $layer_height = $layer->height;
my $z = $layer->print_z - $layer_height;
my $z = $layer->print_z + $self->config->z_offset - $layer_height;
my $newlayer = 0;
Slic3r::GCode::Reader->new(gcode => $gcode)->parse(sub {
my ($reader, $cmd, $args, $info) = @_;
Expand Down
10 changes: 9 additions & 1 deletion t/shells.t
@@ -1,4 +1,4 @@
use Test::More tests => 6;
use Test::More tests => 10;
use strict;
use warnings;

Expand Down Expand Up @@ -104,6 +104,7 @@ use Slic3r::Test;
$config->set('spiral_vase', 1);
$config->set('bottom_solid_layers', 0);
$config->set('skirts', 0);
$config->set('first_layer_height', '100%');

# TODO: this needs to be tested with a model with sloping edges, where starting
# points of each layer are not aligned - in that case we would test that no
Expand All @@ -114,18 +115,25 @@ use Slic3r::Test;
my $print = Slic3r::Test::init_print($model_name, config => $config);
my $travel_moves_after_first_extrusion = 0;
my $started_extruding = 0;
my @z_steps = ();
Slic3r::GCode::Reader->new(gcode => Slic3r::Test::gcode($print))->parse(sub {
my ($self, $cmd, $args, $info) = @_;

$started_extruding = 1 if $info->{extruding};
push @z_steps, ($args->{Z} - $self->Z)
if $started_extruding && exists $args->{Z};
$travel_moves_after_first_extrusion++
if $info->{travel} && $started_extruding && !exists $args->{Z};
});
is $travel_moves_after_first_extrusion, 0, "no gaps in spiral vase ($description)";
ok !(grep { $_ > $config->layer_height } @z_steps), "no gaps in Z ($description)";
};

$test->('20mm_cube', 'solid model');
$test->('40x10', 'hollow model');

$config->set('z_offset', -10);
$test->('20mm_cube', 'solid model with negative z-offset');
}

__END__

0 comments on commit b5907dc

Please sign in to comment.