Store layer slices and region slices as XS data to save memory and make them shared across threads
This commit is contained in:
parent
d06ac3e31e
commit
f7967414e0
@ -299,6 +299,9 @@ sub medial_axis {
|
||||
return @result;
|
||||
}
|
||||
|
||||
package Slic3r::ExPolygon::XS;
|
||||
use base 'Slic3r::ExPolygon';
|
||||
|
||||
package Slic3r::ExPolygon::Collection;
|
||||
use Moo;
|
||||
use Slic3r::Geometry qw(X1 Y1);
|
||||
|
@ -78,7 +78,9 @@ sub region {
|
||||
# merge all regions' slices to get islands
|
||||
sub make_slices {
|
||||
my $self = shift;
|
||||
$self->slices(union_ex([ map $_->p, map @{$_->slices}, @{$self->regions} ]));
|
||||
|
||||
my $slices = union_ex([ map $_->p, map @{$_->slices}, @{$self->regions} ]);
|
||||
$self->slices([ map Slic3r::ExPolygon::XS->new(@$_), @$slices ]);
|
||||
}
|
||||
|
||||
sub make_perimeters {
|
||||
|
@ -147,7 +147,7 @@ sub _merge_loops {
|
||||
Slic3r::debugf " %d surface(s) having %d holes detected from %d polylines\n",
|
||||
scalar(@$expolygons), scalar(map $_->holes, @$expolygons), scalar(@$loops);
|
||||
|
||||
return map Slic3r::Surface->new(expolygon => $_, surface_type => S_TYPE_INTERNAL), @$expolygons;
|
||||
return map Slic3r::Surface->new(expolygon => Slic3r::ExPolygon::XS->new(@$_), surface_type => S_TYPE_INTERNAL), @$expolygons;
|
||||
}
|
||||
|
||||
sub make_perimeters {
|
||||
|
@ -292,8 +292,8 @@ sub make_perimeters {
|
||||
# of our slice
|
||||
$extra_perimeters++;
|
||||
my $hypothetical_perimeter = diff(
|
||||
[ offset($slice->expolygon, -($perimeter_spacing * ($Slic3r::Config->perimeters + $extra_perimeters-1))) ],
|
||||
[ offset($slice->expolygon, -($perimeter_spacing * ($Slic3r::Config->perimeters + $extra_perimeters))) ],
|
||||
[ offset($slice->expolygon->arrayref, -($perimeter_spacing * ($Slic3r::Config->perimeters + $extra_perimeters-1))) ],
|
||||
[ offset($slice->expolygon->arrayref, -($perimeter_spacing * ($Slic3r::Config->perimeters + $extra_perimeters))) ],
|
||||
);
|
||||
last CYCLE if !@$hypothetical_perimeter; # no extra perimeter is possible
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user