Ported ExtrusionPath to XS. Failing test for Surface
This commit is contained in:
parent
8c1e1cc3ea
commit
f612d4c64e
24 changed files with 501 additions and 143 deletions
126
xs/xsp/ExtrusionPath.xsp
Normal file
126
xs/xsp/ExtrusionPath.xsp
Normal file
|
@ -0,0 +1,126 @@
|
|||
%module{Slic3r::XS};
|
||||
|
||||
%{
|
||||
#include <myinit.h>
|
||||
#include "ExtrusionEntity.hpp"
|
||||
%}
|
||||
|
||||
%name{Slic3r::ExtrusionPath} class ExtrusionPath {
|
||||
~ExtrusionPath();
|
||||
SV* arrayref()
|
||||
%code{% RETVAL = polyline2perl(THIS->polyline); %};
|
||||
void pop_back()
|
||||
%code{% THIS->polyline.points.pop_back(); %};
|
||||
void reverse();
|
||||
%{
|
||||
|
||||
ExtrusionPath*
|
||||
_new(CLASS, polyline_sv, role, height, flow_spacing)
|
||||
char* CLASS;
|
||||
SV* polyline_sv;
|
||||
ExtrusionRole role;
|
||||
double height;
|
||||
double flow_spacing;
|
||||
CODE:
|
||||
RETVAL = new ExtrusionPath ();
|
||||
if (sv_isobject(polyline_sv) && (SvTYPE(SvRV(polyline_sv)) == SVt_PVMG)) {
|
||||
RETVAL->polyline = *(Polyline*)SvIV((SV*)SvRV( polyline_sv ));
|
||||
} else {
|
||||
perl2polyline(polyline_sv, RETVAL->polyline);
|
||||
}
|
||||
RETVAL->role = role;
|
||||
RETVAL->height = height;
|
||||
RETVAL->flow_spacing = flow_spacing;
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
Polyline*
|
||||
ExtrusionPath::as_polyline()
|
||||
PREINIT:
|
||||
const char* CLASS = "Slic3r::Polyline::XS";
|
||||
CODE:
|
||||
RETVAL = new Polyline(THIS->polyline);
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
void
|
||||
ExtrusionPath::set_polyline(polyline_sv)
|
||||
SV* polyline_sv;
|
||||
CODE:
|
||||
if (sv_isobject(polyline_sv) && (SvTYPE(SvRV(polyline_sv)) == SVt_PVMG)) {
|
||||
THIS->polyline = *(Polyline*)SvIV((SV*)SvRV( polyline_sv ));
|
||||
} else {
|
||||
perl2polyline(polyline_sv, THIS->polyline);
|
||||
}
|
||||
|
||||
ExtrusionRole
|
||||
ExtrusionPath::role(...)
|
||||
CODE:
|
||||
if (items > 1) {
|
||||
THIS->role = (ExtrusionRole)SvUV(ST(1));
|
||||
}
|
||||
RETVAL = THIS->role;
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
double
|
||||
ExtrusionPath::height(...)
|
||||
CODE:
|
||||
if (items > 1) {
|
||||
THIS->height = (double)SvNV(ST(1));
|
||||
}
|
||||
RETVAL = THIS->height;
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
double
|
||||
ExtrusionPath::flow_spacing(...)
|
||||
CODE:
|
||||
if (items > 1) {
|
||||
THIS->flow_spacing = (double)SvNV(ST(1));
|
||||
}
|
||||
RETVAL = THIS->flow_spacing;
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
void
|
||||
ExtrusionPath::append(...)
|
||||
CODE:
|
||||
for (unsigned int i = 1; i < items; i++) {
|
||||
Point p;
|
||||
if (sv_isobject(ST(i)) && (SvTYPE(SvRV(ST(i))) == SVt_PVMG)) {
|
||||
p = *(Point*)SvIV((SV*)SvRV( ST(i) ));
|
||||
} else {
|
||||
perl2point(ST(i), p);
|
||||
}
|
||||
THIS->polyline.points.push_back(p);
|
||||
}
|
||||
|
||||
%}
|
||||
};
|
||||
|
||||
%package{Slic3r::ExtrusionPath};
|
||||
%{
|
||||
|
||||
IV
|
||||
_constant()
|
||||
ALIAS:
|
||||
EXTR_ROLE_PERIMETER = erPerimeter
|
||||
EXTR_ROLE_EXTERNAL_PERIMETER = erExternalPerimeter
|
||||
EXTR_ROLE_OVERHANG_PERIMETER = erOverhangPerimeter
|
||||
EXTR_ROLE_CONTOUR_INTERNAL_PERIMETER = erContourInternalPerimeter
|
||||
EXTR_ROLE_FILL = erFill
|
||||
EXTR_ROLE_SOLIDFILL = erSolidFill
|
||||
EXTR_ROLE_TOPSOLIDFILL = erTopSolidFill
|
||||
EXTR_ROLE_BRIDGE = erBrige
|
||||
EXTR_ROLE_INTERNALBRIDGE = erInternalBridge
|
||||
EXTR_ROLE_SKIRT = erSkirt
|
||||
EXTR_ROLE_SUPPORTMATERIAL = erSupportMaterial
|
||||
EXTR_ROLE_GAPFILL = erGapFill
|
||||
PROTOTYPE:
|
||||
CODE:
|
||||
RETVAL = ix;
|
||||
OUTPUT: RETVAL
|
||||
|
||||
%}
|
||||
|
29
xs/xsp/Polygon.xsp
Normal file
29
xs/xsp/Polygon.xsp
Normal file
|
@ -0,0 +1,29 @@
|
|||
%module{Slic3r::XS};
|
||||
|
||||
%{
|
||||
#include <myinit.h>
|
||||
#include "Polygon.hpp"
|
||||
%}
|
||||
|
||||
%name{Slic3r::Polygon::XS} class Polygon {
|
||||
~Polygon();
|
||||
Polygon* clone()
|
||||
%code{% const char* CLASS = "Slic3r::Polygon::XS"; RETVAL = new Polygon(*THIS); %};
|
||||
SV* arrayref()
|
||||
%code{% RETVAL = polygon2perl(*THIS); %};
|
||||
%{
|
||||
|
||||
Polygon*
|
||||
Polygon::new(...)
|
||||
CODE:
|
||||
RETVAL = new Polygon ();
|
||||
// ST(0) is class name, ST(1) is first point
|
||||
RETVAL->points.resize(items-1);
|
||||
for (unsigned int i = 1; i < items; i++) {
|
||||
perl2point(ST(i), RETVAL->points[i-1]);
|
||||
}
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
%}
|
||||
};
|
45
xs/xsp/Polyline.xsp
Normal file
45
xs/xsp/Polyline.xsp
Normal file
|
@ -0,0 +1,45 @@
|
|||
%module{Slic3r::XS};
|
||||
|
||||
%{
|
||||
#include <myinit.h>
|
||||
#include "Polyline.hpp"
|
||||
%}
|
||||
|
||||
%name{Slic3r::Polyline::XS} class Polyline {
|
||||
~Polyline();
|
||||
Polyline* clone()
|
||||
%code{% const char* CLASS = "Slic3r::Polyline::XS"; RETVAL = new Polyline(*THIS); %};
|
||||
SV* arrayref()
|
||||
%code{% RETVAL = polyline2perl(*THIS); %};
|
||||
void pop_back()
|
||||
%code{% THIS->points.pop_back(); %};
|
||||
void reverse();
|
||||
%{
|
||||
|
||||
Polyline*
|
||||
Polyline::new(...)
|
||||
CODE:
|
||||
RETVAL = new Polyline ();
|
||||
// ST(0) is class name, ST(1) is first point
|
||||
RETVAL->points.resize(items-1);
|
||||
for (unsigned int i = 1; i < items; i++) {
|
||||
perl2point(ST(i), RETVAL->points[i-1]);
|
||||
}
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
void
|
||||
Polyline::append(...)
|
||||
CODE:
|
||||
for (unsigned int i = 1; i < items; i++) {
|
||||
Point p;
|
||||
if (sv_isobject(ST(i)) && (SvTYPE(SvRV(ST(i))) == SVt_PVMG)) {
|
||||
p = *(Point*)SvIV((SV*)SvRV( ST(i) ));
|
||||
} else {
|
||||
perl2point(ST(i), p);
|
||||
}
|
||||
THIS->points.push_back(p);
|
||||
}
|
||||
|
||||
%}
|
||||
};
|
|
@ -1,8 +1,14 @@
|
|||
ZTable* O_OBJECT
|
||||
TriangleMesh* O_OBJECT
|
||||
Point* O_OBJECT
|
||||
Polyline* O_OBJECT
|
||||
Polygon* O_OBJECT
|
||||
ExPolygon* O_OBJECT
|
||||
ExPolygonCollection* O_OBJECT
|
||||
SurfaceType T_UV
|
||||
ExtrusionPath* O_OBJECT
|
||||
ExtrusionLoop* O_OBJECT
|
||||
Surface* O_OBJECT
|
||||
SurfaceCollection* O_OBJECT
|
||||
|
||||
ExtrusionRole T_UV
|
||||
SurfaceType T_UV
|
||||
|
|
|
@ -4,9 +4,17 @@
|
|||
%typemap{AV*};
|
||||
%typemap{Point*};
|
||||
%typemap{ExPolygon*};
|
||||
%typemap{Polyline*};
|
||||
%typemap{Polygon*};
|
||||
%typemap{SurfaceType}{parsed}{
|
||||
%cpp_type{SurfaceType};
|
||||
%precall_code{%
|
||||
$CVar = (SurfaceType)SvUV($PerlVar);
|
||||
%};
|
||||
};
|
||||
};
|
||||
%typemap{ExtrusionRole}{parsed}{
|
||||
%cpp_type{ExtrusionRole};
|
||||
%precall_code{%
|
||||
$CVar = (ExtrusionRole)SvUV($PerlVar);
|
||||
%};
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue