mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-21 07:41:09 -06:00
Ported Slic3r::ExPolygon::Collection to XS
This commit is contained in:
parent
7f4dc4e248
commit
b1ad466189
10 changed files with 173 additions and 68 deletions
|
@ -8,6 +8,8 @@
|
|||
%name{Slic3r::ExPolygon::XS} class ExPolygon {
|
||||
%name{_clone} ExPolygon(ExPolygon& self);
|
||||
~ExPolygon();
|
||||
SV* arrayref()
|
||||
%code{% RETVAL = expolygon2perl(*THIS); %};
|
||||
void scale(double factor);
|
||||
void translate(double x, double y);
|
||||
void _rotate(double angle, Point* center);
|
||||
|
@ -26,20 +28,6 @@ ExPolygon::new(...)
|
|||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
SV*
|
||||
ExPolygon::arrayref()
|
||||
CODE:
|
||||
AV* av = newAV();
|
||||
av_fill(av, THIS->holes.size()); // -1 +1
|
||||
av_store(av, 0, polygon2perl(THIS->contour));
|
||||
int i = 0;
|
||||
for (Polygons::iterator it = THIS->holes.begin(); it != THIS->holes.end(); ++it) {
|
||||
av_store(av, ++i, polygon2perl(*it));
|
||||
}
|
||||
RETVAL = sv_bless(newRV_noinc((SV*)av), gv_stashpv("Slic3r::ExPolygon", GV_ADD));
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
%}
|
||||
};
|
||||
|
||||
|
|
48
xs/xsp/ExPolygonCollection.xsp
Normal file
48
xs/xsp/ExPolygonCollection.xsp
Normal file
|
@ -0,0 +1,48 @@
|
|||
%module{Slic3r::XS};
|
||||
|
||||
%{
|
||||
#include <myinit.h>
|
||||
#include "ExPolygonCollection.hpp"
|
||||
%}
|
||||
|
||||
%name{Slic3r::ExPolygon::Collection} class ExPolygonCollection {
|
||||
%name{_clone} ExPolygonCollection(ExPolygonCollection& self);
|
||||
~ExPolygonCollection();
|
||||
void scale(double factor);
|
||||
void translate(double x, double y);
|
||||
void rotate(double angle, Point* center);
|
||||
%{
|
||||
|
||||
ExPolygonCollection*
|
||||
ExPolygonCollection::new(...)
|
||||
CODE:
|
||||
RETVAL = new ExPolygonCollection ();
|
||||
// ST(0) is class name, others are expolygons
|
||||
RETVAL->expolygons.resize(items-1);
|
||||
for (unsigned int i = 1; i < items; i++) {
|
||||
if (sv_isobject(ST(i)) && (SvTYPE(SvRV(ST(i))) == SVt_PVMG)) {
|
||||
// a XS ExPolygon was supplied
|
||||
RETVAL->expolygons[i-1] = *(ExPolygon *)SvIV((SV*)SvRV( ST(i) ));
|
||||
} else {
|
||||
// a Perl arrayref was supplied
|
||||
perl2expolygon(ST(i), RETVAL->expolygons[i-1]);
|
||||
}
|
||||
}
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
SV*
|
||||
ExPolygonCollection::arrayref()
|
||||
CODE:
|
||||
AV* av = newAV();
|
||||
av_fill(av, THIS->expolygons.size()-1);
|
||||
int i = 0;
|
||||
for (ExPolygons::iterator it = THIS->expolygons.begin(); it != THIS->expolygons.end(); ++it) {
|
||||
av_store(av, i++, expolygon2perl(*it));
|
||||
}
|
||||
RETVAL = newRV_noinc((SV*)av);
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
%}
|
||||
};
|
|
@ -2,3 +2,4 @@ ZTable* O_OBJECT
|
|||
TriangleMesh* O_OBJECT
|
||||
Point* O_OBJECT
|
||||
ExPolygon* O_OBJECT
|
||||
ExPolygonCollection* O_OBJECT
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue