mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 20:21:12 -06:00 
			
		
		
		
	Fixed ooze prevention test as well
This commit is contained in:
		
							parent
							
								
									0b77fe743c
								
							
						
					
					
						commit
						de2fd9721c
					
				
					 1 changed files with 30 additions and 9 deletions
				
			
		
							
								
								
									
										39
									
								
								t/multi.t
									
										
									
									
									
								
							
							
						
						
									
										39
									
								
								t/multi.t
									
										
									
									
									
								
							|  | @ -17,23 +17,25 @@ use Slic3r::Test; | ||||||
|     my $config = Slic3r::Config->new_from_defaults; |     my $config = Slic3r::Config->new_from_defaults; | ||||||
|     $config->set('raft_layers', 2); |     $config->set('raft_layers', 2); | ||||||
|     $config->set('infill_extruder', 2); |     $config->set('infill_extruder', 2); | ||||||
|     $config->set('support_material_extruder', 3); |     $config->set('solid_infill_extruder', 3); | ||||||
|  |     $config->set('support_material_extruder', 4); | ||||||
|     $config->set('ooze_prevention', 1); |     $config->set('ooze_prevention', 1); | ||||||
|     $config->set('extruder_offset', [ [0,0], [20,0], [0,20] ]); |     $config->set('extruder_offset', [ [0,0], [20,0], [0,20], [20,20] ]); | ||||||
|     $config->set('temperature', [200, 180, 170]); |     $config->set('temperature', [200, 180, 170, 160]); | ||||||
|     $config->set('first_layer_temperature', [206, 186, 166]); |     $config->set('first_layer_temperature', [206, 186, 166, 156]); | ||||||
|     $config->set('toolchange_gcode', ';toolchange');  # test that it doesn't crash when this is supplied |     $config->set('toolchange_gcode', ';toolchange');  # test that it doesn't crash when this is supplied | ||||||
|      |      | ||||||
|     my $print = Slic3r::Test::init_print('20mm_cube', config => $config); |     my $print = Slic3r::Test::init_print('20mm_cube', config => $config); | ||||||
|      |      | ||||||
|     my $tool = undef; |     my $tool = undef; | ||||||
|     my @tool_temp = (0,0,0); |     my @tool_temp = (0,0,0,0); | ||||||
|     my @toolchange_points = (); |     my @toolchange_points = (); | ||||||
|     my @extrusion_points = (); |     my @extrusion_points = (); | ||||||
|     Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub { |     Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub { | ||||||
|         my ($self, $cmd, $args, $info) = @_; |         my ($self, $cmd, $args, $info) = @_; | ||||||
|          |          | ||||||
|         if ($cmd =~ /^T(\d+)/) { |         if ($cmd =~ /^T(\d+)/) { | ||||||
|  |             # ignore initial toolchange | ||||||
|             if (defined $tool) { |             if (defined $tool) { | ||||||
|                 my $expected_temp = $self->Z == ($config->get_value('first_layer_height') + $config->z_offset) |                 my $expected_temp = $self->Z == ($config->get_value('first_layer_height') + $config->z_offset) | ||||||
|                     ? $config->first_layer_temperature->[$tool] |                     ? $config->first_layer_temperature->[$tool] | ||||||
|  | @ -41,8 +43,8 @@ use Slic3r::Test; | ||||||
|                 die 'standby temperature was not set before toolchange' |                 die 'standby temperature was not set before toolchange' | ||||||
|                     if $tool_temp[$tool] != $expected_temp + $config->standby_temperature_delta; |                     if $tool_temp[$tool] != $expected_temp + $config->standby_temperature_delta; | ||||||
|                  |                  | ||||||
|                 # ignore initial toolchange |                 push @toolchange_points, my $point = Slic3r::Point->new_scale($self->X, $self->Y); | ||||||
|                 push @toolchange_points, Slic3r::Point->new_scale($self->X, $self->Y); |                 $point->translate(map +scale($_), @{ $config->extruder_offset->[$tool] }); | ||||||
|             } |             } | ||||||
|             $tool = $1; |             $tool = $1; | ||||||
|         } elsif ($cmd eq 'M104' || $cmd eq 'M109') { |         } elsif ($cmd eq 'M104' || $cmd eq 'M109') { | ||||||
|  | @ -54,11 +56,30 @@ use Slic3r::Test; | ||||||
|             $tool_temp[$t] = $args->{S}; |             $tool_temp[$t] = $args->{S}; | ||||||
|         } elsif ($cmd eq 'G1' && $info->{extruding} && $info->{dist_XY} > 0) { |         } elsif ($cmd eq 'G1' && $info->{extruding} && $info->{dist_XY} > 0) { | ||||||
|             push @extrusion_points, my $point = Slic3r::Point->new_scale($args->{X}, $args->{Y}); |             push @extrusion_points, my $point = Slic3r::Point->new_scale($args->{X}, $args->{Y}); | ||||||
|             $point->translate(map scale($_), @{ $config->extruder_offset->[$tool] }); |             $point->translate(map +scale($_), @{ $config->extruder_offset->[$tool] }); | ||||||
|         } |         } | ||||||
|     }); |     }); | ||||||
|     my $convex_hull = convex_hull(\@extrusion_points); |     my $convex_hull = convex_hull(\@extrusion_points); | ||||||
|     ok !(defined first { $convex_hull->contains_point($_) } @toolchange_points), 'all toolchanges happen outside skirt'; |      | ||||||
|  |     my @t = (); | ||||||
|  |     foreach my $point (@toolchange_points) { | ||||||
|  |         foreach my $offset (@{$config->extruder_offset}) { | ||||||
|  |             push @t, my $p = $point->clone; | ||||||
|  |             $p->translate(map +scale($_), @$offset); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |     ok !(defined first { $convex_hull->contains_point($_) } @t), 'all nozzles are outside skirt at toolchange'; | ||||||
|  |      | ||||||
|  |     if (0) { | ||||||
|  |         require "Slic3r/SVG.pm"; | ||||||
|  |         Slic3r::SVG::output( | ||||||
|  |             "ooze_prevention.svg", | ||||||
|  |             no_arrows   => 1, | ||||||
|  |             polygons    => [$convex_hull], | ||||||
|  |             points      => \@toolchange_points, | ||||||
|  |             red_points  => \@t, | ||||||
|  |         ); | ||||||
|  |     } | ||||||
|      |      | ||||||
|     # offset the skirt by the maximum displacement between extruders plus a safety extra margin |     # offset the skirt by the maximum displacement between extruders plus a safety extra margin | ||||||
|     my $delta = scale(20 * sqrt(2) + 1); |     my $delta = scale(20 * sqrt(2) + 1); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Alessandro Ranellucci
						Alessandro Ranellucci