diff --git a/lib/Slic3r/ExtrusionPath.pm b/lib/Slic3r/ExtrusionPath.pm index e2f43e345..531c7ab6e 100644 --- a/lib/Slic3r/ExtrusionPath.pm +++ b/lib/Slic3r/ExtrusionPath.pm @@ -10,29 +10,9 @@ our @EXPORT_OK = qw(EXTR_ROLE_PERIMETER EXTR_ROLE_EXTERNAL_PERIMETER EXTR_ROLE_INTERNALBRIDGE EXTR_ROLE_SKIRT EXTR_ROLE_SUPPORTMATERIAL EXTR_ROLE_GAPFILL); our %EXPORT_TAGS = (roles => \@EXPORT_OK); -sub clip_with_polygon { - my $self = shift; - my ($polygon) = @_; - - return $self->clip_with_expolygon(Slic3r::ExPolygon->new($polygon)); -} - -sub clip_with_expolygon { - my $self = shift; - my ($expolygon) = @_; - - return map $self->clone(polyline => $_), - $self->polyline->clip_with_expolygon($expolygon); -} - sub simplify { my $self = shift; $self->polyline($self->polyline->simplify(@_)); } -sub points { - my $self = shift; - return $self->polyline; -} - 1; diff --git a/lib/Slic3r/Fill/PlanePath.pm b/lib/Slic3r/Fill/PlanePath.pm index c911b8980..0797fd10e 100644 --- a/lib/Slic3r/Fill/PlanePath.pm +++ b/lib/Slic3r/Fill/PlanePath.pm @@ -4,6 +4,7 @@ use Moo; extends 'Slic3r::Fill::Base'; use Slic3r::Geometry qw(scale X1 Y1 X2 Y2); +use Slic3r::Geometry::Clipper qw(intersection_pl); sub multiplier () { 1 } @@ -40,8 +41,7 @@ sub fill_surface { $self->process_polyline($polyline, $bounding_box); - my @paths = map $_->clip_with_expolygon($expolygon), - $polyline->clip_with_polygon($bounding_box->polygon); + my @paths = @{intersection_pl([$polyline], \@$expolygon)}; if (0) { require "Slic3r/SVG.pm"; diff --git a/lib/Slic3r/Layer/Region.pm b/lib/Slic3r/Layer/Region.pm index b57a1f091..dc3a60174 100644 --- a/lib/Slic3r/Layer/Region.pm +++ b/lib/Slic3r/Layer/Region.pm @@ -6,7 +6,7 @@ use Slic3r::ExtrusionPath ':roles'; use Slic3r::Geometry qw(PI A B scale unscale chained_path_items points_coincide); use Slic3r::Geometry::Clipper qw(union_ex diff_ex intersection_ex offset offset2 offset2_ex union_pt traverse_pt diff intersection - union diff); + union diff intersection_pl); use Slic3r::Surface ':types'; has 'layer' => ( @@ -491,7 +491,7 @@ sub _detect_bridge_direction { foreach my $lower (@lower) { # turn bridge contour and holes into polylines and then clip them # with each lower slice's contour - my @clipped = map $_->split_at_first_point->clip_with_polygon($lower->contour), map @$_, @$grown; + my @clipped = @{intersection_pl([ map $_->split_at_first_point, map @$_, @$grown ], [$lower->contour])}; if (@clipped == 2) { # If the split_at_first_point() call above happens to split the polygon inside the clipping area # we would get two consecutive polylines instead of a single one, so we use this ugly hack to diff --git a/lib/Slic3r/Polyline.pm b/lib/Slic3r/Polyline.pm index 0a66be258..fc368a692 100644 --- a/lib/Slic3r/Polyline.pm +++ b/lib/Slic3r/Polyline.pm @@ -35,21 +35,6 @@ sub simplify { return __PACKAGE__->new(@$simplified); } -sub clip_with_polygon { - my $self = shift; - my ($polygon) = @_; - - return $self->clip_with_expolygon(Slic3r::ExPolygon->new($polygon)); -} - -sub clip_with_expolygon { - my $self = shift; - my ($expolygon) = @_; - - my $result = Boost::Geometry::Utils::polygon_multi_linestring_intersection($expolygon->pp, [$self->pp]); - return map { __PACKAGE__->new(@$_) } @$result; -} - sub bounding_box { my $self = shift; return Slic3r::Geometry::BoundingBox->new_from_points($self);