Fix regression in start perimeters at non-overhangs. #1442

This commit is contained in:
Alessandro Ranellucci 2013-09-16 18:42:28 +02:00
parent 9a51964e98
commit a88ce0cb5e
3 changed files with 17 additions and 16 deletions

View File

@ -29,18 +29,18 @@ sub clip_with_expolygon {
sub intersect_expolygons {
my $self = shift;
my ($expolygons) = @_;
my ($expolygons_pp) = @_;
return map $self->clone(polyline => Slic3r::Polyline->new(@$_)),
@{Boost::Geometry::Utils::multi_polygon_multi_linestring_intersection([ map $_->pp, @$expolygons ], [$self->pp])};
@{Boost::Geometry::Utils::multi_polygon_multi_linestring_intersection($expolygons_pp, [$self->pp])};
}
sub subtract_expolygons {
my $self = shift;
my ($expolygons) = @_;
my ($expolygons_pp) = @_;
return map $self->clone(polyline => Slic3r::Polyline->new(@$_)),
@{Boost::Geometry::Utils::multi_linestring_multi_polygon_difference([$self->pp], [ map $_->pp, @$expolygons ])};
@{Boost::Geometry::Utils::multi_linestring_multi_polygon_difference([$self->pp], $expolygons_pp)};
}
sub simplify {

View File

@ -16,7 +16,7 @@ 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 '_layer_overhangs_pp' => (is => 'rw');
has 'shift_x' => (is => 'rw', default => sub {0} );
has 'shift_y' => (is => 'rw', default => sub {0} );
has 'z' => (is => 'rw');
@ -99,10 +99,10 @@ sub change_layer {
$self->_layer_islands([]);
$self->_upper_layer_islands([]);
}
$self->_layer_overhangs(
$self->_layer_overhangs_pp(
# clone ExPolygons because they come from Surface objects but will be used outside here
$layer->id > 0 && ($layer->config->overhangs || $Slic3r::Config->start_perimeters_at_non_overhang)
? [ map $_->expolygon->clone, grep $_->surface_type == S_TYPE_BOTTOM, map @{$_->slices}, @{$layer->regions} ]
($layer->id > 0 && ($layer->config->overhangs || $Slic3r::Config->start_perimeters_at_non_overhang))
? [ map $_->expolygon->pp, grep $_->surface_type == S_TYPE_BOTTOM, map @{$_->slices}, @{$layer->regions} ]
: []
);
if ($self->config->avoid_crossing_perimeters) {
@ -180,7 +180,7 @@ sub extrude_loop {
}
my @candidates = ();
if ($Slic3r::Config->start_perimeters_at_non_overhang) {
@candidates = grep !Boost::Geometry::Utils::point_covered_by_multi_polygon($_->pp, $self->_layer_overhangs), @concave;
@candidates = grep !Boost::Geometry::Utils::point_covered_by_multi_polygon($_->pp, $self->_layer_overhangs_pp), @concave;
}
if (!@candidates) {
# if none, look for any concave vertex
@ -188,7 +188,7 @@ sub extrude_loop {
if (!@candidates) {
# if none, look for any non-overhang vertex
if ($Slic3r::Config->start_perimeters_at_non_overhang) {
@candidates = grep !Boost::Geometry::Utils::point_covered_by_multi_polygon($_->pp, $self->_layer_overhangs), @{$polygon};
@candidates = grep !Boost::Geometry::Utils::point_covered_by_multi_polygon($_->pp, $self->_layer_overhangs_pp), @$polygon;
}
if (!@candidates) {
# if none, all points are valid candidates
@ -218,15 +218,15 @@ sub extrude_loop {
my @paths = ();
# detect overhanging/bridging perimeters
if ($self->layer->config->overhangs && $extrusion_path->is_perimeter && @{$self->_layer_overhangs}) {
if ($self->layer->config->overhangs && $extrusion_path->is_perimeter && @{$self->_layer_overhangs_pp}) {
# get non-overhang paths by subtracting overhangs from the loop
push @paths,
$extrusion_path->subtract_expolygons($self->_layer_overhangs);
$extrusion_path->subtract_expolygons($self->_layer_overhangs_pp);
# get overhang paths by intersecting overhangs with the loop
push @paths,
map { $_->role(EXTR_ROLE_OVERHANG_PERIMETER); $_ }
$extrusion_path->intersect_expolygons($self->_layer_overhangs);
$extrusion_path->intersect_expolygons($self->_layer_overhangs_pp);
# reapply the nearest point search for starting point
# (clone because the collection gets DESTROY'ed)

View File

@ -69,9 +69,10 @@ sub subdivide {
sub concave_points {
my $self = shift;
my @points = @{$self->pp};
return map $self->[$_],
grep Slic3r::Geometry::angle3points(@points[$_, $_-1, $_+1]) < PI - epsilon,
my @points = @$self;
my @points_pp = @{$self->pp};
return map $points[$_],
grep Slic3r::Geometry::angle3points(@points_pp[$_, $_-1, $_+1]) < PI - epsilon,
-1 .. ($#points-1);
}