From 91bc4d8157ac4a75b741640f0f8002d40af5326f Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Wed, 24 Dec 2014 00:11:29 +0100 Subject: [PATCH] Bugfix: a typo caused wrong loop splitting, thus wrong ordering of perimeters having bridging parts. Includes regression test. #2258 --- xs/src/libslic3r/ExtrusionEntity.cpp | 7 ++----- xs/t/08_extrusionloop.t | 27 ++++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/xs/src/libslic3r/ExtrusionEntity.cpp b/xs/src/libslic3r/ExtrusionEntity.cpp index c84b08489..ee49e3357 100644 --- a/xs/src/libslic3r/ExtrusionEntity.cpp +++ b/xs/src/libslic3r/ExtrusionEntity.cpp @@ -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 { diff --git a/xs/t/08_extrusionloop.t b/xs/t/08_extrusionloop.t index dd657d156..0657766c8 100644 --- a/xs/t/08_extrusionloop.t +++ b/xs/t/08_extrusionloop.t @@ -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__