PrusaSlicer-NonPlainar/xs/xsp/ExPolygonCollection.xsp
2013-07-18 19:09:07 +02:00

74 lines
2.1 KiB
Plaintext

%module{Slic3r::XS};
%{
#include <myinit.h>
#include "ExPolygonCollection.hpp"
%}
%name{Slic3r::ExPolygon::Collection} class ExPolygonCollection {
~ExPolygonCollection();
ExPolygonCollection* clone()
%code{% const char* CLASS = "Slic3r::ExPolygon::Collection"; RETVAL = new ExPolygonCollection(*THIS); %};
void clear()
%code{% THIS->expolygons.clear(); %};
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++) {
// Note: a COPY of the input is stored
RETVAL->expolygons[i-1] = new ExPolygon;
RETVAL->expolygons[i-1]->from_SV_check(ST(i));
RETVAL->expolygons[i-1]->in_collection = true;
}
OUTPUT:
RETVAL
SV*
ExPolygonCollection::arrayref()
CODE:
AV* av = newAV();
av_fill(av, THIS->expolygons.size()-1);
int i = 0;
for (ExPolygonsPtr::iterator it = THIS->expolygons.begin(); it != THIS->expolygons.end(); ++it) {
SV* sv = newSV(0);
sv_setref_pv( sv, "Slic3r::ExPolygon", *it );
av_store(av, i++, sv);
}
RETVAL = newRV_noinc((SV*)av);
OUTPUT:
RETVAL
SV*
ExPolygonCollection::pp()
CODE:
AV* av = newAV();
av_fill(av, THIS->expolygons.size()-1);
int i = 0;
for (ExPolygonsPtr::iterator it = THIS->expolygons.begin(); it != THIS->expolygons.end(); ++it) {
av_store(av, i++, (*it)->to_SV_pureperl());
}
RETVAL = newRV_noinc((SV*)av);
OUTPUT:
RETVAL
void
ExPolygonCollection::append(...)
CODE:
for (unsigned int i = 1; i < items; i++) {
ExPolygon* expolygon = new ExPolygon;
expolygon->from_SV_check( ST(i) );
expolygon->in_collection = true;
THIS->expolygons.push_back(expolygon);
}
%}
};