Switch print_z to unscaled coordinates
This commit is contained in:
parent
3bcb2f04ed
commit
51de3ce14f
@ -119,12 +119,11 @@ sub change_layer {
|
|||||||
return $gcode;
|
return $gcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
# this method accepts Z in scaled coordinates
|
# this method accepts Z in unscaled coordinates
|
||||||
sub move_z {
|
sub move_z {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my ($z, $comment) = @_;
|
my ($z, $comment) = @_;
|
||||||
|
|
||||||
$z *= &Slic3r::SCALING_FACTOR;
|
|
||||||
$z += $self->config->z_offset;
|
$z += $self->config->z_offset;
|
||||||
|
|
||||||
my $gcode = "";
|
my $gcode = "";
|
||||||
|
@ -16,7 +16,7 @@ sub process_layer {
|
|||||||
|
|
||||||
my $new_gcode = "";
|
my $new_gcode = "";
|
||||||
my $layer_height = $layer->height;
|
my $layer_height = $layer->height;
|
||||||
my $z = unscale($layer->print_z) - $layer_height;
|
my $z = $layer->print_z - $layer_height;
|
||||||
my $newlayer = 0;
|
my $newlayer = 0;
|
||||||
Slic3r::GCode::Reader->new(gcode => $gcode)->parse(sub {
|
Slic3r::GCode::Reader->new(gcode => $gcode)->parse(sub {
|
||||||
my ($reader, $cmd, $args, $info) = @_;
|
my ($reader, $cmd, $args, $info) = @_;
|
||||||
|
@ -11,7 +11,7 @@ has 'regions' => (is => 'ro', default => sub { [] });
|
|||||||
has 'slicing_errors' => (is => 'rw');
|
has 'slicing_errors' => (is => 'rw');
|
||||||
|
|
||||||
has 'slice_z' => (is => 'ro', required => 1); # Z used for slicing in scaled coordinates
|
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
|
has 'height' => (is => 'ro', required => 1); # layer height in unscaled coordinates
|
||||||
|
|
||||||
# collection of expolygons generated by slicing the original geometry;
|
# 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
|
# Z used for printing support material contact in scaled coordinates
|
||||||
sub support_material_contact_z {
|
sub support_material_contact_z {
|
||||||
my $self = shift;
|
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 {
|
sub upper_layer_slices {
|
||||||
|
@ -36,7 +36,7 @@ sub BUILD {
|
|||||||
object => $self,
|
object => $self,
|
||||||
id => $id,
|
id => $id,
|
||||||
height => $height,
|
height => $height,
|
||||||
print_z => scale $print_z,
|
print_z => $print_z,
|
||||||
slice_z => -1,
|
slice_z => -1,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -71,7 +71,7 @@ sub BUILD {
|
|||||||
object => $self,
|
object => $self,
|
||||||
id => $id,
|
id => $id,
|
||||||
height => $height,
|
height => $height,
|
||||||
print_z => scale $print_z,
|
print_z => $print_z,
|
||||||
slice_z => scale $slice_z,
|
slice_z => scale $slice_z,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -904,7 +904,7 @@ sub generate_support_material {
|
|||||||
|
|
||||||
if ($Slic3r::debug) {
|
if ($Slic3r::debug) {
|
||||||
printf "Layer %d (z = %.2f) has %d generic support areas, %d normal interface areas, %d contact areas\n",
|
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}});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ sub export_svg {
|
|||||||
my ($filename) = @_;
|
my ($filename) = @_;
|
||||||
|
|
||||||
my $print_size = $self->print->size;
|
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(
|
my $svg = SVG->new(
|
||||||
width => $self->scale * unscale($print_size->[X]),
|
width => $self->scale * unscale($print_size->[X]),
|
||||||
height => $self->scale * $self->height,
|
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
|
# we're cutting the path in the longitudinal direction, so we've got a rectangle
|
||||||
push @rectangles, {
|
push @rectangles, {
|
||||||
'x' => $self->scale * unscale $line->[A][X],
|
'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,
|
'width' => $self->scale * $width,
|
||||||
'height' => $self->scale * $radius * 2,
|
'height' => $self->scale * $radius * 2,
|
||||||
'rx' => $self->scale * $radius * 0.35,
|
'rx' => $self->scale * $radius * 0.35,
|
||||||
@ -115,7 +115,7 @@ sub _plot {
|
|||||||
} else {
|
} else {
|
||||||
push @circles, {
|
push @circles, {
|
||||||
'cx' => $self->scale * (unscale($line->[A][X]) + $radius),
|
'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,
|
'r' => $self->scale * $radius,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -125,7 +125,7 @@ sub _plot {
|
|||||||
my $height = $path->height // $layer->height;
|
my $height = $path->height // $layer->height;
|
||||||
{
|
{
|
||||||
'x' => $self->scale * unscale $_->[A][X],
|
'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])),
|
'width' => $self->scale * unscale(abs($_->[B][X] - $_->[A][X])),
|
||||||
'height' => $self->scale * $height,
|
'height' => $self->scale * $height,
|
||||||
'rx' => $self->scale * $height * 0.35,
|
'rx' => $self->scale * $height * 0.35,
|
||||||
|
Loading…
Reference in New Issue
Block a user