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

« back to all changes in this revision

Viewing changes to xs/xsp/Polyline.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 "BoundingBox.hpp"
 
6
#include "ClipperUtils.hpp"
 
7
#include "Polyline.hpp"
 
8
%}
 
9
 
 
10
%name{Slic3r::Polyline} class Polyline {
 
11
    ~Polyline();
 
12
    Clone<Polyline> clone()
 
13
        %code{% RETVAL = THIS; %};
 
14
    SV* arrayref()
 
15
        %code{% RETVAL = THIS->to_AV(); %};
 
16
    SV* pp()
 
17
        %code{% RETVAL = THIS->to_SV_pureperl(); %};
 
18
    void scale(double factor);
 
19
    void translate(double x, double y);
 
20
    void pop_back()
 
21
        %code{% THIS->points.pop_back(); %};
 
22
    void reverse();
 
23
    Lines lines();
 
24
    Clone<Point> first_point();
 
25
    Clone<Point> last_point();
 
26
    Points equally_spaced_points(double distance)
 
27
        %code{% THIS->equally_spaced_points(distance, &RETVAL); %};
 
28
    double length();
 
29
    bool is_valid();
 
30
    void clip_end(double distance);
 
31
    void clip_start(double distance);
 
32
    void extend_end(double distance);
 
33
    void extend_start(double distance);
 
34
    void simplify(double tolerance);
 
35
    void split_at(Point* point, Polyline* p1, Polyline* p2)
 
36
        %code{% THIS->split_at(*point, p1, p2); %};
 
37
%{
 
38
 
 
39
Polyline*
 
40
Polyline::new(...)
 
41
    CODE:
 
42
        RETVAL = new Polyline ();
 
43
        // ST(0) is class name, ST(1) is first point
 
44
        RETVAL->points.resize(items-1);
 
45
        for (unsigned int i = 1; i < items; i++) {
 
46
            RETVAL->points[i-1].from_SV_check( ST(i) );
 
47
        }
 
48
    OUTPUT:
 
49
        RETVAL
 
50
 
 
51
void
 
52
Polyline::append(...)
 
53
    CODE:
 
54
        for (unsigned int i = 1; i < items; i++) {
 
55
            Point p;
 
56
            p.from_SV_check( ST(i) );
 
57
            THIS->points.push_back(p);
 
58
        }
 
59
 
 
60
void
 
61
Polyline::append_polyline(polyline)
 
62
    Polyline* polyline;
 
63
    CODE:
 
64
        for (Points::const_iterator it = polyline->points.begin(); it != polyline->points.end(); ++it) {
 
65
            THIS->points.push_back((*it));
 
66
        }
 
67
 
 
68
void
 
69
Polyline::rotate(angle, center_sv)
 
70
    double  angle;
 
71
    SV*     center_sv;
 
72
    CODE:
 
73
        Point center;
 
74
        center.from_SV_check(center_sv);
 
75
        THIS->rotate(angle, center);
 
76
 
 
77
Polygons
 
78
Polyline::grow(delta, scale = CLIPPER_OFFSET_SCALE, joinType = ClipperLib::jtSquare, miterLimit = 3)
 
79
    const float             delta
 
80
    double                  scale
 
81
    ClipperLib::JoinType    joinType
 
82
    double                  miterLimit
 
83
    CODE:
 
84
        Polylines polylines;
 
85
        polylines.push_back(*THIS);
 
86
        offset(polylines, RETVAL, delta, scale, joinType, miterLimit);
 
87
    OUTPUT:
 
88
        RETVAL
 
89
 
 
90
%}
 
91
};