From 96d5e513b89d52b263ace4d68acf2acdb75c17e6 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Mon, 16 Apr 2012 14:05:38 +0200 Subject: [PATCH] Rename $Slic3r::resolution to $Slic3r::scaling_factor --- lib/Slic3r.pm | 4 ++-- lib/Slic3r/Config.pm | 2 +- lib/Slic3r/ExPolygon.pm | 2 +- lib/Slic3r/Extruder.pm | 18 +++++++++--------- lib/Slic3r/ExtrusionPath.pm | 2 +- lib/Slic3r/Geometry.pm | 4 ++-- lib/Slic3r/Layer.pm | 8 ++++---- lib/Slic3r/Polygon.pm | 4 ++-- lib/Slic3r/Print.pm | 4 ++-- lib/Slic3r/SVG.pm | 4 ++-- 10 files changed, 26 insertions(+), 26 deletions(-) diff --git a/lib/Slic3r.pm b/lib/Slic3r.pm index 4aa7d0d99..0bf8e150b 100644 --- a/lib/Slic3r.pm +++ b/lib/Slic3r.pm @@ -82,8 +82,8 @@ our $perimeter_acceleration = 25; # mm/s^2 our $infill_acceleration = 50; # mm/s^2 # accuracy options -our $resolution = 0.00000001; -our $small_perimeter_area = ((6.5 / $resolution)**2)*PI; +our $scaling_factor = 0.00000001; +our $small_perimeter_area = ((6.5 / $scaling_factor)**2)*PI; our $layer_height = 0.4; our $first_layer_height_ratio = 1; our $infill_every_layers = 1; diff --git a/lib/Slic3r/Config.pm b/lib/Slic3r/Config.pm index 34f880101..e504171ab 100644 --- a/lib/Slic3r/Config.pm +++ b/lib/Slic3r/Config.pm @@ -534,7 +534,7 @@ sub validate { die "Invalid value for --layer-height\n" if $Slic3r::layer_height <= 0; die "--layer-height must be a multiple of print resolution\n" - if $Slic3r::layer_height / $Slic3r::resolution % 1 != 0; + if $Slic3r::layer_height / $Slic3r::scaling_factor % 1 != 0; # --first-layer-height-ratio die "Invalid value for --first-layer-height-ratio\n" diff --git a/lib/Slic3r/ExPolygon.pm b/lib/Slic3r/ExPolygon.pm index 1c014eb05..d6470bdc3 100644 --- a/lib/Slic3r/ExPolygon.pm +++ b/lib/Slic3r/ExPolygon.pm @@ -62,7 +62,7 @@ sub boost_polygon { sub offset { my $self = shift; my ($distance, $scale, $joinType, $miterLimit) = @_; - $scale ||= $Slic3r::resolution * 1000000; + $scale ||= $Slic3r::scaling_factor * 1000000; $joinType = JT_MITER if !defined $joinType; $miterLimit ||= 2; diff --git a/lib/Slic3r/Extruder.pm b/lib/Slic3r/Extruder.pm index 53aa60db0..7ecafa186 100644 --- a/lib/Slic3r/Extruder.pm +++ b/lib/Slic3r/Extruder.pm @@ -40,7 +40,7 @@ sub change_layer { my ($layer) = @_; $self->layer($layer); - my $z = $Slic3r::z_offset + $layer->print_z * $Slic3r::resolution; + my $z = $Slic3r::z_offset + $layer->print_z * $Slic3r::scaling_factor; my $gcode = ""; @@ -100,7 +100,7 @@ sub extrude_path { # retract if distance from previous position is greater or equal to the one # specified by the user *and* to the maximum distance between infill lines { - my $distance_from_last_pos = $self->last_pos->distance_to($path->points->[0]) * $Slic3r::resolution; + my $distance_from_last_pos = $self->last_pos->distance_to($path->points->[0]) * $Slic3r::scaling_factor; my $distance_threshold = $Slic3r::retract_before_travel; $distance_threshold = 2 * $Slic3r::flow_width / $Slic3r::fill_density * sqrt(2) if $Slic3r::fill_density > 0 && $description =~ /fill/; @@ -133,7 +133,7 @@ sub extrude_path { $area = $Slic3r::nozzle_diameter * $h * (1 - PI/4) + $h * $w * PI/4; } - my $e = $Slic3r::resolution + my $e = $Slic3r::scaling_factor * $area * $Slic3r::extrusion_multiplier * (4 / (($Slic3r::filament_diameter ** 2) * PI)); @@ -259,8 +259,8 @@ sub _G0_G1 { if ($point) { $gcode .= sprintf " X%.${dec}f Y%.${dec}f", - ($point->x * $Slic3r::resolution) + $self->shift_x, - ($point->y * $Slic3r::resolution) + $self->shift_y; #** + ($point->x * $Slic3r::scaling_factor) + $self->shift_x, + ($point->y * $Slic3r::scaling_factor) + $self->shift_y; #** $self->last_pos($point); } if (defined $z && $z != $self->z) { @@ -279,13 +279,13 @@ sub G2_G3 { my $gcode = $orientation eq 'cw' ? "G2" : "G3"; $gcode .= sprintf " X%.${dec}f Y%.${dec}f", - ($point->x * $Slic3r::resolution) + $self->shift_x, - ($point->y * $Slic3r::resolution) + $self->shift_y; #** + ($point->x * $Slic3r::scaling_factor) + $self->shift_x, + ($point->y * $Slic3r::scaling_factor) + $self->shift_y; #** # XY distance of the center from the start position $gcode .= sprintf " I%.${dec}f J%.${dec}f", - ($center->[X] - $self->last_pos->[X]) * $Slic3r::resolution, - ($center->[Y] - $self->last_pos->[Y]) * $Slic3r::resolution; + ($center->[X] - $self->last_pos->[X]) * $Slic3r::scaling_factor, + ($center->[Y] - $self->last_pos->[Y]) * $Slic3r::scaling_factor; $self->last_pos($point); return $self->_Gx($gcode, $e, $comment); diff --git a/lib/Slic3r/ExtrusionPath.pm b/lib/Slic3r/ExtrusionPath.pm index 173a05ee2..750b9c5b6 100644 --- a/lib/Slic3r/ExtrusionPath.pm +++ b/lib/Slic3r/ExtrusionPath.pm @@ -130,7 +130,7 @@ sub detect_arcs { my ($max_angle, $len_epsilon) = @_; $max_angle = deg2rad($max_angle || 15); - $len_epsilon ||= 10 / $Slic3r::resolution; + $len_epsilon ||= 10 / $Slic3r::scaling_factor; my @points = @{$self->points}; my @paths = (); diff --git a/lib/Slic3r/Geometry.pm b/lib/Slic3r/Geometry.pm index f2339e0ce..7a30499b4 100644 --- a/lib/Slic3r/Geometry.pm +++ b/lib/Slic3r/Geometry.pm @@ -39,8 +39,8 @@ our $parallel_degrees_limit = abs(deg2rad(3)); sub epsilon () { 1E-4 } -sub scale ($) { $_[0] / $Slic3r::resolution } -sub unscale ($) { $_[0] * $Slic3r::resolution } +sub scale ($) { $_[0] / $Slic3r::scaling_factor } +sub unscale ($) { $_[0] * $Slic3r::scaling_factor } sub slope { my ($line) = @_; diff --git a/lib/Slic3r/Layer.pm b/lib/Slic3r/Layer.pm index 5642ed8f1..b2672b899 100644 --- a/lib/Slic3r/Layer.pm +++ b/lib/Slic3r/Layer.pm @@ -82,18 +82,18 @@ has 'fills' => ( sub slice_z { my $self = shift; if ($self->id == 0) { - return ($Slic3r::layer_height * $Slic3r::first_layer_height_ratio) / 2 / $Slic3r::resolution; + return ($Slic3r::layer_height * $Slic3r::first_layer_height_ratio) / 2 / $Slic3r::scaling_factor; } return (($Slic3r::layer_height * $Slic3r::first_layer_height_ratio) + (($self->id-1) * $Slic3r::layer_height) - + ($Slic3r::layer_height/2)) / $Slic3r::resolution; + + ($Slic3r::layer_height/2)) / $Slic3r::scaling_factor; } # Z used for printing sub print_z { my $self = shift; return (($Slic3r::layer_height * $Slic3r::first_layer_height_ratio) - + ($self->id * $Slic3r::layer_height)) / $Slic3r::resolution; + + ($self->id * $Slic3r::layer_height)) / $Slic3r::scaling_factor; } sub height { @@ -175,7 +175,7 @@ sub prepare_fill_surfaces { # merge too small internal surfaces with their surrounding tops # (if they're too small, they can be treated as solid) { - my $min_area = ((7 * $Slic3r::flow_spacing / $Slic3r::resolution)**2) * PI; + my $min_area = ((7 * $Slic3r::flow_spacing / $Slic3r::scaling_factor)**2) * PI; my $small_internal = [ grep { $_->expolygon->contour->area <= $min_area } grep { $_->surface_type eq 'internal' } diff --git a/lib/Slic3r/Polygon.pm b/lib/Slic3r/Polygon.pm index c5296fb3e..97cbc910b 100644 --- a/lib/Slic3r/Polygon.pm +++ b/lib/Slic3r/Polygon.pm @@ -95,7 +95,7 @@ sub safety_offset { sub offset { my $self = shift; my ($distance, $scale, $joinType, $miterLimit) = @_; - $scale ||= $Slic3r::resolution * 1000000; + $scale ||= $Slic3r::scaling_factor * 1000000; $joinType = JT_MITER if !defined $joinType; $miterLimit ||= 2; @@ -135,7 +135,7 @@ sub is_printable { # if no offset is possible, then polyline is not printable my $p = $self->clone; $p->make_counter_clockwise; - my $offsets = Math::Clipper::offset([$p], -(scale $Slic3r::flow_spacing / 2), $Slic3r::resolution * 100000, JT_MITER, 2); + my $offsets = Math::Clipper::offset([$p], -(scale $Slic3r::flow_spacing / 2), $Slic3r::scaling_factor * 100000, JT_MITER, 2); return @$offsets ? 1 : 0; } diff --git a/lib/Slic3r/Print.pm b/lib/Slic3r/Print.pm index 488f327bc..f945f1305 100644 --- a/lib/Slic3r/Print.pm +++ b/lib/Slic3r/Print.pm @@ -27,7 +27,7 @@ sub new_from_mesh { my ($mesh) = @_; $mesh->rotate($Slic3r::rotate); - $mesh->scale($Slic3r::scale / $Slic3r::resolution); + $mesh->scale($Slic3r::scale / $Slic3r::scaling_factor); $mesh->align_to_origin; # initialize print job @@ -495,7 +495,7 @@ sub extrude_skirt { my @skirts = (); for (my $i = $Slic3r::skirts - 1; $i >= 0; $i--) { my $distance = scale ($Slic3r::skirt_distance + ($Slic3r::flow_spacing * $i)); - my $outline = offset([$convex_hull], $distance, $Slic3r::resolution * 100, JT_ROUND); + my $outline = offset([$convex_hull], $distance, $Slic3r::scaling_factor * 100, JT_ROUND); push @skirts, Slic3r::ExtrusionLoop->new( polygon => Slic3r::Polygon->new(@{$outline->[0]}), role => 'skirt', diff --git a/lib/Slic3r/SVG.pm b/lib/Slic3r/SVG.pm index 65921b23e..834e59f6b 100644 --- a/lib/Slic3r/SVG.pm +++ b/lib/Slic3r/SVG.pm @@ -8,12 +8,12 @@ use constant X => 0; use constant Y => 1; sub factor { - return $Slic3r::resolution * 10; + return $Slic3r::scaling_factor * 10; } sub svg { my ($print) = @_; - $print ||= Slic3r::Print->new(x_length => 200 / $Slic3r::resolution, y_length => 200 / $Slic3r::resolution); + $print ||= Slic3r::Print->new(x_length => 200 / $Slic3r::scaling_factor, y_length => 200 / $Slic3r::scaling_factor); my $svg = SVG->new(width => $print->max_length * factor(), height => $print->max_length * factor()); my $marker_end = $svg->marker(