diff --git a/lib/Slic3r/GCode/MotionPlanner.pm b/lib/Slic3r/GCode/MotionPlanner.pm index 6eff6c3bc..026485357 100644 --- a/lib/Slic3r/GCode/MotionPlanner.pm +++ b/lib/Slic3r/GCode/MotionPlanner.pm @@ -75,6 +75,7 @@ sub BUILD { { my @outer = (map @$_, @{$self->_outer}); + my @outer_ex = map [$_], @outer; # as ExPolygons # lines of outer polygons connect visible points for my $i (0 .. $#outer) { @@ -91,7 +92,7 @@ sub BUILD { for my $m (0 .. $#{$outer[$i]}) { for my $n (0 .. $#{$outer[$j]}) { my $line = Slic3r::Line->new($outer[$i][$m], $outer[$j][$n]); - if (!first { $_->intersects_line($line) } @outer) { + if (!@{Boost::Geometry::Utils::multi_polygon_multi_linestring_intersection(\@outer_ex, [$line])}) { # this line does not cross any polygon my $dist = $line->length; $edges->{$outer[$i][$m]}{$outer[$j][$n]} = $dist; @@ -106,12 +107,13 @@ sub BUILD { # lines connecting inner polygons contours are visible but discouraged if (!$self->no_internal) { my @inner = (map $_->contour, map @$_, @{$self->_inner}); + my @inner_ex = map [$_], @inner; # as ExPolygons for my $i (0 .. $#inner) { for my $j (($i+1) .. $#inner) { for my $m (0 .. $#{$inner[$i]}) { for my $n (0 .. $#{$inner[$j]}) { my $line = Slic3r::Line->new($inner[$i][$m], $inner[$j][$n]); - if (!first { $_->intersects_line($line) } @inner) { + if (!@{Boost::Geometry::Utils::multi_polygon_multi_linestring_intersection(\@inner_ex, [$line])}) { # this line does not cross any polygon my $dist = $line->length * CROSSING_FACTOR; $edges->{$inner[$i][$m]}{$inner[$j][$n]} = $dist; diff --git a/lib/Slic3r/Polygon.pm b/lib/Slic3r/Polygon.pm index f8df6915a..6e460f40b 100644 --- a/lib/Slic3r/Polygon.pm +++ b/lib/Slic3r/Polygon.pm @@ -172,10 +172,4 @@ sub split_at_first_point { return $self->split_at_index(0); } -sub intersects_line { - my $self = shift; - my ($line) = @_; - return @{Boost::Geometry::Utils::polygon_multi_linestring_intersection([$self], [$line])} > 0; -} - 1; \ No newline at end of file