mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 04:31:15 -06:00 
			
		
		
		
	Do each island completely if avoid_crossing_perimeters is enabled. #278
This commit is contained in:
		
							parent
							
								
									f10a4787b2
								
							
						
					
					
						commit
						dac168eff0
					
				
					 4 changed files with 57 additions and 17 deletions
				
			
		|  | @ -60,6 +60,11 @@ sub split_at_first_point { | |||
|     return $self->split_at_index(0); | ||||
| } | ||||
| 
 | ||||
| sub first_point { | ||||
|     my $self = shift; | ||||
|     return $self->polygon->[0]; | ||||
| } | ||||
| 
 | ||||
| package Slic3r::ExtrusionLoop::Packed; | ||||
| sub unpack { | ||||
|     my $self = shift; | ||||
|  |  | |||
|  | @ -86,9 +86,9 @@ sub points { | |||
|     return $self->polyline; | ||||
| } | ||||
| 
 | ||||
| sub endpoints { | ||||
| sub first_point { | ||||
|     my $self = shift; | ||||
|     return ($self->points->[0], $self->points->[-1]); | ||||
|     return $self->polyline->[0]; | ||||
| } | ||||
| 
 | ||||
| sub is_printable { 1 } | ||||
|  |  | |||
|  | @ -3,9 +3,12 @@ use Moo; | |||
| 
 | ||||
| has 'paths' => (is => 'rw', default => sub { [] }); | ||||
| 
 | ||||
| sub endpoints { | ||||
| # no-op | ||||
| sub unpack { $_[0] } | ||||
| 
 | ||||
| sub first_point { | ||||
|     my $self = shift; | ||||
|     return [ map $_->endpoints, @{$self->paths} ]; | ||||
|     return $self->paths->[0]->unpack->polyline->[0]; | ||||
| } | ||||
| 
 | ||||
| sub chained_path { | ||||
|  |  | |||
|  | @ -850,21 +850,53 @@ sub write_gcode { | |||
|                 my $layerm = $layer->regions->[$region_id]; | ||||
|                 my $region = $self->regions->[$region_id]; | ||||
|                  | ||||
|                 # extrude perimeters | ||||
|                 if (@{ $layerm->perimeters }) { | ||||
|                     $gcode .= $gcodegen->set_extruder($region->extruders->{perimeter}); | ||||
|                     $gcode .= $gcodegen->extrude($_, 'perimeter') for @{ $layerm->perimeters }; | ||||
|                 my @islands = (); | ||||
|                 if ($Slic3r::Config->avoid_crossing_perimeters) { | ||||
|                     push @islands, map +{ perimeters => [], fills => [] }, @{$layer->slices}; | ||||
|                     PERIMETER: foreach my $perimeter (@{$layerm->perimeters}) { | ||||
|                         $perimeter = $perimeter->unpack; | ||||
|                         for my $i (0 .. $#{$layer->slices}-1) { | ||||
|                             if ($layer->slices->[$i]->contour->encloses_point($perimeter->first_point)) { | ||||
|                                 push @{ $islands[$i]{perimeters} }, $perimeter; | ||||
|                                 next PERIMETER; | ||||
|                             } | ||||
|                         } | ||||
|                         push @{ $islands[-1]{perimeters} }, $perimeter; # optimization | ||||
|                     } | ||||
|                     FILL: foreach my $fill (@{$layerm->fills}) { | ||||
|                         for my $i (0 .. $#{$layer->slices}-1) { | ||||
|                             $fill = $fill->unpack; | ||||
|                             if ($layer->slices->[$i]->contour->encloses_point($fill->first_point)) { | ||||
|                                 push @{ $islands[$i]{fills} }, $fill; | ||||
|                                 next FILL; | ||||
|                             } | ||||
|                         } | ||||
|                         push @{ $islands[-1]{fills} }, $fill; # optimization | ||||
|                     } | ||||
|                 } else { | ||||
|                     push @islands, { | ||||
|                         perimeters  => $layerm->perimeters, | ||||
|                         fills       => $layerm->fills, | ||||
|                     }; | ||||
|                 } | ||||
|                  | ||||
|                 # extrude fills | ||||
|                 if (@{ $layerm->fills }) { | ||||
|                     $gcode .= $gcodegen->set_extruder($region->extruders->{infill}); | ||||
|                     for my $fill (@{ $layerm->fills }) { | ||||
|                         if ($fill->isa('Slic3r::ExtrusionPath::Collection')) { | ||||
|                             $gcode .= $gcodegen->extrude($_, 'fill')  | ||||
|                                 for $fill->chained_path($gcodegen->last_pos); | ||||
|                         } else { | ||||
|                             $gcode .= $gcodegen->extrude($fill, 'fill') ; | ||||
|                 foreach my $island (@islands) { | ||||
|                     # extrude perimeters | ||||
|                     if (@{ $island->{perimeters} }) { | ||||
|                         $gcode .= $gcodegen->set_extruder($region->extruders->{perimeter}); | ||||
|                         $gcode .= $gcodegen->extrude($_, 'perimeter') for @{ $island->{perimeters} }; | ||||
|                     } | ||||
|                      | ||||
|                     # extrude fills | ||||
|                     if (@{ $island->{fills} }) { | ||||
|                         $gcode .= $gcodegen->set_extruder($region->extruders->{infill}); | ||||
|                         for my $fill (@{ $island->{fills} }) { | ||||
|                             if ($fill->isa('Slic3r::ExtrusionPath::Collection')) { | ||||
|                                 $gcode .= $gcodegen->extrude($_, 'fill')  | ||||
|                                     for $fill->chained_path($gcodegen->last_pos); | ||||
|                             } else { | ||||
|                                 $gcode .= $gcodegen->extrude($fill, 'fill') ; | ||||
|                             } | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Alessandro Ranellucci
						Alessandro Ranellucci