Some basic ability to close holes in non-manifold models
This commit is contained in:
parent
85ef7ce665
commit
5c9916dc75
@ -237,7 +237,7 @@ sub make_loops {
|
|||||||
grep defined $lines[$_][I_A_ID],
|
grep defined $lines[$_][I_A_ID],
|
||||||
(0..$#lines);
|
(0..$#lines);
|
||||||
|
|
||||||
my (@polygons, %visited_lines) = ();
|
my (@polygons, @failed_loops, %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];
|
||||||
next if $visited_lines{$line};
|
next if $visited_lines{$line};
|
||||||
@ -253,20 +253,24 @@ sub make_loops {
|
|||||||
} 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);
|
||||||
|
push @failed_loops, [@points] if @points;
|
||||||
next CYCLE;
|
next CYCLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$next_line || $visited_lines{$next_line}) {
|
if (!$next_line || $visited_lines{$next_line}) {
|
||||||
Slic3r::debugf " failed to close this loop\n";
|
Slic3r::debugf " failed to close this loop\n";
|
||||||
$layer->slicing_errors(1);
|
$layer->slicing_errors(1);
|
||||||
|
push @failed_loops, [@points] if @points;
|
||||||
next CYCLE;
|
next CYCLE;
|
||||||
} elsif (defined $next_line->[I_PREV_FACET_INDEX] && $next_line->[I_PREV_FACET_INDEX] != $line->[I_FACET_INDEX]) {
|
} elsif (defined $next_line->[I_PREV_FACET_INDEX] && $next_line->[I_PREV_FACET_INDEX] != $line->[I_FACET_INDEX]) {
|
||||||
Slic3r::debugf " wrong prev_facet_index\n";
|
Slic3r::debugf " wrong prev_facet_index\n";
|
||||||
$layer->slicing_errors(1);
|
$layer->slicing_errors(1);
|
||||||
|
push @failed_loops, [@points] if @points;
|
||||||
next CYCLE;
|
next CYCLE;
|
||||||
} elsif (defined $next_line->[I_A_ID] && $next_line->[I_A_ID] != $line->[I_B_ID]) {
|
} elsif (defined $next_line->[I_A_ID] && $next_line->[I_A_ID] != $line->[I_B_ID]) {
|
||||||
Slic3r::debugf " wrong a_id\n";
|
Slic3r::debugf " wrong a_id\n";
|
||||||
$layer->slicing_errors(1);
|
$layer->slicing_errors(1);
|
||||||
|
push @failed_loops, [@points] if @points;
|
||||||
next CYCLE;
|
next CYCLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,6 +285,14 @@ sub make_loops {
|
|||||||
if $Slic3r::debug;
|
if $Slic3r::debug;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# TODO: we should try to combine failed loops
|
||||||
|
for (grep @$_ >= 3, @failed_loops) {
|
||||||
|
push @polygons, Slic3r::Polygon->new(@$_);
|
||||||
|
Slic3r::debugf " Discovered failed %s polygon of %d points\n",
|
||||||
|
($polygons[-1]->is_counter_clockwise ? 'ccw' : 'cw'), scalar(@$_)
|
||||||
|
if $Slic3r::debug;
|
||||||
|
}
|
||||||
|
|
||||||
return [@polygons];
|
return [@polygons];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user