Bugfix: sometimes holes were detected as contours

This commit is contained in:
Alessandro Ranellucci 2011-12-01 20:57:38 +01:00
parent 133f3a0495
commit f7a9c9be63
2 changed files with 12 additions and 3 deletions

View File

@ -5,7 +5,8 @@ use warnings;
require Exporter;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw(explode_expolygon explode_expolygons safety_offset offset
diff_ex diff union_ex intersection_ex PFT_EVENODD JT_MITER JT_ROUND);
diff_ex diff union_ex intersection_ex PFT_EVENODD JT_MITER JT_ROUND
is_counter_clockwise);
use Math::Clipper 1.02 ':all';
our $clipper = Math::Clipper->new;

View File

@ -3,7 +3,7 @@ use Moo;
use Math::Clipper ':all';
use Slic3r::Geometry qw(scale collinear X Y A B PI);
use Slic3r::Geometry::Clipper qw(union_ex diff_ex intersection_ex PFT_EVENODD);
use Slic3r::Geometry::Clipper qw(union_ex diff_ex intersection_ex is_counter_clockwise);
use XXX;
# a sequential number of layer, starting at 0
@ -98,7 +98,15 @@ sub make_surfaces {
my ($loops) = @_;
{
my $expolygons = union_ex($loops, PFT_EVENODD);
# merge contours
my $expolygons = union_ex([ grep is_counter_clockwise($_), @$loops ]);
# subtract holes
$expolygons = union_ex([
(map @$_, @$expolygons),
(grep !is_counter_clockwise($_), @$loops)
]);
Slic3r::debugf " %d surface(s) having %d holes detected from %d polylines\n",
scalar(@$expolygons), scalar(map $_->holes, @$expolygons), scalar(@$loops);