1%module{Slic3r::XS};
2
3%{
4#include <xsinit.h>
5#include "libslic3r/ExtrusionEntity.hpp"
6#include "libslic3r/ExtrusionEntityCollection.hpp"
7%}
8
9%name{Slic3r::ExtrusionPath} class ExtrusionPath {
10    ~ExtrusionPath();
11    SV* arrayref()
12        %code{% RETVAL = to_AV(&THIS->polyline); %};
13    SV* pp()
14        %code{% RETVAL = to_SV_pureperl(&THIS->polyline); %};
15    void pop_back()
16        %code{% THIS->polyline.points.pop_back(); %};
17    void reverse();
18    Lines lines()
19        %code{% RETVAL = THIS->polyline.lines(); %};
20    Clone<Point> first_point();
21    Clone<Point> last_point();
22    void clip_end(double distance);
23    void simplify(double tolerance);
24    double length();
25    ExtrusionRole role() const;
26    bool is_bridge()
27        %code{% RETVAL = is_bridge(THIS->role()); %};
28    Polygons polygons_covered_by_width();
29    Polygons polygons_covered_by_spacing();
30%{
31
32ExtrusionPath*
33_new(CLASS, polyline_sv, role, mm3_per_mm, width, height)
34    char*           CLASS;
35    SV*             polyline_sv;
36    ExtrusionRole   role;
37    double          mm3_per_mm;
38    float           width;
39    float           height;
40    CODE:
41        RETVAL = new ExtrusionPath (role);
42        from_SV_check(polyline_sv, &RETVAL->polyline);
43        RETVAL->mm3_per_mm      = mm3_per_mm;
44        RETVAL->width           = width;
45        RETVAL->height          = height;
46    OUTPUT:
47        RETVAL
48
49Ref<Polyline>
50ExtrusionPath::polyline(...)
51    CODE:
52        if (items > 1) {
53            from_SV_check(ST(1), &THIS->polyline);
54        }
55        RETVAL = &(THIS->polyline);
56    OUTPUT:
57        RETVAL
58
59double
60ExtrusionPath::mm3_per_mm(...)
61    CODE:
62        if (items > 1) {
63            THIS->mm3_per_mm = (double)SvNV(ST(1));
64        }
65        RETVAL = THIS->mm3_per_mm;
66    OUTPUT:
67        RETVAL
68
69float
70ExtrusionPath::width(...)
71    CODE:
72        if (items > 1) {
73            THIS->width = (float)SvNV(ST(1));
74        }
75        RETVAL = THIS->width;
76    OUTPUT:
77        RETVAL
78
79float
80ExtrusionPath::height(...)
81    CODE:
82        if (items > 1) {
83            THIS->height = (float)SvNV(ST(1));
84        }
85        RETVAL = THIS->height;
86    OUTPUT:
87        RETVAL
88
89void
90ExtrusionPath::append(...)
91    CODE:
92        for (unsigned int i = 1; i < items; i++) {
93            Point p;
94            from_SV_check(ST(i), &p);
95            THIS->polyline.points.push_back(p);
96        }
97
98ExtrusionEntityCollection*
99ExtrusionPath::intersect_expolygons(ExPolygonCollection* collection)
100    CODE:
101        RETVAL = new ExtrusionEntityCollection ();
102        THIS->intersect_expolygons(*collection, RETVAL);
103    OUTPUT:
104        RETVAL
105
106ExtrusionEntityCollection*
107ExtrusionPath::subtract_expolygons(ExPolygonCollection* collection)
108    CODE:
109        RETVAL = new ExtrusionEntityCollection ();
110        THIS->subtract_expolygons(*collection, RETVAL);
111    OUTPUT:
112        RETVAL
113
114%}
115};
116
117%package{Slic3r::ExtrusionPath};
118%{
119
120IV
121_constant()
122  ALIAS:
123    EXTR_ROLE_NONE                         = erNone
124    EXTR_ROLE_PERIMETER                    = erPerimeter
125    EXTR_ROLE_EXTERNAL_PERIMETER           = erExternalPerimeter
126    EXTR_ROLE_OVERHANG_PERIMETER           = erOverhangPerimeter
127    EXTR_ROLE_FILL                         = erInternalInfill
128    EXTR_ROLE_SOLIDFILL                    = erSolidInfill
129    EXTR_ROLE_TOPSOLIDFILL                 = erTopSolidInfill
130    EXTR_ROLE_BRIDGE                       = erBridgeInfill
131    EXTR_ROLE_GAPFILL                      = erGapFill
132    EXTR_ROLE_SKIRT                        = erSkirt
133    EXTR_ROLE_SUPPORTMATERIAL              = erSupportMaterial
134    EXTR_ROLE_SUPPORTMATERIAL_INTERFACE    = erSupportMaterialInterface
135    EXTR_ROLE_MIXED                        = erMixed
136  PROTOTYPE:
137  CODE:
138    RETVAL = ix;
139  OUTPUT: RETVAL
140
141%}
142
143