mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-11-02 20:51:23 -07:00 
			
		
		
		
	Renamed encloses_line() to contains_line() and implemented it using diff_pl()
This commit is contained in:
		
							parent
							
								
									3025c77675
								
							
						
					
					
						commit
						bd62de7653
					
				
					 4 changed files with 10 additions and 18 deletions
				
			
		| 
						 | 
				
			
			@ -54,16 +54,11 @@ sub encloses_point_quick {
 | 
			
		|||
    return Boost::Geometry::Utils::point_within_polygon($point->pp, $self->pp);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
sub encloses_line {
 | 
			
		||||
sub contains_line {
 | 
			
		||||
    my $self = shift;
 | 
			
		||||
    my ($line, $tolerance) = @_;
 | 
			
		||||
    my $clip = $self->clip_line($line);
 | 
			
		||||
    if (!defined $tolerance) {
 | 
			
		||||
        # optimization
 | 
			
		||||
        return @$clip == 1 && $clip->[0]->coincides_with($line);
 | 
			
		||||
    } else {
 | 
			
		||||
        return @$clip == 1 && abs($clip->[0]->length - $line->length) < $tolerance;
 | 
			
		||||
    }
 | 
			
		||||
    my ($line) = @_;
 | 
			
		||||
    
 | 
			
		||||
    return @{Slic3r::Geometry::Clipper::diff_pl([$line->as_polyline], \@$self)} ? 0 : 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
sub bounding_box {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -83,7 +83,7 @@ sub fill_surface {
 | 
			
		|||
                
 | 
			
		||||
                # TODO: we should also check that both points are on a fill_boundary to avoid 
 | 
			
		||||
                # connecting paths on the boundaries of internal regions
 | 
			
		||||
                if ($can_connect->(@distance) && $expolygon_off->encloses_line(Slic3r::Line->new($last_point, $first_point), $tolerance)) {
 | 
			
		||||
                if ($can_connect->(@distance) && $expolygon_off->contains_line(Slic3r::Line->new($last_point, $first_point))) {
 | 
			
		||||
                    $polylines[-1]->append_polyline($polyline);
 | 
			
		||||
                    next;
 | 
			
		||||
                }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -389,9 +389,9 @@ sub travel_to {
 | 
			
		|||
    # *and* in an island in the upper layer (so that the ooze will not be visible)
 | 
			
		||||
    if ($travel->length < scale $self->extruder->retract_before_travel
 | 
			
		||||
        || ($self->config->only_retract_when_crossing_perimeters
 | 
			
		||||
            && (first { $_->encloses_line($travel, scaled_epsilon) } @{$self->_upper_layer_islands})
 | 
			
		||||
            && (first { $_->encloses_line($travel, scaled_epsilon) } @{$self->_layer_islands}))
 | 
			
		||||
        || (defined $role && $role == EXTR_ROLE_SUPPORTMATERIAL && (first { $_->encloses_line($travel, scaled_epsilon) } @{$self->layer->support_islands}))
 | 
			
		||||
            && (first { $_->contains_line($travel) } @{$self->_upper_layer_islands})
 | 
			
		||||
            && (first { $_->contains_line($travel) } @{$self->_layer_islands}))
 | 
			
		||||
        || (defined $role && $role == EXTR_ROLE_SUPPORTMATERIAL && (first { $_->contains_line($travel) } @{$self->layer->support_islands}))
 | 
			
		||||
        ) {
 | 
			
		||||
        $self->straight_once(0);
 | 
			
		||||
        $self->speed('travel');
 | 
			
		||||
| 
						 | 
				
			
			@ -434,7 +434,7 @@ sub _plan {
 | 
			
		|||
        $need_retract = 1;
 | 
			
		||||
        foreach my $island (@{$self->_upper_layer_islands}) {
 | 
			
		||||
            # discard the island if at any line is not enclosed in it
 | 
			
		||||
            next if first { !$island->encloses_line($_, scaled_epsilon) } @travel;
 | 
			
		||||
            next if first { !$island->contains_line($_) } @travel;
 | 
			
		||||
            # okay, this island encloses the full travel path
 | 
			
		||||
            $need_retract = 0;
 | 
			
		||||
            last;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -10,7 +10,6 @@ has '_contours_ex'  => (is => 'rw', default => sub { [] });  # arrayref of array
 | 
			
		|||
has '_pointmap'     => (is => 'rw', default => sub { {} });  # { id => $point }
 | 
			
		||||
has '_edges'        => (is => 'rw', default => sub { {} });  # node_idx => { node_idx => distance, ... }
 | 
			
		||||
has '_crossing_edges' => (is => 'rw', default => sub { {} });  # edge_idx => bool
 | 
			
		||||
has '_tolerance'    => (is => 'lazy');
 | 
			
		||||
 | 
			
		||||
use List::Util qw(first);
 | 
			
		||||
use Slic3r::Geometry qw(A B scale epsilon);
 | 
			
		||||
| 
						 | 
				
			
			@ -31,8 +30,6 @@ use constant CROSSING_FACTOR => 20;
 | 
			
		|||
 | 
			
		||||
use constant INFINITY => 'inf';
 | 
			
		||||
 | 
			
		||||
sub _build__tolerance { scale epsilon }
 | 
			
		||||
 | 
			
		||||
# setup our configuration space
 | 
			
		||||
sub BUILD {
 | 
			
		||||
    my $self = shift;
 | 
			
		||||
| 
						 | 
				
			
			@ -175,7 +172,7 @@ sub _add_expolygon {
 | 
			
		|||
    for my $i (0 .. $#points) {
 | 
			
		||||
        for my $j (($i+1) .. $#points) {
 | 
			
		||||
            my $line = Slic3r::Line->new($points[$i], $points[$j]);
 | 
			
		||||
            if ($expolygon->encloses_line($line, $self->_tolerance)) {
 | 
			
		||||
            if ($expolygon->contains_line($line)) {
 | 
			
		||||
                my $dist = $line->length * ($crosses_perimeter ? CROSSING_FACTOR : 1);
 | 
			
		||||
                $edges->{$points[$i]}{$points[$j]} = $dist;
 | 
			
		||||
                $edges->{$points[$j]}{$points[$i]} = $dist;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue