Replace 'scale epsilon' with 'scaled_epsilon'
This commit is contained in:
parent
9934f8957f
commit
e0d5f4e528
@ -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 {
|
||||
|
10
t/arcs.t
10
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';
|
||||
}
|
||||
|
||||
#==========================================================
|
||||
|
Loading…
Reference in New Issue
Block a user