mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-08-02 19:44:00 -06:00
Add test for polyline lines
This commit is contained in:
parent
439255ca46
commit
77c479c127
3 changed files with 34 additions and 19 deletions
|
@ -110,19 +110,6 @@ Line::to_SV_pureperl() {
|
||||||
return newRV_noinc((SV*)av);
|
return newRV_noinc((SV*)av);
|
||||||
}
|
}
|
||||||
|
|
||||||
SV*
|
|
||||||
lines2perl(pTHX_ Lines& lines)
|
|
||||||
{
|
|
||||||
AV* av = newAV();
|
|
||||||
av_extend(av, lines.size()-1);
|
|
||||||
int i = 0;
|
|
||||||
for (Lines::iterator it = lines.begin(); it != lines.end(); ++it) {
|
|
||||||
SV* sv = (*it).to_SV_ref();
|
|
||||||
av_store(av, i++, sv);
|
|
||||||
}
|
|
||||||
return (SV*)newRV_noinc((SV*)av);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
27
xs/t/09_polyline.t
Normal file
27
xs/t/09_polyline.t
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
use Slic3r::XS;
|
||||||
|
use Test::More tests => 4;
|
||||||
|
|
||||||
|
my $points = [
|
||||||
|
[100, 100],
|
||||||
|
[200, 100],
|
||||||
|
[200, 200],
|
||||||
|
];
|
||||||
|
|
||||||
|
my $polyline = Slic3r::Polyline->new(@$points);
|
||||||
|
is_deeply $polyline->pp, $points, 'polyline roundtrip';
|
||||||
|
|
||||||
|
is ref($polyline->arrayref), 'ARRAY', 'polyline arrayref is unblessed';
|
||||||
|
isa_ok $polyline->[0], 'Slic3r::Point', 'polyline point is blessed';
|
||||||
|
|
||||||
|
my $lines = $polyline->lines;
|
||||||
|
is_deeply [ map $_->pp, @$lines ], [
|
||||||
|
[ [100, 100], [200, 100] ],
|
||||||
|
[ [200, 100], [200, 200] ],
|
||||||
|
], 'polyline lines';
|
||||||
|
|
||||||
|
__END__
|
|
@ -15,15 +15,16 @@ ExtrusionRole T_UV
|
||||||
SurfaceType T_UV
|
SurfaceType T_UV
|
||||||
|
|
||||||
Lines T_LINES
|
Lines T_LINES
|
||||||
Lines* T_LINES_PTR
|
|
||||||
|
|
||||||
INPUT
|
INPUT
|
||||||
|
|
||||||
OUTPUT
|
OUTPUT
|
||||||
|
|
||||||
T_LINES
|
T_LINES
|
||||||
$arg = lines2perl(aTHX_ $var);
|
AV* av = newAV();
|
||||||
|
$arg = newRV_noinc((SV*)av);
|
||||||
T_LINES_PTR
|
const unsigned int len = $var.size();
|
||||||
$arg = lines2perl(aTHX_ *$var);
|
av_extend(av, len-1);
|
||||||
delete $var;
|
for (unsigned int i = 0; i < len; i++) {
|
||||||
|
av_store(av, i, ${var}[i].to_SV_ref());
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue