From bf809d1fd041bae6f4eca12bb6c85fb428cdbc95 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sun, 31 Mar 2013 19:50:22 +0200 Subject: [PATCH] Use linestring_length() from Boost --- lib/Slic3r/ExPolygon.pm | 4 ++-- lib/Slic3r/Line.pm | 2 +- lib/Slic3r/Polyline.pm | 4 +--- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/Slic3r/ExPolygon.pm b/lib/Slic3r/ExPolygon.pm index ac1d0fb3..2fa46fe4 100644 --- a/lib/Slic3r/ExPolygon.pm +++ b/lib/Slic3r/ExPolygon.pm @@ -7,7 +7,7 @@ use warnings; use Boost::Geometry::Utils; use List::Util qw(first); use Math::Geometry::Voronoi; -use Slic3r::Geometry qw(X Y A B point_in_polygon same_line line_length epsilon); +use Slic3r::Geometry qw(X Y A B point_in_polygon same_line epsilon); use Slic3r::Geometry::Clipper qw(union_ex JT_MITER); # the constructor accepts an array of polygons @@ -131,7 +131,7 @@ sub encloses_line { # optimization return @$clip == 1 && same_line($clip->[0], $line); } else { - return @$clip == 1 && abs(line_length($clip->[0]) - $line->length) < $tolerance; + return @$clip == 1 && abs(Boost::Geometry::Utils::linestring_length($clip->[0]) - $line->length) < $tolerance; } } diff --git a/lib/Slic3r/Line.pm b/lib/Slic3r/Line.pm index d0d0a3da..81ca1d48 100644 --- a/lib/Slic3r/Line.pm +++ b/lib/Slic3r/Line.pm @@ -29,7 +29,7 @@ sub coincides_with { sub length { my $self = shift; - return Slic3r::Geometry::line_length($self); + return Boost::Geometry::Utils::linestring_length($self); } sub vector { diff --git a/lib/Slic3r/Polyline.pm b/lib/Slic3r/Polyline.pm index 12fe0cb9..5883cf00 100644 --- a/lib/Slic3r/Polyline.pm +++ b/lib/Slic3r/Polyline.pm @@ -79,9 +79,7 @@ sub reverse { sub length { my $self = shift; - my $length = 0; - $length += $_->length for $self->lines; - return $length; + return Boost::Geometry::Utils::linestring_length($self); } sub grow {