Bugfix: a typo caused wrong loop splitting, thus wrong ordering of perimeters having bridging parts. Includes regression test. #2258
This commit is contained in:
parent
c63d5da5c2
commit
91bc4d8157
@ -244,9 +244,6 @@ ExtrusionLoop::split_at_vertex(const Point &point)
|
||||
path->polyline.points.insert(path->polyline.points.end(), path->polyline.points.begin() + 1, path->polyline.points.begin() + idx + 1);
|
||||
path->polyline.points.erase(path->polyline.points.begin(), path->polyline.points.begin() + idx);
|
||||
} else {
|
||||
// if we have multiple paths we assume they have different types, so no need to
|
||||
// check for continuity as we do for the single path case above
|
||||
|
||||
// new paths list starts with the second half of current path
|
||||
ExtrusionPaths new_paths;
|
||||
{
|
||||
@ -256,10 +253,10 @@ ExtrusionLoop::split_at_vertex(const Point &point)
|
||||
}
|
||||
|
||||
// then we add all paths until the end of current path list
|
||||
new_paths.insert(new_paths.end(), this->paths.begin(), path); // not including this path
|
||||
new_paths.insert(new_paths.end(), path+1, this->paths.end()); // not including this path
|
||||
|
||||
// then we add all paths since the beginning of current list up to the previous one
|
||||
new_paths.insert(new_paths.end(), path+1, this->paths.end()); // not including this path
|
||||
new_paths.insert(new_paths.end(), this->paths.begin(), path); // not including this path
|
||||
|
||||
// finally we add the first half of current path
|
||||
{
|
||||
|
@ -5,7 +5,7 @@ use warnings;
|
||||
|
||||
use List::Util qw(sum);
|
||||
use Slic3r::XS;
|
||||
use Test::More tests => 45;
|
||||
use Test::More tests => 46;
|
||||
|
||||
{
|
||||
my $square = [
|
||||
@ -119,4 +119,29 @@ use Test::More tests => 45;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
my @polylines = (
|
||||
Slic3r::Polyline->new([59312736,4821067],[64321068,4821067],[64321068,4821067],[64321068,9321068],[59312736,9321068]),
|
||||
Slic3r::Polyline->new([59312736,9321068],[9829401,9321068]),
|
||||
Slic3r::Polyline->new([9829401,9321068],[4821067,9321068],[4821067,4821067],[9829401,4821067]),
|
||||
Slic3r::Polyline->new([9829401,4821067],[59312736,4821067]),
|
||||
);
|
||||
my $loop = Slic3r::ExtrusionLoop->new;
|
||||
$loop->append($_) for (
|
||||
Slic3r::ExtrusionPath->new(polyline => $polylines[0], role => Slic3r::ExtrusionPath::EXTR_ROLE_EXTERNAL_PERIMETER, mm3_per_mm => 1),
|
||||
Slic3r::ExtrusionPath->new(polyline => $polylines[1], role => Slic3r::ExtrusionPath::EXTR_ROLE_OVERHANG_PERIMETER, mm3_per_mm => 1),
|
||||
Slic3r::ExtrusionPath->new(polyline => $polylines[2], role => Slic3r::ExtrusionPath::EXTR_ROLE_EXTERNAL_PERIMETER, mm3_per_mm => 1),
|
||||
Slic3r::ExtrusionPath->new(polyline => $polylines[3], role => Slic3r::ExtrusionPath::EXTR_ROLE_OVERHANG_PERIMETER, mm3_per_mm => 1),
|
||||
);
|
||||
my $point = Slic3r::Point->new(4821067,9321068);
|
||||
$loop->split_at_vertex($point) or $loop->split_at($point);
|
||||
is_deeply [ map $_->role, @$loop ], [
|
||||
Slic3r::ExtrusionPath::EXTR_ROLE_EXTERNAL_PERIMETER,
|
||||
Slic3r::ExtrusionPath::EXTR_ROLE_OVERHANG_PERIMETER,
|
||||
Slic3r::ExtrusionPath::EXTR_ROLE_EXTERNAL_PERIMETER,
|
||||
Slic3r::ExtrusionPath::EXTR_ROLE_OVERHANG_PERIMETER,
|
||||
Slic3r::ExtrusionPath::EXTR_ROLE_EXTERNAL_PERIMETER,
|
||||
], 'order is correctly preserved after splitting';
|
||||
}
|
||||
|
||||
__END__
|
||||
|
Loading…
Reference in New Issue
Block a user