Use the faster polygon_multi_linestring_intersection()

This commit is contained in:
Alessandro Ranellucci 2013-01-28 00:32:19 +01:00
parent ae201c8f41
commit 2963e54d21
4 changed files with 6 additions and 15 deletions

View file

@ -153,10 +153,7 @@ sub clip_line {
my $self = shift; my $self = shift;
my ($line) = @_; # line must be a Slic3r::Line object my ($line) = @_; # line must be a Slic3r::Line object
return Boost::Geometry::Utils::polygon_linestring_intersection( return Boost::Geometry::Utils::polygon_multi_linestring_intersection($self, [$line]);
$self->boost_polygon,
$line->boost_linestring,
);
} }
sub simplify { sub simplify {

View file

@ -48,9 +48,9 @@ sub fill_surface {
# clip paths against a slightly offsetted expolygon, so that the first and last paths # clip paths against a slightly offsetted expolygon, so that the first and last paths
# are kept even if the expolygon has vertical sides # are kept even if the expolygon has vertical sides
my @paths = @{ Boost::Geometry::Utils::polygon_linestring_intersection( my @paths = @{ Boost::Geometry::Utils::polygon_multi_linestring_intersection(
+($expolygon->offset_ex(scaled_epsilon))[0]->boost_polygon, # TODO: we should use all the resulting expolygons and clip the linestrings to a multipolygon object +($expolygon->offset_ex(scaled_epsilon))[0], # TODO: we should use all the resulting expolygons and clip the linestrings to a multipolygon object
Boost::Geometry::Utils::linestring(@vertical_lines), [ @vertical_lines ],
) }; ) };
for (@paths) { for (@paths) {
$_->[0][Y] += $overlap_distance; $_->[0][Y] += $overlap_distance;

View file

@ -92,10 +92,7 @@ sub BUILD {
my $intersects = sub { my $intersects = sub {
my ($polygon, $line) = @_; my ($polygon, $line) = @_;
@{Boost::Geometry::Utils::polygon_linestring_intersection( @{Boost::Geometry::Utils::polygon_multi_linestring_intersection([$polygon], [$line])} > 0;
$polygon->boost_polygon,
$line->boost_linestring,
)} > 0;
}; };
{ {

View file

@ -115,10 +115,7 @@ sub clip_with_expolygon {
my $self = shift; my $self = shift;
my ($expolygon) = @_; my ($expolygon) = @_;
my $result = Boost::Geometry::Utils::polygon_linestring_intersection( my $result = Boost::Geometry::Utils::polygon_multi_linestring_intersection($expolygon, [$self]);
$expolygon->boost_polygon,
$self->boost_linestring,
);
bless $_, 'Slic3r::Polyline' for @$result; bless $_, 'Slic3r::Polyline' for @$result;
bless $_, 'Slic3r::Point' for map @$_, @$result; bless $_, 'Slic3r::Point' for map @$_, @$result;
return @$result; return @$result;