mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 12:11:15 -06:00 
			
		
		
		
	New feature: brim. #424
This commit is contained in:
		
							parent
							
								
									53d24bc580
								
							
						
					
					
						commit
						48addf8c3f
					
				
					 7 changed files with 57 additions and 8 deletions
				
			
		|  | @ -150,10 +150,11 @@ our $min_print_speed        = 10; | |||
| our $disable_fan_first_layers = 1; | ||||
| our $fan_always_on          = 0; | ||||
| 
 | ||||
| # skirt options | ||||
| # skirt/brim options | ||||
| our $skirts             = 1; | ||||
| our $skirt_distance     = 6;    # mm | ||||
| our $skirt_height       = 1;    # layers | ||||
| our $brim_thickness     = 0;    # mm | ||||
| 
 | ||||
| # transform options | ||||
| our $scale              = 1; | ||||
|  |  | |||
|  | @ -406,7 +406,7 @@ our $Options = { | |||
|         type    => 'bool', | ||||
|     }, | ||||
|      | ||||
|     # skirt options | ||||
|     # skirt/brim options | ||||
|     'skirts' => { | ||||
|         label   => 'Loops', | ||||
|         cli     => 'skirts=i', | ||||
|  | @ -415,13 +415,18 @@ our $Options = { | |||
|     'skirt_distance' => { | ||||
|         label   => 'Distance from object (mm)', | ||||
|         cli     => 'skirt-distance=f', | ||||
|         type    => 'i', | ||||
|         type    => 'f', | ||||
|     }, | ||||
|     'skirt_height' => { | ||||
|         label   => 'Skirt height (layers)', | ||||
|         cli     => 'skirt-height=i', | ||||
|         type    => 'i', | ||||
|     }, | ||||
|     'brim_thickness' => { | ||||
|         label   => 'Brim thickness (mm)', | ||||
|         cli     => 'brim-thickness=f', | ||||
|         type    => 'f', | ||||
|     }, | ||||
|      | ||||
|     # transform options | ||||
|     'scale' => { | ||||
|  |  | |||
|  | @ -44,7 +44,7 @@ sub new { | |||
|         }, | ||||
|         print => { | ||||
|             title => 'Print settings', | ||||
|             options => [qw(perimeters solid_layers fill_density fill_angle fill_pattern solid_fill_pattern randomize_start support_material support_material_tool)], | ||||
|             options => [qw(perimeters solid_layers fill_density fill_angle fill_pattern solid_fill_pattern randomize_start support_material)], | ||||
|         }, | ||||
|         retract => { | ||||
|             title => 'Retraction', | ||||
|  | @ -57,7 +57,7 @@ sub new { | |||
|         }, | ||||
|         skirt => { | ||||
|             title => 'Skirt', | ||||
|             options => [qw(skirts skirt_distance skirt_height)], | ||||
|             options => [qw(skirts skirt_distance skirt_height brim_thickness)], | ||||
|         }, | ||||
|         gcode => { | ||||
|             title => 'G-code', | ||||
|  | @ -78,7 +78,7 @@ sub new { | |||
|         }, | ||||
|         other => { | ||||
|             title => 'Other', | ||||
|             options => [ ($Slic3r::have_threads ? qw(threads) : ()), qw(extra_perimeters) ], | ||||
|             options => [ ($Slic3r::have_threads ? qw(threads) : ()), qw(extra_perimeters support_material_tool) ], | ||||
|         }, | ||||
|         notes => { | ||||
|             title => 'Notes', | ||||
|  |  | |||
|  | @ -147,12 +147,14 @@ sub rotate { | |||
|     my $self = shift; | ||||
|     my ($angle, $center) = @_; | ||||
|     @$self = Slic3r::Geometry::rotate_points($angle, $center, @$self); | ||||
|     return $self; | ||||
| } | ||||
| 
 | ||||
| sub translate { | ||||
|     my $self = shift; | ||||
|     my ($x, $y) = @_; | ||||
|     @$self = Slic3r::Geometry::move_points([$x, $y], @$self); | ||||
|     return $self; | ||||
| } | ||||
| 
 | ||||
| 1; | ||||
|  |  | |||
|  | @ -20,6 +20,13 @@ has 'skirt' => ( | |||
|     default => sub { [] }, | ||||
| ); | ||||
| 
 | ||||
| # ordered collection of extrusion paths to build a brim | ||||
| has 'brim' => ( | ||||
|     is      => 'rw', | ||||
|     #isa     => 'ArrayRef[Slic3r::ExtrusionLoop]', | ||||
|     default => sub { [] }, | ||||
| ); | ||||
| 
 | ||||
| sub add_object_from_file { | ||||
|     my $self = shift; | ||||
|     my ($input_file) = @_; | ||||
|  | @ -306,6 +313,7 @@ sub export_gcode { | |||
|     # make skirt | ||||
|     $status_cb->(88, "Generating skirt"); | ||||
|     $self->make_skirt; | ||||
|     $self->make_brim; | ||||
|      | ||||
|     # output everything to a G-code file | ||||
|     my $output_file = $self->expanded_output_filepath($params{output_file}); | ||||
|  | @ -438,9 +446,10 @@ sub make_skirt { | |||
|     my $convex_hull = convex_hull(\@points); | ||||
|      | ||||
|     # draw outlines from outside to inside | ||||
|     my $flow = $Slic3r::first_layer_flow || $Slic3r::flow; | ||||
|     my @skirt = (); | ||||
|     for (my $i = $Slic3r::skirts; $i > 0; $i--) { | ||||
|         my $distance = scale ($Slic3r::skirt_distance + ($Slic3r::flow->spacing * $i)); | ||||
|         my $distance = scale ($Slic3r::skirt_distance + ($flow->spacing * $i)); | ||||
|         my $outline = offset([$convex_hull], $distance, $Slic3r::scaling_factor * 100, JT_ROUND); | ||||
|         push @skirt, Slic3r::ExtrusionLoop->new( | ||||
|             polygon => Slic3r::Polygon->new(@{$outline->[0]}), | ||||
|  | @ -450,6 +459,28 @@ sub make_skirt { | |||
|     unshift @{$self->skirt}, @skirt; | ||||
| } | ||||
| 
 | ||||
| sub make_brim { | ||||
|     my $self = shift; | ||||
|     return unless $Slic3r::brim_thickness > 0; | ||||
|      | ||||
|     my @islands = (); # array of polygons | ||||
|     foreach my $obj_idx (0 .. $#{$self->objects}) { | ||||
|         my @object_islands = map $_->contour, @{ $self->objects->[$obj_idx]->layers->[0]->slices }; | ||||
|         foreach my $copy (@{$self->copies->[$obj_idx]}) { | ||||
|             push @islands, map $_->clone->translate(@$copy), @object_islands; | ||||
|         } | ||||
|     } | ||||
|      | ||||
|     my $flow = $Slic3r::first_layer_flow || $Slic3r::flow; | ||||
|     my $num_loops = sprintf "%.0f", $Slic3r::brim_thickness / $flow->width; | ||||
|     for my $i (reverse 1 .. $num_loops) { | ||||
|         push @{$self->brim}, Slic3r::ExtrusionLoop->new( | ||||
|             polygon => Slic3r::Polygon->new($_), | ||||
|             role    => EXTR_ROLE_SKIRT, | ||||
|         ) for @{Math::Clipper::offset(\@islands, $i * scale $flow->spacing)}; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| sub write_gcode { | ||||
|     my $self = shift; | ||||
|     my ($file) = @_; | ||||
|  | @ -535,12 +566,18 @@ sub write_gcode { | |||
|             $extruder->shift_x($shift[X]); | ||||
|             $extruder->shift_y($shift[Y]); | ||||
|             $gcode .= $extruder->set_acceleration($Slic3r::perimeter_acceleration); | ||||
|             if ($layer_id < $Slic3r::skirt_height) { | ||||
|             # skip skirt if we have a large brim | ||||
|             if ($layer_id < $Slic3r::skirt_height && ($layer_id != 0 || $Slic3r::skirt_distance + ($Slic3r::skirts * $Slic3r::flow->width) > $Slic3r::brim_thickness)) { | ||||
|                 $gcode .= $extruder->extrude_loop($_, 'skirt') for @{$self->skirt}; | ||||
|             } | ||||
|             $skirt_done++; | ||||
|         } | ||||
|          | ||||
|         # extrude brim | ||||
|         if ($layer_id == 0) { | ||||
|             $gcode .= $extruder->extrude_loop($_, 'brim') for @{$self->brim}; | ||||
|         } | ||||
|          | ||||
|         for my $obj_copy (@$object_copies) { | ||||
|             my ($obj_idx, $copy) = @$obj_copy; | ||||
|             my $layer = $self->objects->[$obj_idx]->layers->[$layer_id]; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Alessandro Ranellucci
						Alessandro Ranellucci