From e0d5f4e528e76a18148f8a988d932e0013b92f37 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Wed, 12 Sep 2012 15:22:43 +0200 Subject: [PATCH] Replace 'scale epsilon' with 'scaled_epsilon' --- lib/Slic3r/Fill/Rectilinear.pm | 8 ++++---- t/arcs.t | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/Slic3r/Fill/Rectilinear.pm b/lib/Slic3r/Fill/Rectilinear.pm index bac965c15..121249eaa 100644 --- a/lib/Slic3r/Fill/Rectilinear.pm +++ b/lib/Slic3r/Fill/Rectilinear.pm @@ -3,7 +3,7 @@ use Moo; extends 'Slic3r::Fill::Base'; -use Slic3r::Geometry qw(X1 Y1 X2 Y2 A B X Y scale unscale epsilon); +use Slic3r::Geometry qw(X1 Y1 X2 Y2 A B X Y scale unscale scaled_epsilon); sub fill_surface { my $self = shift; @@ -36,7 +36,7 @@ sub fill_surface { my $x = $bounding_box->[X1]; my $is_line_pattern = $self->isa('Slic3r::Fill::Line'); my @vertical_lines = (); - for (my $i = 0; $x <= $bounding_box->[X2] + scale epsilon; $i++) { + for (my $i = 0; $x <= $bounding_box->[X2] + scaled_epsilon; $i++) { my $vertical_line = Slic3r::Line->new([$x, $bounding_box->[Y2]], [$x, $bounding_box->[Y1]]); if ($is_line_pattern && $i % 2) { $vertical_line->[A][X] += $line_oscillation; @@ -49,7 +49,7 @@ sub fill_surface { # clip paths against a slightly offsetted expolygon, so that the first and last paths # are kept even if the expolygon has vertical sides my @paths = @{ Boost::Geometry::Utils::polygon_linestring_intersection( - +($expolygon->offset_ex(scale 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]->boost_polygon, # TODO: we should use all the resulting expolygons and clip the linestrings to a multipolygon object Boost::Geometry::Utils::linestring(@vertical_lines), ) }; for (@paths) { @@ -64,7 +64,7 @@ sub fill_surface { ); @paths = (); - my $tolerance = 10 * scale epsilon; + my $tolerance = 10 * scaled_epsilon; my $diagonal_distance = $distance_between_lines * 5; my $can_connect = $is_line_pattern ? sub { diff --git a/t/arcs.t b/t/arcs.t index 1ffcd87b0..972620402 100644 --- a/t/arcs.t +++ b/t/arcs.t @@ -11,7 +11,7 @@ BEGIN { use Slic3r; use Slic3r::ExtrusionPath ':roles'; -use Slic3r::Geometry qw(epsilon scale X Y); +use Slic3r::Geometry qw(scaled_epsilon scale X Y); { my $path = Slic3r::ExtrusionPath->new(polyline => Slic3r::Polyline->new( @@ -61,17 +61,17 @@ use Slic3r::Geometry qw(epsilon scale X Y); isa_ok $collection2->paths->[0], 'Slic3r::ExtrusionPath::Arc', 'path'; my $expected_length = scale 7.06858347057701; - ok abs($collection1->paths->[0]->length - $expected_length) < scale epsilon, 'cw oriented arc has correct length'; - ok abs($collection2->paths->[0]->length - $expected_length) < scale epsilon, 'ccw oriented arc has correct length'; + ok abs($collection1->paths->[0]->length - $expected_length) < scaled_epsilon, 'cw oriented arc has correct length'; + ok abs($collection2->paths->[0]->length - $expected_length) < scaled_epsilon, 'ccw oriented arc has correct length'; is $collection1->paths->[0]->orientation, 'cw', 'cw orientation was correctly detected'; is $collection2->paths->[0]->orientation, 'ccw', 'ccw orientation was correctly detected'; my $center1 = [ map sprintf('%.0f', $_), @{ $collection1->paths->[0]->center } ]; - ok abs($center1->[X] - scale 10) < scale epsilon && abs($center1->[Y] - scale 10) < scale epsilon, 'center was correctly detected'; + ok abs($center1->[X] - scale 10) < scaled_epsilon && abs($center1->[Y] - scale 10) < scaled_epsilon, 'center was correctly detected'; my $center2 = [ map sprintf('%.0f', $_), @{ $collection2->paths->[0]->center } ]; - ok abs($center2->[X] - scale 10) < scale epsilon && abs($center1->[Y] - scale 10) < scale epsilon, 'center was correctly detected'; + ok abs($center2->[X] - scale 10) < scaled_epsilon && abs($center1->[Y] - scale 10) < scaled_epsilon, 'center was correctly detected'; } #==========================================================