PrusaSlicer-NonPlainar/xs/xsp/SurfaceCollection.xsp

79 lines
2.0 KiB
Plaintext
Raw Normal View History

2013-07-14 12:56:43 +00:00
%module{Slic3r::XS};
%{
#include <myinit.h>
#include "SurfaceCollection.hpp"
%}
%name{Slic3r::Surface::Collection} class SurfaceCollection {
~SurfaceCollection();
void clear()
%code{% THIS->surfaces.clear(); %};
int count()
%code{% RETVAL = THIS->surfaces.size(); %};
2013-11-22 01:16:10 +00:00
void simplify(double tolerance);
2013-07-14 12:56:43 +00:00
%{
SurfaceCollection*
SurfaceCollection::new(...)
CODE:
RETVAL = new SurfaceCollection;
2013-07-14 12:56:43 +00:00
// ST(0) is class name, others are surfaces
RETVAL->surfaces.resize(items-1);
for (unsigned int i = 1; i < items; i++) {
// Note: a COPY of the input is stored
RETVAL->surfaces[i-1] = *(Surface *)SvIV((SV*)SvRV( ST(i) ));
2013-07-14 12:56:43 +00:00
}
OUTPUT:
RETVAL
SV*
SurfaceCollection::arrayref()
CODE:
AV* av = newAV();
av_fill(av, THIS->surfaces.size()-1);
int i = 0;
for (Surfaces::iterator it = THIS->surfaces.begin(); it != THIS->surfaces.end(); ++it) {
av_store(av, i++, (*it).to_SV_ref());
}
RETVAL = newRV_noinc((SV*)av);
OUTPUT:
RETVAL
SV*
SurfaceCollection::filter_by_type(surface_type)
SurfaceType surface_type;
CODE:
AV* av = newAV();
for (Surfaces::iterator it = THIS->surfaces.begin(); it != THIS->surfaces.end(); ++it) {
if ((*it).surface_type == surface_type) av_push(av, (*it).to_SV_ref());
2013-07-14 12:56:43 +00:00
}
RETVAL = newRV_noinc((SV*)av);
OUTPUT:
RETVAL
void
SurfaceCollection::append(...)
CODE:
for (unsigned int i = 1; i < items; i++) {
// Note: a COPY of the input is stored
THIS->surfaces.push_back(*(Surface *)SvIV((SV*)SvRV( ST(i) )));
2013-07-14 12:56:43 +00:00
}
void
SurfaceCollection::replace(index, surface)
int index
Surface* surface
CODE:
THIS->surfaces[index] = *surface;
void
SurfaceCollection::set_surface_type(index, surface_type)
int index
SurfaceType surface_type;
CODE:
THIS->surfaces[index].surface_type = surface_type;
2013-07-14 12:56:43 +00:00
%}
};