diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 7155f21ee..9c6a900da 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -419,9 +419,7 @@ sub rotate { # rotate, realign to 0,0 and update size $object->mesh->rotate($angle); $object->mesh->align_to_origin; - my @size = $object->mesh->size; - $object->x_length($size[X]); - $object->y_length($size[Y]); + $object->size([ $object->mesh->size ]); $self->make_thumbnail($obj_idx); $self->recenter; @@ -458,9 +456,7 @@ sub changescale { my $mesh = $object->mesh; $mesh->scale($scale/100 / $self->{scale}[$obj_idx]); $object->mesh->align_to_origin; - my @size = $object->mesh->size; - $object->x_length($size[X]); - $object->y_length($size[Y]); + $object->size([ $object->mesh->size ]); $self->{scale}[$obj_idx] = $scale/100; $self->{list}->SetItem($obj_idx, 2, "$scale%"); diff --git a/lib/Slic3r/Print.pm b/lib/Slic3r/Print.pm index 487a5c312..f015416de 100644 --- a/lib/Slic3r/Print.pm +++ b/lib/Slic3r/Print.pm @@ -112,11 +112,9 @@ sub add_object_from_mesh { $mesh->align_to_origin; # initialize print object - my @size = $mesh->size; my $object = Slic3r::Print::Object->new( - mesh => $mesh, - x_length => $size[X], - y_length => $size[Y], + mesh => $mesh, + size => [ $mesh->size ], ); push @{$self->objects}, $object; @@ -201,8 +199,8 @@ sub duplicate { for my $x_copy (1..$Slic3r::Config->duplicate_grid->[X]) { for my $y_copy (1..$Slic3r::Config->duplicate_grid->[Y]) { push @{$self->copies->[0]}, [ - ($object->x_length + $dist) * ($x_copy-1), - ($object->y_length + $dist) * ($y_copy-1), + ($object->size->[X] + $dist) * ($x_copy-1), + ($object->size->[Y] + $dist) * ($y_copy-1), ]; } } @@ -220,8 +218,8 @@ sub arrange_objects { my $total_parts = scalar map @$_, @{$self->copies}; my $partx = my $party = 0; foreach my $object (@{$self->objects}) { - $partx = $object->x_length if $object->x_length > $partx; - $party = $object->y_length if $object->y_length > $party; + $partx = $object->size->[X] if $object->size->[X] > $partx; + $party = $object->size->[Y] if $object->size->[Y] > $party; } # object distance is max(duplicate_distance, clearance_radius) @@ -246,9 +244,9 @@ sub bounding_box { foreach my $copy (@{$self->copies->[$obj_idx]}) { push @points, [ $copy->[X], $copy->[Y] ], - [ $copy->[X] + $object->x_length, $copy->[Y] ], - [ $copy->[X] + $object->x_length, $copy->[Y] + $object->y_length ], - [ $copy->[X], $copy->[Y] + $object->y_length ]; + [ $copy->[X] + $object->size->[X], $copy->[Y] ], + [ $copy->[X] + $object->size->[X], $copy->[Y] + $object->size->[Y] ], + [ $copy->[X], $copy->[Y] + $object->size->[Y] ]; } } return Slic3r::Geometry::bounding_box(\@points); diff --git a/lib/Slic3r/Print/Object.pm b/lib/Slic3r/Print/Object.pm index c06358b83..696d72ca3 100644 --- a/lib/Slic3r/Print/Object.pm +++ b/lib/Slic3r/Print/Object.pm @@ -8,8 +8,7 @@ use Slic3r::Surface ':types'; has 'input_file' => (is => 'rw', required => 0); has 'mesh' => (is => 'rw', required => 0); -has 'x_length' => (is => 'rw', required => 1); -has 'y_length' => (is => 'rw', required => 1); +has 'size' => (is => 'rw', required => 1); has 'layers' => ( traits => ['Array'], diff --git a/t/fill.t b/t/fill.t index 0e725698a..2a7ef1f93 100644 --- a/t/fill.t +++ b/t/fill.t @@ -16,11 +16,7 @@ use Slic3r::Surface qw(:types); sub scale_points (@) { map [scale $_->[X], scale $_->[Y]], @_ } { - my $print = Slic3r::Print->new( - x_length => 50, - y_length => 50, - ); - my $filler = Slic3r::Fill::Rectilinear->new(print => $print); + my $filler = Slic3r::Fill::Rectilinear->new(print => Slic3r::Print->new); my $surface_width = 250; my $distance = $filler->adjust_solid_spacing( width => $surface_width, @@ -31,12 +27,8 @@ sub scale_points (@) { map [scale $_->[X], scale $_->[Y]], @_ } } { - my $print = Slic3r::Print->new( - x_length => scale 100, - y_length => scale 100, - ); my $filler = Slic3r::Fill::Rectilinear->new( - print => $print, + print => Slic3r::Print->new, max_print_dimension => scale 100, ); my $surface = Slic3r::Surface->new(