mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 20:21:12 -06:00 
			
		
		
		
	Many changes and fixes to remove leaks and return objects by reference
This commit is contained in:
		
							parent
							
								
									275422fac7
								
							
						
					
					
						commit
						a49dc603cc
					
				
					 27 changed files with 67 additions and 46 deletions
				
			
		|  | @ -8,7 +8,7 @@ use Slic3r::Geometry::Clipper qw(union_ex); | |||
| use Slic3r::Surface ':types'; | ||||
| 
 | ||||
| has 'config'             => (is => 'ro', required => 1); | ||||
| has 'extruders'          => (is => 'ro', default => sub {0}, required => 1); | ||||
| has 'extruders'          => (is => 'ro', required => 1); | ||||
| has 'multiple_extruders' => (is => 'lazy'); | ||||
| has 'enable_loop_clipping' => (is => 'rw', default => sub {1}); | ||||
| has 'enable_wipe'        => (is => 'lazy');   # at least one extruder has wipe enabled | ||||
|  |  | |||
|  | @ -197,9 +197,10 @@ sub make_perimeters { | |||
|                 : $perimeter_spacing; | ||||
|              | ||||
|             my @offsets = @{offset2_ex(\@last, -1.5*$spacing,  +0.5*$spacing)}; | ||||
|             my @contours_offsets    = map $_->contour, @offsets; | ||||
|             my @holes_offsets       = map @{$_->holes}, @offsets; | ||||
|             @offsets = (@contours_offsets, @holes_offsets);     # turn @offsets from ExPolygons to Polygons | ||||
|             # clone polygons because these ExPolygons will go out of scope very soon | ||||
|             my @contours_offsets    = map $_->contour->clone, @offsets; | ||||
|             my @holes_offsets       = map $_->clone, map @{$_->holes}, @offsets; | ||||
|             @offsets = map $_->clone, (@contours_offsets, @holes_offsets);     # turn @offsets from ExPolygons to Polygons | ||||
|              | ||||
|             # where offset2() collapses the expolygon, then there's no room for an inner loop | ||||
|             # and we can extract the gap for later processing | ||||
|  | @ -555,13 +556,12 @@ sub _detect_bridge_direction { | |||
|         } | ||||
|     } elsif (@edges) { | ||||
|         # inset the bridge expolygon; we'll use this one to clip our test lines | ||||
|         my $inset = [ $expolygon->offset_ex($self->infill_flow->scaled_width) ]; | ||||
|         my $inset = $expolygon->offset_ex($self->infill_flow->scaled_width); | ||||
|          | ||||
|         # detect anchors as intersection between our bridge expolygon and the lower slices | ||||
|         my $anchors = intersection_ex( | ||||
|             [ @$grown ], | ||||
|             [ map @$_, @lower ], | ||||
|             undef, | ||||
|             1,  # safety offset required to avoid Clipper from detecting empty intersection while Boost actually found some @edges | ||||
|         ); | ||||
|          | ||||
|  | @ -584,7 +584,8 @@ sub _detect_bridge_direction { | |||
|             } | ||||
|              | ||||
|             # TODO: use a multi_polygon_multi_linestring_intersection() call | ||||
|             my @clipped_lines = map @{ Boost::Geometry::Utils::polygon_multi_linestring_intersection($_, \@lines) }, @$inset; | ||||
|             my @clipped_lines = map Slic3r::Line->new(@$_), | ||||
|                 map @{ Boost::Geometry::Utils::polygon_multi_linestring_intersection($_->pp, \@lines) }, @$inset; | ||||
|              | ||||
|             # remove any line not having both endpoints within anchors | ||||
|             @clipped_lines = grep { | ||||
|  |  | |||
|  | @ -19,7 +19,7 @@ sub merge_continuous_lines { | |||
|      | ||||
|     my $p = $self->pp; | ||||
|     polygon_remove_parallel_continuous_edges($p); | ||||
|     return (ref $self)->new(@$p); | ||||
|     return __PACKAGE__->new(@$p); | ||||
| } | ||||
| 
 | ||||
| sub remove_acute_vertices { | ||||
|  |  | |||
|  | @ -32,7 +32,7 @@ sub simplify { | |||
|     my $tolerance = shift || 10; | ||||
|      | ||||
|     my $simplified = Boost::Geometry::Utils::linestring_simplify($self->pp, $tolerance); | ||||
|     return (ref $self)->new(@$simplified); | ||||
|     return __PACKAGE__->new(@$simplified); | ||||
| } | ||||
| 
 | ||||
| sub length { | ||||
|  | @ -66,7 +66,7 @@ sub clip_with_expolygon { | |||
|     my ($expolygon) = @_; | ||||
|      | ||||
|     my $result = Boost::Geometry::Utils::polygon_multi_linestring_intersection($expolygon->pp, [$self->pp]); | ||||
|     return map { (ref $self)->new(@$_) } @$result; | ||||
|     return map { __PACKAGE__->new(@$_) } @$result; | ||||
| } | ||||
| 
 | ||||
| sub bounding_box { | ||||
|  | @ -128,7 +128,7 @@ sub clip_start { | |||
|         $distance = 0; | ||||
|     } | ||||
|      | ||||
|     return (ref $self)->new($points); | ||||
|     return __PACKAGE__->new($points); | ||||
| } | ||||
| 
 | ||||
| # this method returns a collection of points picked on the polygon contour | ||||
|  |  | |||
|  | @ -643,7 +643,7 @@ sub discover_horizontal_shells { | |||
|                                 # additional area in the next shell too | ||||
| 
 | ||||
|                                 # make sure our grown surfaces don't exceed the fill area | ||||
|                                 my @grown = map @$_, @{intersection_ex( | ||||
|                                 my @grown = @{intersection( | ||||
|                                     offset([ map @$_, @$too_narrow ], +$margin), | ||||
|                                     [ map $_->p, @neighbor_fill_surfaces ], | ||||
|                                 )}; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Alessandro Ranellucci
						Alessandro Ranellucci