mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-11-02 20:51:23 -07:00 
			
		
		
		
	New wipe feature
This commit is contained in:
		
							parent
							
								
									83065b0789
								
							
						
					
					
						commit
						7de8b20bc4
					
				
					 7 changed files with 71 additions and 6 deletions
				
			
		| 
						 | 
				
			
			@ -164,6 +164,7 @@ sub scale {
 | 
			
		|||
    return $self;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# removes the given distance from the end of the polyline
 | 
			
		||||
sub clip_end {
 | 
			
		||||
    my $self = shift;
 | 
			
		||||
    my ($distance) = @_;
 | 
			
		||||
| 
						 | 
				
			
			@ -184,6 +185,30 @@ sub clip_end {
 | 
			
		|||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# only keeps the given distance at the beginning of the polyline
 | 
			
		||||
sub clip_start {
 | 
			
		||||
    my $self = shift;
 | 
			
		||||
    my ($distance) = @_;
 | 
			
		||||
    
 | 
			
		||||
    my $points = [];
 | 
			
		||||
    
 | 
			
		||||
    for (my $i = 1; $distance > 0 && $i <= $#$self; $i++) {
 | 
			
		||||
        my $point = $self->[$i];
 | 
			
		||||
        my $segment_length = $point->distance_to($self->[$i-1]);
 | 
			
		||||
        if ($segment_length <= $distance) {
 | 
			
		||||
            $distance -= $segment_length;
 | 
			
		||||
            push @$points, $point;
 | 
			
		||||
            next;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        my $new_point = Slic3r::Geometry::point_along_segment($self->[$i-1], $point, $distance);
 | 
			
		||||
        push @$points, Slic3r::Point->new($new_point);
 | 
			
		||||
        $distance = 0;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    return (ref $self)->new($points);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
package Slic3r::Polyline::Collection;
 | 
			
		||||
use Moo;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue