multi.t 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. use Test::More tests => 1;
  2. use strict;
  3. use warnings;
  4. BEGIN {
  5. use FindBin;
  6. use lib "$FindBin::Bin/../lib";
  7. }
  8. use List::Util qw(first);
  9. use Slic3r;
  10. use Slic3r::Geometry qw(scale convex_hull);
  11. use Slic3r::Test;
  12. {
  13. my $config = Slic3r::Config->new_from_defaults;
  14. $config->set('raft_layers', 2);
  15. $config->set('infill_extruder', 2);
  16. $config->set('support_material_extruder', 3);
  17. $config->set('ooze_prevention', 1);
  18. $config->set('extruder_offset', [ [0,0], [20,0], [0,20] ]);
  19. $config->set('temperature', [200, 180, 170]);
  20. $config->set('first_layer_temperature', [206, 186, 166]);
  21. my $print = Slic3r::Test::init_print('20mm_cube', config => $config);
  22. my $tool = undef;
  23. my @tool_temp = (0,0,0);
  24. my @toolchange_points = ();
  25. my @extrusion_points = ();
  26. Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub {
  27. my ($self, $cmd, $args, $info) = @_;
  28. if ($cmd =~ /^T(\d+)/) {
  29. if (defined $tool) {
  30. my $expected_temp = $self->Z == ($config->get_value('first_layer_height') + $config->z_offset)
  31. ? $config->first_layer_temperature->[$tool]
  32. : $config->temperature->[$tool];
  33. die 'standby temperature was not set before toolchange'
  34. if $tool_temp[$tool] != $expected_temp + $config->standby_temperature_delta;
  35. }
  36. $tool = $1;
  37. push @toolchange_points, Slic3r::Point->new_scale($self->X, $self->Y);
  38. } elsif ($cmd eq 'M104' || $cmd eq 'M109') {
  39. my $t = $args->{T} // $tool;
  40. if ($tool_temp[$t] == 0) {
  41. fail 'initial temperature is not equal to first layer temperature + standby delta'
  42. unless $args->{S} == $config->first_layer_temperature->[$t] + $config->standby_temperature_delta;
  43. }
  44. $tool_temp[$t] = $args->{S};
  45. } elsif ($cmd eq 'G1' && $info->{extruding} && $info->{dist_XY} > 0) {
  46. push @extrusion_points, my $point = Slic3r::Point->new_scale($args->{X}, $args->{Y});
  47. $point->translate(map scale($_), @{ $config->extruder_offset->[$tool] });
  48. }
  49. });
  50. my $convex_hull = convex_hull(\@extrusion_points);
  51. ok !(first { $convex_hull->contains_point($_) } @toolchange_points), 'all toolchanges happen outside skirt';
  52. }
  53. __END__