Never scale TriangleMesh objects

This commit is contained in:
Alessandro Ranellucci 2013-11-23 19:25:33 +01:00
parent 46e3b3180e
commit e75dbf37fa
6 changed files with 33 additions and 16 deletions

View file

@ -11,7 +11,7 @@ has 'upper_layer' => (is => 'rw', weak_ref => 1);
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 'slice_z' => (is => 'ro', required => 1); # Z used for slicing in unscaled 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

View file

@ -135,7 +135,7 @@ sub _merge_loops {
$slices = offset2_ex($slices, +$safety_offset, -$safety_offset);
Slic3r::debugf "Layer %d (slice_z = %.2f, print_z = %.2f): %d surface(s) having %d holes detected from %d polylines\n",
$self->id, unscale($self->slice_z), $self->print_z,
$self->id, $self->slice_z, $self->print_z,
scalar(@$slices), scalar(map @{$_->holes}, @$slices), scalar(@$loops)
if $Slic3r::debug;

View file

@ -129,8 +129,6 @@ sub add_model {
$mesh->rotate($object->instances->[0]->rotation, $object->center_2D);
$mesh->scale($object->instances->[0]->scaling_factor);
}
$mesh->scale(1 / &Slic3r::SCALING_FACTOR);
$mesh->repair;
}
@ -140,6 +138,9 @@ sub add_model {
my @align2 = map -$bb->extents->[$_][MIN], (X,Y,Z);
$_->translate(@align2) for grep $_, @meshes;
my $scaled_bb = $bb->clone;
$scaled_bb->scale(1 / &Slic3r::SCALING_FACTOR);
# initialize print object
push @{$self->objects}, Slic3r::Print::Object->new(
print => $self,
@ -150,7 +151,7 @@ sub add_model {
? (map [ scale($_->offset->[X] - $align[X]) - $align2[X], scale($_->offset->[Y] - $align[Y]) - $align2[Y] ], @{$object->instances})
: [0,0],
],
size => $bb->size, # transformed size
size => $scaled_bb->size, # transformed size
input_file => $object->input_file,
config_overrides => $object->config,
layer_height_ranges => $object->layer_height_ranges,
@ -514,7 +515,7 @@ EOF
my @previous_layer_slices = ();
for my $layer_id (0..$self->layer_count-1) {
my @layers = map $_->layers->[$layer_id], @{$self->objects};
printf $fh qq{ <g id="layer%d" slic3r:z="%s">\n}, $layer_id, unscale +(grep defined $_, @layers)[0]->slice_z;
printf $fh qq{ <g id="layer%d" slic3r:z="%s">\n}, $layer_id, +(grep defined $_, @layers)[0]->slice_z;
my @current_layer_slices = ();
for my $obj_idx (0 .. $#{$self->objects}) {

View file

@ -63,7 +63,7 @@ sub BUILD {
id => $id,
height => $height,
print_z => $print_z,
slice_z => scale $slice_z,
slice_z => $slice_z,
);
if (@{$self->layers} >= 2) {
$self->layers->[-2]->upper_layer($self->layers->[-1]);