2013-12-18 15:34:31 +00:00
|
|
|
use Test::More tests => 2;
|
2013-06-15 10:10:57 +00:00
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
BEGIN {
|
|
|
|
use FindBin;
|
|
|
|
use lib "$FindBin::Bin/../lib";
|
|
|
|
}
|
|
|
|
|
|
|
|
use List::Util qw(first);
|
|
|
|
use Slic3r;
|
2013-12-18 15:34:31 +00:00
|
|
|
use Slic3r::Geometry qw(epsilon unscale X Y);
|
2013-06-15 10:10:57 +00:00
|
|
|
use Slic3r::Test;
|
|
|
|
|
|
|
|
{
|
2013-12-18 15:34:31 +00:00
|
|
|
my $config = Slic3r::Config->new_from_defaults;
|
|
|
|
$config->set('print_center', [100,100]);
|
|
|
|
my $print = Slic3r::Test::init_print('20mm_cube', config => $config);
|
|
|
|
my @extrusion_points = ();
|
|
|
|
Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub {
|
|
|
|
my ($self, $cmd, $args, $info) = @_;
|
|
|
|
|
|
|
|
if ($cmd eq 'G1' && $info->{extruding} && $info->{dist_XY} > 0) {
|
|
|
|
push @extrusion_points, my $point = Slic3r::Point->new_scale($args->{X}, $args->{Y});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
my $bb = Slic3r::Geometry::BoundingBox->new_from_points(\@extrusion_points);
|
2014-01-07 11:48:09 +00:00
|
|
|
my $center = $bb->center;
|
2013-12-18 15:34:31 +00:00
|
|
|
ok abs(unscale($center->[X]) - $config->print_center->[X]) < epsilon, 'print is centered around print_center (X)';
|
|
|
|
ok abs(unscale($center->[Y]) - $config->print_center->[Y]) < epsilon, 'print is centered around print_center (Y)';
|
2013-06-15 10:10:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
__END__
|