2013-07-14 12:56:43 +00:00
|
|
|
%module{Slic3r::XS};
|
|
|
|
|
|
|
|
%{
|
|
|
|
#include <myinit.h>
|
2014-08-03 17:42:29 +00:00
|
|
|
#include "libslic3r/SurfaceCollection.hpp"
|
2013-07-14 12:56:43 +00:00
|
|
|
%}
|
|
|
|
|
|
|
|
%name{Slic3r::Surface::Collection} class SurfaceCollection {
|
2014-11-09 15:23:50 +00:00
|
|
|
%name{_new} SurfaceCollection();
|
2013-07-14 12:56:43 +00:00
|
|
|
~SurfaceCollection();
|
|
|
|
void clear()
|
|
|
|
%code{% THIS->surfaces.clear(); %};
|
2014-11-09 15:23:50 +00:00
|
|
|
void append(Surface* surface)
|
|
|
|
%code{% THIS->surfaces.push_back(*surface); %};
|
2013-09-17 21:38:23 +00:00
|
|
|
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
|
|
|
%{
|
|
|
|
|
|
|
|
SV*
|
|
|
|
SurfaceCollection::arrayref()
|
|
|
|
CODE:
|
|
|
|
AV* av = newAV();
|
|
|
|
av_fill(av, THIS->surfaces.size()-1);
|
|
|
|
int i = 0;
|
2013-08-08 00:10:34 +00:00
|
|
|
for (Surfaces::iterator it = THIS->surfaces.begin(); it != THIS->surfaces.end(); ++it) {
|
2014-05-08 12:52:48 +00:00
|
|
|
av_store(av, i++, perl_to_SV_ref(*it));
|
2013-09-06 16:36:38 +00:00
|
|
|
}
|
|
|
|
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) {
|
2014-05-08 12:52:48 +00:00
|
|
|
if ((*it).surface_type == surface_type) av_push(av, perl_to_SV_ref(*it));
|
2013-07-14 12:56:43 +00:00
|
|
|
}
|
|
|
|
RETVAL = newRV_noinc((SV*)av);
|
|
|
|
OUTPUT:
|
|
|
|
RETVAL
|
|
|
|
|
2013-08-08 00:10:34 +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-11-23 17:15:59 +00:00
|
|
|
SV*
|
2014-02-10 12:19:44 +00:00
|
|
|
SurfaceCollection::group()
|
2013-11-23 17:15:59 +00:00
|
|
|
CODE:
|
|
|
|
// perform grouping
|
|
|
|
std::vector<SurfacesPtr> groups;
|
2014-02-10 12:19:44 +00:00
|
|
|
THIS->group(&groups);
|
2013-11-23 17:15:59 +00:00
|
|
|
|
|
|
|
// build return arrayref
|
|
|
|
AV* av = newAV();
|
|
|
|
av_fill(av, groups.size()-1);
|
|
|
|
size_t i = 0;
|
|
|
|
for (std::vector<SurfacesPtr>::iterator it = groups.begin(); it != groups.end(); ++it) {
|
|
|
|
AV* innerav = newAV();
|
|
|
|
av_fill(innerav, it->size()-1);
|
|
|
|
size_t j = 0;
|
|
|
|
for (SurfacesPtr::iterator it_s = it->begin(); it_s != it->end(); ++it_s) {
|
2014-05-08 12:52:48 +00:00
|
|
|
av_store(innerav, j++, perl_to_SV_clone_ref(**it_s));
|
2013-11-23 17:15:59 +00:00
|
|
|
}
|
|
|
|
av_store(av, i++, newRV_noinc((SV*)innerav));
|
|
|
|
}
|
|
|
|
RETVAL = newRV_noinc((SV*)av);
|
|
|
|
OUTPUT:
|
|
|
|
RETVAL
|
|
|
|
|
2013-07-14 12:56:43 +00:00
|
|
|
%}
|
|
|
|
};
|