forked from prusa3d/PrusaSlicer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSurface.xsp
118 lines (105 loc) · 2.98 KB
/
Surface.xsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
%module{Slic3r::XS};
%{
#include <xsinit.h>
#include "libslic3r/Surface.hpp"
#include "libslic3r/ClipperUtils.hpp"
%}
%name{Slic3r::Surface} class Surface {
~Surface();
Ref<ExPolygon> expolygon()
%code{% RETVAL = &(THIS->expolygon); %};
double thickness()
%code{% RETVAL = THIS->thickness; %};
unsigned short thickness_layers()
%code{% RETVAL = THIS->thickness_layers; %};
double area();
bool is_solid() const;
bool is_external() const;
bool is_internal() const;
bool is_bottom() const;
bool is_bridge() const;
%{
Surface*
_new(CLASS, expolygon, surface_type, thickness, thickness_layers, bridge_angle, extra_perimeters)
char* CLASS;
ExPolygon* expolygon;
SurfaceType surface_type;
double thickness;
unsigned short thickness_layers;
double bridge_angle;
unsigned short extra_perimeters;
CODE:
RETVAL = new Surface (surface_type, *expolygon);
RETVAL->thickness = thickness;
RETVAL->thickness_layers = thickness_layers;
RETVAL->bridge_angle = bridge_angle;
RETVAL->extra_perimeters = extra_perimeters;
// we don't delete expolygon here because it's referenced by a Perl SV
// whose DESTROY will take care of destruction
OUTPUT:
RETVAL
SurfaceType
Surface::surface_type(...)
CODE:
if (items > 1) {
THIS->surface_type = (SurfaceType)SvUV(ST(1));
}
RETVAL = THIS->surface_type;
OUTPUT:
RETVAL
double
Surface::bridge_angle(...)
CODE:
if (items > 1) {
THIS->bridge_angle = (double)SvNV(ST(1));
}
RETVAL = THIS->bridge_angle;
OUTPUT:
RETVAL
unsigned short
Surface::extra_perimeters(...)
CODE:
if (items > 1) {
THIS->extra_perimeters = (double)SvUV(ST(1));
}
RETVAL = THIS->extra_perimeters;
OUTPUT:
RETVAL
Polygons
Surface::polygons()
CODE:
RETVAL.push_back(THIS->expolygon.contour);
for (Polygons::iterator it = THIS->expolygon.holes.begin(); it != THIS->expolygon.holes.end(); ++it) {
RETVAL.push_back((*it));
}
OUTPUT:
RETVAL
Surfaces
Surface::offset(delta, joinType = ClipperLib::jtMiter, miterLimit = 3)
const float delta
ClipperLib::JoinType joinType
double miterLimit
CODE:
surfaces_append(RETVAL, offset_ex(THIS->expolygon, delta, joinType, miterLimit), *THIS);
OUTPUT:
RETVAL
%}
};
%package{Slic3r::Surface};
%{
IV
_constant()
ALIAS:
S_TYPE_TOP = stTop
S_TYPE_BOTTOM = stBottom
S_TYPE_BOTTOMBRIDGE = stBottomBridge
S_TYPE_INTERNAL = stInternal
S_TYPE_INTERNALSOLID = stInternalSolid
S_TYPE_INTERNALBRIDGE = stInternalBridge
S_TYPE_INTERNALVOID = stInternalVoid
S_TYPW_PERIMETER = stPerimeter
PROTOTYPE:
CODE:
RETVAL = ix;
OUTPUT: RETVAL
%}