Refactoring: turn x_length and y_length in size
This commit is contained in:
parent
896641cb7e
commit
a1ac866b84
@ -419,9 +419,7 @@ sub rotate {
|
|||||||
# rotate, realign to 0,0 and update size
|
# rotate, realign to 0,0 and update size
|
||||||
$object->mesh->rotate($angle);
|
$object->mesh->rotate($angle);
|
||||||
$object->mesh->align_to_origin;
|
$object->mesh->align_to_origin;
|
||||||
my @size = $object->mesh->size;
|
$object->size([ $object->mesh->size ]);
|
||||||
$object->x_length($size[X]);
|
|
||||||
$object->y_length($size[Y]);
|
|
||||||
|
|
||||||
$self->make_thumbnail($obj_idx);
|
$self->make_thumbnail($obj_idx);
|
||||||
$self->recenter;
|
$self->recenter;
|
||||||
@ -458,9 +456,7 @@ sub changescale {
|
|||||||
my $mesh = $object->mesh;
|
my $mesh = $object->mesh;
|
||||||
$mesh->scale($scale/100 / $self->{scale}[$obj_idx]);
|
$mesh->scale($scale/100 / $self->{scale}[$obj_idx]);
|
||||||
$object->mesh->align_to_origin;
|
$object->mesh->align_to_origin;
|
||||||
my @size = $object->mesh->size;
|
$object->size([ $object->mesh->size ]);
|
||||||
$object->x_length($size[X]);
|
|
||||||
$object->y_length($size[Y]);
|
|
||||||
|
|
||||||
$self->{scale}[$obj_idx] = $scale/100;
|
$self->{scale}[$obj_idx] = $scale/100;
|
||||||
$self->{list}->SetItem($obj_idx, 2, "$scale%");
|
$self->{list}->SetItem($obj_idx, 2, "$scale%");
|
||||||
|
@ -112,11 +112,9 @@ sub add_object_from_mesh {
|
|||||||
$mesh->align_to_origin;
|
$mesh->align_to_origin;
|
||||||
|
|
||||||
# initialize print object
|
# initialize print object
|
||||||
my @size = $mesh->size;
|
|
||||||
my $object = Slic3r::Print::Object->new(
|
my $object = Slic3r::Print::Object->new(
|
||||||
mesh => $mesh,
|
mesh => $mesh,
|
||||||
x_length => $size[X],
|
size => [ $mesh->size ],
|
||||||
y_length => $size[Y],
|
|
||||||
);
|
);
|
||||||
|
|
||||||
push @{$self->objects}, $object;
|
push @{$self->objects}, $object;
|
||||||
@ -201,8 +199,8 @@ sub duplicate {
|
|||||||
for my $x_copy (1..$Slic3r::Config->duplicate_grid->[X]) {
|
for my $x_copy (1..$Slic3r::Config->duplicate_grid->[X]) {
|
||||||
for my $y_copy (1..$Slic3r::Config->duplicate_grid->[Y]) {
|
for my $y_copy (1..$Slic3r::Config->duplicate_grid->[Y]) {
|
||||||
push @{$self->copies->[0]}, [
|
push @{$self->copies->[0]}, [
|
||||||
($object->x_length + $dist) * ($x_copy-1),
|
($object->size->[X] + $dist) * ($x_copy-1),
|
||||||
($object->y_length + $dist) * ($y_copy-1),
|
($object->size->[Y] + $dist) * ($y_copy-1),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -220,8 +218,8 @@ sub arrange_objects {
|
|||||||
my $total_parts = scalar map @$_, @{$self->copies};
|
my $total_parts = scalar map @$_, @{$self->copies};
|
||||||
my $partx = my $party = 0;
|
my $partx = my $party = 0;
|
||||||
foreach my $object (@{$self->objects}) {
|
foreach my $object (@{$self->objects}) {
|
||||||
$partx = $object->x_length if $object->x_length > $partx;
|
$partx = $object->size->[X] if $object->size->[X] > $partx;
|
||||||
$party = $object->y_length if $object->y_length > $party;
|
$party = $object->size->[Y] if $object->size->[Y] > $party;
|
||||||
}
|
}
|
||||||
|
|
||||||
# object distance is max(duplicate_distance, clearance_radius)
|
# object distance is max(duplicate_distance, clearance_radius)
|
||||||
@ -246,9 +244,9 @@ sub bounding_box {
|
|||||||
foreach my $copy (@{$self->copies->[$obj_idx]}) {
|
foreach my $copy (@{$self->copies->[$obj_idx]}) {
|
||||||
push @points,
|
push @points,
|
||||||
[ $copy->[X], $copy->[Y] ],
|
[ $copy->[X], $copy->[Y] ],
|
||||||
[ $copy->[X] + $object->x_length, $copy->[Y] ],
|
[ $copy->[X] + $object->size->[X], $copy->[Y] ],
|
||||||
[ $copy->[X] + $object->x_length, $copy->[Y] + $object->y_length ],
|
[ $copy->[X] + $object->size->[X], $copy->[Y] + $object->size->[Y] ],
|
||||||
[ $copy->[X], $copy->[Y] + $object->y_length ];
|
[ $copy->[X], $copy->[Y] + $object->size->[Y] ];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Slic3r::Geometry::bounding_box(\@points);
|
return Slic3r::Geometry::bounding_box(\@points);
|
||||||
|
@ -8,8 +8,7 @@ use Slic3r::Surface ':types';
|
|||||||
|
|
||||||
has 'input_file' => (is => 'rw', required => 0);
|
has 'input_file' => (is => 'rw', required => 0);
|
||||||
has 'mesh' => (is => 'rw', required => 0);
|
has 'mesh' => (is => 'rw', required => 0);
|
||||||
has 'x_length' => (is => 'rw', required => 1);
|
has 'size' => (is => 'rw', required => 1);
|
||||||
has 'y_length' => (is => 'rw', required => 1);
|
|
||||||
|
|
||||||
has 'layers' => (
|
has 'layers' => (
|
||||||
traits => ['Array'],
|
traits => ['Array'],
|
||||||
|
12
t/fill.t
12
t/fill.t
@ -16,11 +16,7 @@ use Slic3r::Surface qw(:types);
|
|||||||
sub scale_points (@) { map [scale $_->[X], scale $_->[Y]], @_ }
|
sub scale_points (@) { map [scale $_->[X], scale $_->[Y]], @_ }
|
||||||
|
|
||||||
{
|
{
|
||||||
my $print = Slic3r::Print->new(
|
my $filler = Slic3r::Fill::Rectilinear->new(print => Slic3r::Print->new);
|
||||||
x_length => 50,
|
|
||||||
y_length => 50,
|
|
||||||
);
|
|
||||||
my $filler = Slic3r::Fill::Rectilinear->new(print => $print);
|
|
||||||
my $surface_width = 250;
|
my $surface_width = 250;
|
||||||
my $distance = $filler->adjust_solid_spacing(
|
my $distance = $filler->adjust_solid_spacing(
|
||||||
width => $surface_width,
|
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(
|
my $filler = Slic3r::Fill::Rectilinear->new(
|
||||||
print => $print,
|
print => Slic3r::Print->new,
|
||||||
max_print_dimension => scale 100,
|
max_print_dimension => scale 100,
|
||||||
);
|
);
|
||||||
my $surface = Slic3r::Surface->new(
|
my $surface = Slic3r::Surface->new(
|
||||||
|
Loading…
Reference in New Issue
Block a user