~ubuntu-branches/ubuntu/utopic/slic3r/utopic

« back to all changes in this revision

Viewing changes to xs/xsp/Surface.xsp

  • Committer: Package Import Robot
  • Author(s): Chow Loong Jin
  • Date: 2014-06-17 01:27:26 UTC
  • Revision ID: package-import@ubuntu.com-20140617012726-2wrs4zdo251nr4vg
Tags: upstream-1.1.4+dfsg
ImportĀ upstreamĀ versionĀ 1.1.4+dfsg

Show diffs side-by-side

added added

removed removed

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