diff --git a/lib/Slic3r/Layer/Region.pm b/lib/Slic3r/Layer/Region.pm index 39cec3d61a..3d089cc82c 100644 --- a/lib/Slic3r/Layer/Region.pm +++ b/lib/Slic3r/Layer/Region.pm @@ -302,7 +302,7 @@ sub make_perimeters { height => $self->height, ); } - + # reapply the nearest point search for starting point # (clone because the collection gets DESTROY'ed) # We allow polyline reversal because Clipper may have randomly diff --git a/lib/Slic3r/Polygon.pm b/lib/Slic3r/Polygon.pm index c12d3dcaf2..124d9ae996 100644 --- a/lib/Slic3r/Polygon.pm +++ b/lib/Slic3r/Polygon.pm @@ -15,6 +15,11 @@ sub wkt { return sprintf "POLYGON((%s))", join ',', map "$_->[0] $_->[1]", @$self; } +sub dump_perl { + my $self = shift; + return sprintf "[%s]", join ',', map "[$_->[0],$_->[1]]", @$self; +} + sub grow { my $self = shift; return $self->split_at_first_point->grow(@_); diff --git a/xs/t/11_clipper.t b/xs/t/11_clipper.t index ca00bc6e3e..f2f7686a85 100644 --- a/xs/t/11_clipper.t +++ b/xs/t/11_clipper.t @@ -4,7 +4,7 @@ use strict; use warnings; use Slic3r::XS; -use Test::More tests => 17; +use Test::More tests => 19; my $square = Slic3r::Polygon->new( # ccw [200, 100], @@ -155,4 +155,26 @@ if (0) { # Clipper does not preserve polyline orientation } } +{ + my $subject = Slic3r::Polyline->new( + [44735000,31936670],[55270000,31936670],[55270000,25270000],[74730000,25270000],[74730000,44730000],[68063296,44730000],[68063296,55270000],[74730000,55270000],[74730000,74730000],[55270000,74730000],[55270000,68063296],[44730000,68063296],[44730000,74730000],[25270000,74730000],[25270000,55270000],[31936670,55270000],[31936670,44730000],[25270000,44730000],[25270000,25270000],[44730000,25270000],[44730000,31936670] + ); + my $clip = [ + Slic3r::Polygon->new([75200000,45200000],[54800000,45200000],[54800000,24800000],[75200000,24800000]), + ]; + my $result = Slic3r::Geometry::Clipper::intersection_pl([$subject], $clip); + is scalar(@$result), 1, 'intersection_pl - result is not empty'; +} + +{ + my $subject = Slic3r::Polygon->new( + [44730000,31936670],[55270000,31936670],[55270000,25270000],[74730000,25270000],[74730000,44730000],[68063296,44730000],[68063296,55270000],[74730000,55270000],[74730000,74730000],[55270000,74730000],[55270000,68063296],[44730000,68063296],[44730000,74730000],[25270000,74730000],[25270000,55270000],[31936670,55270000],[31936670,44730000],[25270000,44730000],[25270000,25270000],[44730000,25270000] + ); + my $clip = [ + Slic3r::Polygon->new([75200000,45200000],[54800000,45200000],[54800000,24800000],[75200000,24800000]), + ]; + my $result = Slic3r::Geometry::Clipper::intersection_ppl([$subject], $clip); + is scalar(@$result), 1, 'intersection_ppl - result is not empty'; +} + __END__