Return Surface->expolygon by reference
This commit is contained in:
parent
828785312e
commit
bb45437526
@ -22,6 +22,11 @@ use overload
|
|||||||
'@{}' => sub { $_[0]->arrayref },
|
'@{}' => sub { $_[0]->arrayref },
|
||||||
'fallback' => 1;
|
'fallback' => 1;
|
||||||
|
|
||||||
|
package Slic3r::ExPolygon::Ref;
|
||||||
|
our @ISA = 'Slic3r::ExPolygon';
|
||||||
|
|
||||||
|
sub DESTROY {}
|
||||||
|
|
||||||
package Slic3r::Polyline;
|
package Slic3r::Polyline;
|
||||||
use overload
|
use overload
|
||||||
'@{}' => sub { $_[0]->arrayref },
|
'@{}' => sub { $_[0]->arrayref },
|
||||||
|
@ -4,7 +4,7 @@ use strict;
|
|||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
use Slic3r::XS;
|
use Slic3r::XS;
|
||||||
use Test::More tests => 12;
|
use Test::More tests => 13;
|
||||||
|
|
||||||
my $square = [ # ccw
|
my $square = [ # ccw
|
||||||
[100, 100],
|
[100, 100],
|
||||||
@ -27,7 +27,7 @@ my $surface = Slic3r::Surface->new(
|
|||||||
|
|
||||||
$surface = $surface->clone;
|
$surface = $surface->clone;
|
||||||
|
|
||||||
isa_ok $surface->expolygon, 'Slic3r::ExPolygon', 'expolygon';
|
isa_ok $surface->expolygon, 'Slic3r::ExPolygon::Ref', 'expolygon';
|
||||||
is_deeply [ @{$surface->expolygon->pp} ], [$square, $hole_in_square], 'expolygon roundtrip';
|
is_deeply [ @{$surface->expolygon->pp} ], [$square, $hole_in_square], 'expolygon roundtrip';
|
||||||
is scalar(@{$surface->polygons}), 2, 'polygons roundtrip';
|
is scalar(@{$surface->polygons}), 2, 'polygons roundtrip';
|
||||||
|
|
||||||
@ -41,6 +41,12 @@ is $surface->bridge_angle, 30, 'bridge_angle';
|
|||||||
$surface->extra_perimeters(2);
|
$surface->extra_perimeters(2);
|
||||||
is $surface->extra_perimeters, 2, 'extra_perimeters';
|
is $surface->extra_perimeters, 2, 'extra_perimeters';
|
||||||
|
|
||||||
|
{
|
||||||
|
my $surface2 = $surface->clone;
|
||||||
|
$surface2->expolygon->scale(2);
|
||||||
|
isnt $surface2->expolygon->area, $expolygon->area, 'expolygon is returned by reference';
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
my $collection = Slic3r::Surface::Collection->new($surface, $surface->clone);
|
my $collection = Slic3r::Surface::Collection->new($surface, $surface->clone);
|
||||||
is scalar(@$collection), 2, 'collection has the right number of items';
|
is scalar(@$collection), 2, 'collection has the right number of items';
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
%name{Slic3r::Surface} class Surface {
|
%name{Slic3r::Surface} class Surface {
|
||||||
~Surface();
|
~Surface();
|
||||||
ExPolygon* expolygon()
|
ExPolygon* expolygon()
|
||||||
%code{% const char* CLASS = "Slic3r::ExPolygon"; RETVAL = new ExPolygon(THIS->expolygon); %};
|
%code{% const char* CLASS = "Slic3r::ExPolygon::Ref"; RETVAL = &(THIS->expolygon); %};
|
||||||
double thickness()
|
double thickness()
|
||||||
%code{% RETVAL = THIS->thickness; %};
|
%code{% RETVAL = THIS->thickness; %};
|
||||||
unsigned short thickness_layers()
|
unsigned short thickness_layers()
|
||||||
|
Loading…
Reference in New Issue
Block a user