mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-08-02 11:33:59 -06:00
Polyline->lines
This commit is contained in:
parent
ab6b3d41a7
commit
439255ca46
5 changed files with 39 additions and 1 deletions
|
@ -23,6 +23,7 @@ class Line
|
||||||
void from_SV(SV* line_sv);
|
void from_SV(SV* line_sv);
|
||||||
void from_SV_check(SV* line_sv);
|
void from_SV_check(SV* line_sv);
|
||||||
SV* to_SV();
|
SV* to_SV();
|
||||||
|
SV* to_SV_ref();
|
||||||
SV* to_SV_pureperl();
|
SV* to_SV_pureperl();
|
||||||
void scale(double factor);
|
void scale(double factor);
|
||||||
void translate(double x, double y);
|
void translate(double x, double y);
|
||||||
|
@ -93,6 +94,13 @@ Line::to_SV() {
|
||||||
return newRV_noinc((SV*)av);
|
return newRV_noinc((SV*)av);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SV*
|
||||||
|
Line::to_SV_ref() {
|
||||||
|
SV* sv = newSV(0);
|
||||||
|
sv_setref_pv( sv, "Slic3r::Line", new Line(*this) );
|
||||||
|
return sv;
|
||||||
|
}
|
||||||
|
|
||||||
SV*
|
SV*
|
||||||
Line::to_SV_pureperl() {
|
Line::to_SV_pureperl() {
|
||||||
AV* av = newAV();
|
AV* av = newAV();
|
||||||
|
@ -102,6 +110,19 @@ 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
|
||||||
|
|
|
@ -14,7 +14,7 @@ my $square = [ # ccw
|
||||||
];
|
];
|
||||||
|
|
||||||
my $polygon = Slic3r::Polygon->new(@$square);
|
my $polygon = Slic3r::Polygon->new(@$square);
|
||||||
is_deeply [ @{$polygon->pp} ], [ @$square ], 'polygon roundtrip';
|
is_deeply $polygon->pp, $square, 'polygon roundtrip';
|
||||||
|
|
||||||
is ref($polygon->arrayref), 'ARRAY', 'polygon arrayref is unblessed';
|
is ref($polygon->arrayref), 'ARRAY', 'polygon arrayref is unblessed';
|
||||||
isa_ok $polygon->[0], 'Slic3r::Point', 'polygon point is blessed';
|
isa_ok $polygon->[0], 'Slic3r::Point', 'polygon point is blessed';
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
void pop_back()
|
void pop_back()
|
||||||
%code{% THIS->points.pop_back(); %};
|
%code{% THIS->points.pop_back(); %};
|
||||||
void reverse();
|
void reverse();
|
||||||
|
Lines lines();
|
||||||
%{
|
%{
|
||||||
|
|
||||||
Polyline*
|
Polyline*
|
||||||
|
|
|
@ -13,3 +13,17 @@ SurfaceCollection* O_OBJECT
|
||||||
|
|
||||||
ExtrusionRole T_UV
|
ExtrusionRole T_UV
|
||||||
SurfaceType T_UV
|
SurfaceType T_UV
|
||||||
|
|
||||||
|
Lines T_LINES
|
||||||
|
Lines* T_LINES_PTR
|
||||||
|
|
||||||
|
INPUT
|
||||||
|
|
||||||
|
OUTPUT
|
||||||
|
|
||||||
|
T_LINES
|
||||||
|
$arg = lines2perl(aTHX_ $var);
|
||||||
|
|
||||||
|
T_LINES_PTR
|
||||||
|
$arg = lines2perl(aTHX_ *$var);
|
||||||
|
delete $var;
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
%typemap{ExPolygon*};
|
%typemap{ExPolygon*};
|
||||||
%typemap{Polyline*};
|
%typemap{Polyline*};
|
||||||
%typemap{Polygon*};
|
%typemap{Polygon*};
|
||||||
|
%typemap{Lines};
|
||||||
|
|
||||||
%typemap{SurfaceType}{parsed}{
|
%typemap{SurfaceType}{parsed}{
|
||||||
%cpp_type{SurfaceType};
|
%cpp_type{SurfaceType};
|
||||||
%precall_code{%
|
%precall_code{%
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue