mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-12 17:27:52 -06:00
Fix memory leak in avoid_crossing_perimeters. #1044
This commit is contained in:
parent
813aa5b307
commit
9c122bda5e
2 changed files with 15 additions and 9 deletions
|
@ -168,11 +168,17 @@ sub BUILD {
|
||||||
lines => \@lines,
|
lines => \@lines,
|
||||||
points => [ values %{$self->_pointmap} ],
|
points => [ values %{$self->_pointmap} ],
|
||||||
no_arrows => 1,
|
no_arrows => 1,
|
||||||
polygons => [ map @$_, @{$self->islands} ],
|
expolygons => $self->islands,
|
||||||
#red_polygons => [ map $_->holes, map @$_, @{$self->_inner} ],
|
#red_polygons => [ map $_->holes, map @$_, @{$self->_inner} ],
|
||||||
#white_polygons => [ map @$_, @{$self->_outer} ],
|
#white_polygons => [ map @$_, @{$self->_outer} ],
|
||||||
);
|
);
|
||||||
printf "%d islands\n", scalar @{$self->islands};
|
printf "%d islands\n", scalar @{$self->islands};
|
||||||
|
|
||||||
|
eval "use Devel::Size";
|
||||||
|
print "MEMORY USAGE:\n";
|
||||||
|
printf " %-19s = %.1fMb\n", $_, Devel::Size::total_size($self->$_)/1024/1024
|
||||||
|
for qw(_inner _outer _contours_ex _pointmap _edges _crossing_edges islands last_crossings);
|
||||||
|
printf " %-19s = %.1fMb\n", 'self', Devel::Size::total_size($self)/1024/1024;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -881,24 +881,24 @@ sub write_gcode {
|
||||||
if ($Slic3r::Config->avoid_crossing_perimeters) {
|
if ($Slic3r::Config->avoid_crossing_perimeters) {
|
||||||
push @islands, map +{ perimeters => [], fills => [] }, @{$layer->slices};
|
push @islands, map +{ perimeters => [], fills => [] }, @{$layer->slices};
|
||||||
PERIMETER: foreach my $perimeter (@{$layerm->perimeters}) {
|
PERIMETER: foreach my $perimeter (@{$layerm->perimeters}) {
|
||||||
$perimeter = $perimeter->unpack;
|
my $p = $perimeter->unpack;
|
||||||
for my $i (0 .. $#{$layer->slices}-1) {
|
for my $i (0 .. $#{$layer->slices}-1) {
|
||||||
if ($layer->slices->[$i]->contour->encloses_point($perimeter->first_point)) {
|
if ($layer->slices->[$i]->contour->encloses_point($p->first_point)) {
|
||||||
push @{ $islands[$i]{perimeters} }, $perimeter;
|
push @{ $islands[$i]{perimeters} }, $p;
|
||||||
next PERIMETER;
|
next PERIMETER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
push @{ $islands[-1]{perimeters} }, $perimeter; # optimization
|
push @{ $islands[-1]{perimeters} }, $p; # optimization
|
||||||
}
|
}
|
||||||
FILL: foreach my $fill (@{$layerm->fills}) {
|
FILL: foreach my $fill (@{$layerm->fills}) {
|
||||||
|
my $f = $fill->unpack;
|
||||||
for my $i (0 .. $#{$layer->slices}-1) {
|
for my $i (0 .. $#{$layer->slices}-1) {
|
||||||
$fill = $fill->unpack;
|
if ($layer->slices->[$i]->contour->encloses_point($f->first_point)) {
|
||||||
if ($layer->slices->[$i]->contour->encloses_point($fill->first_point)) {
|
push @{ $islands[$i]{fills} }, $f;
|
||||||
push @{ $islands[$i]{fills} }, $fill;
|
|
||||||
next FILL;
|
next FILL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
push @{ $islands[-1]{fills} }, $fill; # optimization
|
push @{ $islands[-1]{fills} }, $f; # optimization
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
push @islands, {
|
push @islands, {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue