mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-12 07:08:59 +08:00
Reduce computational complexity of make_loops() => speed boost
This commit is contained in:
parent
3cf5f86ce0
commit
6f9cefe001
@ -196,6 +196,14 @@ sub make_loops {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# optimization: build indexes of lines
|
||||||
|
my %by_facet_index = map { $lines[$_]->facet_index => $_ }
|
||||||
|
grep defined $lines[$_]->facet_index,
|
||||||
|
(0..$#lines);
|
||||||
|
my %by_a_id = map { $lines[$_]->a_id => $_ }
|
||||||
|
grep defined $lines[$_]->a_id,
|
||||||
|
(0..$#lines);
|
||||||
|
|
||||||
my (@polygons, %visited_lines) = ();
|
my (@polygons, %visited_lines) = ();
|
||||||
CYCLE: for (my $i = 0; $i <= $#lines; $i++) {
|
CYCLE: for (my $i = 0; $i <= $#lines; $i++) {
|
||||||
my $line = $lines[$i];
|
my $line = $lines[$i];
|
||||||
@ -205,23 +213,12 @@ sub make_loops {
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
my $next_line;
|
my $next_line;
|
||||||
if (defined $line->next_facet_index) {
|
if (defined $line->next_facet_index && exists $by_facet_index{$line->next_facet_index}) {
|
||||||
for (@lines) {
|
my $l = $lines[$by_facet_index{$line->next_facet_index}];
|
||||||
next if $visited_lines{$_};
|
$next_line = $l unless $visited_lines{$l};
|
||||||
if ($_->facet_index == $line->next_facet_index) {
|
} elsif (defined $line->b_id && exists $by_a_id{$line->b_id}) {
|
||||||
$next_line = $_;
|
my $l = $lines[$by_a_id{$line->b_id}];
|
||||||
last;
|
$next_line = $l unless $visited_lines{$l};
|
||||||
}
|
|
||||||
}
|
|
||||||
} elsif (defined $line->b_id) {
|
|
||||||
for (@lines) {
|
|
||||||
next if !defined $_->a_id;
|
|
||||||
next if $visited_lines{$_};
|
|
||||||
if ($_->a_id == $line->b_id) {
|
|
||||||
$next_line = $_;
|
|
||||||
last;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Slic3r::debugf " line has no next_facet_index or b_id\n";
|
Slic3r::debugf " line has no next_facet_index or b_id\n";
|
||||||
$layer->slicing_errors(1);
|
$layer->slicing_errors(1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user