Skip to content

Commit

Permalink
Failing test cases for Clipper bug returning empty result set. #2028
Browse files Browse the repository at this point in the history
  • Loading branch information
alranel committed May 12, 2014
1 parent 69002b8 commit 0bbc5b3
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/Slic3r/Layer/Region.pm
Expand Up @@ -295,7 +295,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
Expand Down
5 changes: 5 additions & 0 deletions lib/Slic3r/Polygon.pm
Expand Up @@ -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(@_);
Expand Down
24 changes: 23 additions & 1 deletion xs/t/11_clipper.t
Expand Up @@ -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],
Expand Down Expand Up @@ -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__

0 comments on commit 0bbc5b3

Please sign in to comment.