Adjust collision detection for brim and include support islands inside the only_retract_when_crossing_perimeters logic

This commit is contained in:
Alessandro Ranellucci 2013-08-09 14:55:36 +02:00
parent 67f5b7ab14
commit 5d80c26b29
4 changed files with 29 additions and 16 deletions

View File

@ -14,6 +14,8 @@ has 'enable_loop_clipping' => (is => 'rw', default => sub {1});
has 'enable_wipe' => (is => 'lazy'); # at least one extruder has wipe enabled
has 'layer_count' => (is => 'ro', required => 1 );
has 'layer' => (is => 'rw');
has '_layer_islands' => (is => 'rw');
has '_upper_layer_islands' => (is => 'rw');
has '_layer_overhangs' => (is => 'rw');
has 'move_z_callback' => (is => 'rw');
has 'shift_x' => (is => 'rw', default => sub {0} );
@ -98,7 +100,14 @@ sub change_layer {
$self->layer($layer);
# avoid computing overhangs if they're not needed
# avoid computing islands and overhangs if they're not needed
if ($self->config->only_retract_when_crossing_perimeters) {
$self->_layer_islands([ $layer->islands ]);
$self->_upper_layer_islands([ $layer->upper_layer_islands ]);
} else {
$self->_layer_islands([]);
$self->_upper_layer_islands([]);
}
$self->_layer_overhangs(
$layer->id > 0 && ($Slic3r::Config->overhangs || $Slic3r::Config->start_perimeters_at_non_overhang)
? [ map $_->expolygon, grep $_->surface_type == S_TYPE_BOTTOM, map @{$_->slices}, @{$layer->regions} ]
@ -374,9 +383,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->layer->upper_layer_slices})
&& (first { $_->encloses_line($travel, scaled_epsilon) } @{$self->layer->slices}))
|| ($role == EXTR_ROLE_SUPPORTMATERIAL && $self->layer->support_islands_enclose_line($travel))
&& (first { $_->encloses_line($travel, scaled_epsilon) } @{$self->_upper_layer_islands})
&& (first { $_->encloses_line($travel, scaled_epsilon) } @{$self->_layer_islands}))
|| ($role == EXTR_ROLE_SUPPORTMATERIAL && (first { $_->encloses_line($travel, scaled_epsilon) } @{$self->layer->support_islands}))
) {
$self->straight_once(0);
$self->speed('travel');

View File

@ -23,11 +23,16 @@ sub _trigger_id {
$_->_trigger_layer for @{$self->regions || []};
}
sub upper_layer_slices {
sub islands {
my $self = shift;
return @{$self->slices};
}
sub upper_layer_islands {
my $self = shift;
my $upper_layer = $self->object->layers->[ $self->id + 1 ] or return [];
return $upper_layer->slices;
my $upper_layer = $self->object->layers->[ $self->id + 1 ] or return ();
return $upper_layer->islands;
}
sub region {
@ -56,20 +61,18 @@ sub make_perimeters {
$_->make_perimeters for @{$self->regions};
}
sub support_islands_enclose_line {
my $self = shift;
my ($line) = @_;
return 0 if !$self->support_islands; # why can we arrive here if there are no support islands?
return (first { $_->encloses_line($line) } @{$self->support_islands}) ? 1 : 0;
}
package Slic3r::Layer::Support;
use Moo;
extends 'Slic3r::Layer';
# ordered collection of extrusion paths to fill surfaces for support material
has 'support_islands' => (is => 'rw');
has 'support_islands' => (is => 'rw', default => sub { [] });
has 'support_fills' => (is => 'rw');
has 'support_interface_fills' => (is => 'rw');
sub islands {
my $self = shift;
return @{$self->slices}, @{$self->support_islands};
}
1;

View File

@ -682,7 +682,7 @@ sub make_brim {
# -0.5 because islands are not represented by their centerlines
# (first offset more, then step back - reverse order than the one used for
# perimeters because here we're offsetting outwards)
push @loops, offset2(\@islands, ($i + 1.0) * $flow->scaled_spacing, -1.5 * $flow->scaled_spacing, undef, JT_SQUARE);
push @loops, offset2(\@islands, ($i + 0.5) * $flow->scaled_spacing, -1.0 * $flow->scaled_spacing, undef, JT_SQUARE);
}
@{$self->brim} = map Slic3r::ExtrusionLoop->pack(

View File

@ -1192,6 +1192,7 @@ sub generate_support_material {
my $support_collection = Slic3r::ExtrusionPath::Collection->new(paths => $result->{support});
$layer->support_fills($support_collection) if @{$support_collection->paths} > 0;
# TODO: use a Slic3r::ExPolygon::Collection
$layer->support_islands($result->{islands});
};
Slic3r::parallelize(