Switch print_z to unscaled coordinates

This commit is contained in:
Alessandro Ranellucci 2013-07-29 00:27:53 +02:00
parent 3bcb2f04ed
commit 51de3ce14f
5 changed files with 11 additions and 12 deletions

View File

@ -119,12 +119,11 @@ sub change_layer {
return $gcode;
}
# this method accepts Z in scaled coordinates
# this method accepts Z in unscaled coordinates
sub move_z {
my $self = shift;
my ($z, $comment) = @_;
$z *= &Slic3r::SCALING_FACTOR;
$z += $self->config->z_offset;
my $gcode = "";

View File

@ -16,7 +16,7 @@ sub process_layer {
my $new_gcode = "";
my $layer_height = $layer->height;
my $z = unscale($layer->print_z) - $layer_height;
my $z = $layer->print_z - $layer_height;
my $newlayer = 0;
Slic3r::GCode::Reader->new(gcode => $gcode)->parse(sub {
my ($reader, $cmd, $args, $info) = @_;

View File

@ -11,7 +11,7 @@ has 'regions' => (is => 'ro', default => sub { [] });
has 'slicing_errors' => (is => 'rw');
has 'slice_z' => (is => 'ro', required => 1); # Z used for slicing in scaled coordinates
has 'print_z' => (is => 'ro', required => 1); # Z used for printing in scaled coordinates
has 'print_z' => (is => 'ro', required => 1); # Z used for printing in unscaled coordinates
has 'height' => (is => 'ro', required => 1); # layer height in unscaled coordinates
# collection of expolygons generated by slicing the original geometry;
@ -51,7 +51,7 @@ sub support_material_contact_height {
# Z used for printing support material contact in scaled coordinates
sub support_material_contact_z {
my $self = shift;
return $self->print_z - ($self->height - $self->support_material_contact_height) / &Slic3r::SCALING_FACTOR;
return ($self->print_z - ($self->height - $self->support_material_contact_height)) / &Slic3r::SCALING_FACTOR;
}
sub upper_layer_slices {

View File

@ -36,7 +36,7 @@ sub BUILD {
object => $self,
id => $id,
height => $height,
print_z => scale $print_z,
print_z => $print_z,
slice_z => -1,
);
}
@ -71,7 +71,7 @@ sub BUILD {
object => $self,
id => $id,
height => $height,
print_z => scale $print_z,
print_z => $print_z,
slice_z => scale $slice_z,
);
@ -904,7 +904,7 @@ sub generate_support_material {
if ($Slic3r::debug) {
printf "Layer %d (z = %.2f) has %d generic support areas, %d normal interface areas, %d contact areas\n",
$i, unscale($layer->print_z), scalar(@{$layers{$i}}), scalar(@{$layers_interfaces{$i}}), scalar(@{$layers_contact_areas{$i}});
$i, $layer->print_z, scalar(@{$layers{$i}}), scalar(@{$layers_interfaces{$i}}), scalar(@{$layers_contact_areas{$i}});
}
}
}

View File

@ -25,7 +25,7 @@ sub export_svg {
my ($filename) = @_;
my $print_size = $self->print->size;
$self->height(unscale max(map $_->print_z, map @{$_->layers}, @{$self->print->objects}));
$self->height(max(map $_->print_z, map @{$_->layers}, @{$self->print->objects}));
my $svg = SVG->new(
width => $self->scale * unscale($print_size->[X]),
height => $self->scale * $self->height,
@ -106,7 +106,7 @@ sub _plot {
# we're cutting the path in the longitudinal direction, so we've got a rectangle
push @rectangles, {
'x' => $self->scale * unscale $line->[A][X],
'y' => $self->scale * $self->_y(unscale($layer->print_z)),
'y' => $self->scale * $self->_y($layer->print_z),
'width' => $self->scale * $width,
'height' => $self->scale * $radius * 2,
'rx' => $self->scale * $radius * 0.35,
@ -115,7 +115,7 @@ sub _plot {
} else {
push @circles, {
'cx' => $self->scale * (unscale($line->[A][X]) + $radius),
'cy' => $self->scale * $self->_y(unscale($layer->print_z) - $radius),
'cy' => $self->scale * $self->_y($layer->print_z - $radius),
'r' => $self->scale * $radius,
};
}
@ -125,7 +125,7 @@ sub _plot {
my $height = $path->height // $layer->height;
{
'x' => $self->scale * unscale $_->[A][X],
'y' => $self->scale * $self->_y(unscale($layer->print_z)),
'y' => $self->scale * $self->_y($layer->print_z),
'width' => $self->scale * unscale(abs($_->[B][X] - $_->[A][X])),
'height' => $self->scale * $height,
'rx' => $self->scale * $height * 0.35,