Rename $Slic3r::resolution to $Slic3r::scaling_factor

This commit is contained in:
Alessandro Ranellucci 2012-04-16 14:05:38 +02:00
parent d51ba94e8a
commit 96d5e513b8
10 changed files with 26 additions and 26 deletions

View file

@ -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;

View file

@ -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"

View file

@ -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;

View file

@ -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);

View file

@ -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 = ();

View file

@ -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) = @_;

View file

@ -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' }

View file

@ -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;
}

View file

@ -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',

View file

@ -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(