2013-07-18 17:09:07 +00:00
|
|
|
%module{Slic3r::XS};
|
|
|
|
|
|
|
|
%{
|
|
|
|
#include <myinit.h>
|
2014-08-03 17:42:29 +00:00
|
|
|
#include "libslic3r/ExtrusionEntityCollection.hpp"
|
2013-07-18 17:09:07 +00:00
|
|
|
%}
|
|
|
|
|
|
|
|
%name{Slic3r::ExtrusionPath::Collection} class ExtrusionEntityCollection {
|
2014-12-16 23:52:01 +00:00
|
|
|
%name{_new} ExtrusionEntityCollection();
|
2013-09-16 08:33:30 +00:00
|
|
|
void reverse();
|
2013-07-18 17:09:07 +00:00
|
|
|
void clear()
|
|
|
|
%code{% THIS->entities.clear(); %};
|
2013-08-29 09:47:59 +00:00
|
|
|
ExtrusionEntityCollection* chained_path(bool no_reverse)
|
2014-04-24 14:40:10 +00:00
|
|
|
%code{%
|
|
|
|
RETVAL = new ExtrusionEntityCollection();
|
|
|
|
THIS->chained_path(RETVAL, no_reverse);
|
|
|
|
%};
|
2013-08-29 09:47:59 +00:00
|
|
|
ExtrusionEntityCollection* chained_path_from(Point* start_near, bool no_reverse)
|
2014-04-24 14:40:10 +00:00
|
|
|
%code{%
|
|
|
|
RETVAL = new ExtrusionEntityCollection();
|
|
|
|
THIS->chained_path_from(*start_near, RETVAL, no_reverse);
|
|
|
|
%};
|
2014-04-27 17:18:53 +00:00
|
|
|
Clone<Point> first_point();
|
|
|
|
Clone<Point> last_point();
|
2013-09-17 21:38:23 +00:00
|
|
|
int count()
|
|
|
|
%code{% RETVAL = THIS->entities.size(); %};
|
2015-01-14 21:55:11 +00:00
|
|
|
bool empty()
|
|
|
|
%code{% RETVAL = THIS->entities.empty(); %};
|
2014-03-15 01:16:04 +00:00
|
|
|
std::vector<size_t> orig_indices()
|
2014-03-09 19:19:30 +00:00
|
|
|
%code{% RETVAL = THIS->orig_indices; %};
|
2015-01-15 19:06:30 +00:00
|
|
|
Polygons grow();
|
2013-07-18 17:09:07 +00:00
|
|
|
%{
|
|
|
|
|
2013-08-30 22:37:17 +00:00
|
|
|
void
|
|
|
|
ExtrusionEntityCollection::DESTROY()
|
|
|
|
CODE:
|
|
|
|
for (ExtrusionEntitiesPtr::iterator it = THIS->entities.begin(); it != THIS->entities.end(); ++it) {
|
|
|
|
delete *it;
|
|
|
|
}
|
|
|
|
delete THIS;
|
|
|
|
|
2013-07-18 17:09:07 +00:00
|
|
|
SV*
|
|
|
|
ExtrusionEntityCollection::arrayref()
|
|
|
|
CODE:
|
|
|
|
AV* av = newAV();
|
|
|
|
av_fill(av, THIS->entities.size()-1);
|
|
|
|
int i = 0;
|
|
|
|
for (ExtrusionEntitiesPtr::iterator it = THIS->entities.begin(); it != THIS->entities.end(); ++it) {
|
|
|
|
SV* sv = newSV(0);
|
2013-08-30 22:37:17 +00:00
|
|
|
// return our item by reference
|
2013-07-18 17:09:07 +00:00
|
|
|
if (ExtrusionPath* path = dynamic_cast<ExtrusionPath*>(*it)) {
|
2014-04-27 17:18:53 +00:00
|
|
|
sv_setref_pv( sv, perl_class_name_ref(path), path );
|
2013-08-30 22:37:17 +00:00
|
|
|
} else if (ExtrusionLoop* loop = dynamic_cast<ExtrusionLoop*>(*it)) {
|
2014-04-27 17:18:53 +00:00
|
|
|
sv_setref_pv( sv, perl_class_name_ref(loop), loop );
|
|
|
|
} else if (ExtrusionEntityCollection* collection = dynamic_cast<ExtrusionEntityCollection*>(*it)) {
|
|
|
|
sv_setref_pv( sv, perl_class_name_ref(collection), collection );
|
2013-07-18 20:29:12 +00:00
|
|
|
} else {
|
2014-04-27 17:18:53 +00:00
|
|
|
croak("Unexpected type in ExtrusionEntityCollection");
|
2013-07-18 17:09:07 +00:00
|
|
|
}
|
|
|
|
av_store(av, i++, sv);
|
|
|
|
}
|
|
|
|
RETVAL = newRV_noinc((SV*)av);
|
|
|
|
OUTPUT:
|
|
|
|
RETVAL
|
|
|
|
|
|
|
|
void
|
|
|
|
ExtrusionEntityCollection::append(...)
|
|
|
|
CODE:
|
|
|
|
for (unsigned int i = 1; i < items; i++) {
|
2014-04-27 17:18:53 +00:00
|
|
|
if(!sv_isobject( ST(i) ) || (SvTYPE(SvRV( ST(i) )) != SVt_PVMG)) {
|
|
|
|
croak("Argument %d is not object", i);
|
|
|
|
}
|
2013-07-18 17:09:07 +00:00
|
|
|
ExtrusionEntity* entity = (ExtrusionEntity *)SvIV((SV*)SvRV( ST(i) ));
|
|
|
|
// append COPIES
|
|
|
|
if (ExtrusionPath* path = dynamic_cast<ExtrusionPath*>(entity)) {
|
|
|
|
THIS->entities.push_back( new ExtrusionPath(*path) );
|
2013-07-18 20:29:12 +00:00
|
|
|
} else if (ExtrusionLoop* loop = dynamic_cast<ExtrusionLoop*>(entity)) {
|
|
|
|
THIS->entities.push_back( new ExtrusionLoop(*loop) );
|
2014-04-27 17:18:53 +00:00
|
|
|
} else if(ExtrusionEntityCollection* collection = dynamic_cast<ExtrusionEntityCollection*>(entity)) {
|
|
|
|
THIS->entities.push_back( collection->clone() );
|
2013-07-18 17:09:07 +00:00
|
|
|
} else {
|
2014-04-27 17:18:53 +00:00
|
|
|
croak("Argument %d is of unknown type", i);
|
2013-07-18 17:09:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ExtrusionEntityCollection::no_sort(...)
|
|
|
|
CODE:
|
|
|
|
if (items > 1) {
|
|
|
|
THIS->no_sort = SvTRUE(ST(1));
|
|
|
|
}
|
|
|
|
RETVAL = THIS->no_sort;
|
|
|
|
OUTPUT:
|
|
|
|
RETVAL
|
|
|
|
|
2014-03-15 01:16:04 +00:00
|
|
|
ExtrusionEntityCollection*
|
|
|
|
ExtrusionEntityCollection::chained_path_indices(bool no_reverse)
|
|
|
|
CODE:
|
2014-04-24 14:40:10 +00:00
|
|
|
RETVAL = new ExtrusionEntityCollection();
|
|
|
|
THIS->chained_path(RETVAL, no_reverse, &RETVAL->orig_indices);
|
2014-03-15 01:16:04 +00:00
|
|
|
OUTPUT:
|
|
|
|
RETVAL
|
|
|
|
|
2013-07-18 17:09:07 +00:00
|
|
|
%}
|
|
|
|
};
|