Bugfix: scaling object from the plater applied scale factor over the factor used in the previous slicing job. #1075

This commit is contained in:
Alessandro Ranellucci 2013-05-14 16:31:50 +02:00
parent 7eff002e21
commit 06ad6b70f8
3 changed files with 11 additions and 1 deletions

View File

@ -19,6 +19,7 @@ my $build = Module::Build->new(
'Moo' => '0.091009', 'Moo' => '0.091009',
'perl' => '5.10.0', 'perl' => '5.10.0',
'Scalar::Util' => '0', 'Scalar::Util' => '0',
'Storable' => '0',
'Time::HiRes' => '0', 'Time::HiRes' => '0',
}, },
build_requires => { build_requires => {

View File

@ -692,6 +692,12 @@ sub make_model {
my $model = Slic3r::Model->new; my $model = Slic3r::Model->new;
foreach my $plater_object (@{$self->{objects}}) { foreach my $plater_object (@{$self->{objects}}) {
my $model_object = $plater_object->get_model_object; my $model_object = $plater_object->get_model_object;
# if we need to alter the mesh, clone it first
if ($plater_object->scale != 1) {
$model_object = $model_object->clone;
}
my $new_model_object = $model->add_object( my $new_model_object = $model->add_object(
vertices => $model_object->vertices, vertices => $model_object->vertices,
input_file => $plater_object->input_file, input_file => $plater_object->input_file,
@ -1091,7 +1097,7 @@ sub free_model_object {
my $self = shift; my $self = shift;
# only delete mesh from memory if we can retrieve it from the original file # only delete mesh from memory if we can retrieve it from the original file
return unless $self->input_file && $self->input_file_object_id; return unless $self->input_file && defined $self->input_file_object_id;
$self->model_object(undef); $self->model_object(undef);
} }

View File

@ -75,6 +75,7 @@ use Moo;
use List::Util qw(first); use List::Util qw(first);
use Slic3r::Geometry qw(X Y Z); use Slic3r::Geometry qw(X Y Z);
use Storable qw(dclone);
has 'input_file' => (is => 'rw'); has 'input_file' => (is => 'rw');
has 'model' => (is => 'ro', weak_ref => 1, required => 1); has 'model' => (is => 'ro', weak_ref => 1, required => 1);
@ -145,6 +146,8 @@ sub check_manifoldness {
return (first { !$_->mesh->check_manifoldness } @{$self->volumes}) ? 0 : 1; return (first { !$_->mesh->check_manifoldness } @{$self->volumes}) ? 0 : 1;
} }
sub clone { dclone($_[0]) }
package Slic3r::Model::Volume; package Slic3r::Model::Volume;
use Moo; use Moo;