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

« back to all changes in this revision

Viewing changes to t/print.t

  • 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
use Test::More tests => 5;
 
2
use strict;
 
3
use warnings;
 
4
 
 
5
BEGIN {
 
6
    use FindBin;
 
7
    use lib "$FindBin::Bin/../lib";
 
8
}
 
9
 
 
10
use List::Util qw(first);
 
11
use Slic3r;
 
12
use Slic3r::Geometry qw(epsilon unscale X Y);
 
13
use Slic3r::Test;
 
14
 
 
15
{
 
16
    my $config = Slic3r::Config->new_from_defaults;
 
17
    $config->set('print_center', [100,100]);
 
18
    my $print = Slic3r::Test::init_print('20mm_cube', config => $config);
 
19
    my @extrusion_points = ();
 
20
    Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub {
 
21
        my ($self, $cmd, $args, $info) = @_;
 
22
        
 
23
        if ($cmd eq 'G1' && $info->{extruding} && $info->{dist_XY} > 0) {
 
24
            push @extrusion_points, my $point = Slic3r::Point->new_scale($args->{X}, $args->{Y});
 
25
        }
 
26
    });
 
27
    my $bb = Slic3r::Geometry::BoundingBox->new_from_points(\@extrusion_points);
 
28
    my $center = $bb->center;
 
29
    ok abs(unscale($center->[X]) - $config->print_center->[X]) < epsilon, 'print is centered around print_center (X)';
 
30
    ok abs(unscale($center->[Y]) - $config->print_center->[Y]) < epsilon, 'print is centered around print_center (Y)';
 
31
}
 
32
 
 
33
{
 
34
    # this represents the aggregate config from presets
 
35
    my $config = Slic3r::Config->new_from_defaults;
 
36
    
 
37
    # user adds one object to the plater
 
38
    my $print = Slic3r::Test::init_print(my $model = Slic3r::Test::model('20mm_cube'), config => $config);
 
39
    
 
40
    # user sets a per-region option
 
41
    $print->print->objects->[0]->model_object->config->set('fill_density', 100);
 
42
    $print->print->reload_object(0);
 
43
    
 
44
    # user exports G-code, thus the default config is reapplied
 
45
    $print->print->apply_config($config);
 
46
    
 
47
    is $print->print->regions->[0]->config->fill_density, 100, 'apply_config() does not override per-object settings';
 
48
    
 
49
    # user assigns object extruders
 
50
    $print->print->objects->[0]->model_object->config->set('extruder', 3);
 
51
    $print->print->objects->[0]->model_object->config->set('perimeter_extruder', 2);
 
52
    $print->print->reload_object(0);
 
53
    
 
54
    is $print->print->regions->[0]->config->infill_extruder, 3, 'extruder setting is correctly expanded';
 
55
    is $print->print->regions->[0]->config->perimeter_extruder, 2, 'extruder setting does not override explicitely specified extruders';
 
56
}
 
57
 
 
58
__END__