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

« back to all changes in this revision

Viewing changes to xs/xsp/Line.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 "Line.hpp"
 
6
#include "Polyline.hpp"
 
7
%}
 
8
 
 
9
%name{Slic3r::Line} class Line {
 
10
    ~Line();
 
11
    Clone<Line> clone()
 
12
        %code{% RETVAL = THIS; %};
 
13
    SV* arrayref()
 
14
        %code{% RETVAL = THIS->to_AV(); %};
 
15
    SV* pp()
 
16
        %code{% RETVAL = THIS->to_SV_pureperl(); %};
 
17
    Ref<Point> a()
 
18
        %code{% RETVAL=&THIS->a; %};
 
19
    Ref<Point> b()
 
20
        %code{% RETVAL=&THIS->b; %};
 
21
    void reverse();
 
22
    void scale(double factor);
 
23
    void translate(double x, double y);
 
24
    double length();
 
25
    double atan2_();
 
26
    double direction();
 
27
    bool parallel_to(double angle);
 
28
    bool parallel_to_line(Line* line)
 
29
        %code{% RETVAL = THIS->parallel_to(*line); %};
 
30
    Point* midpoint();
 
31
    Clone<Point> point_at(double distance);
 
32
    Polyline* as_polyline()
 
33
        %code{% RETVAL = new Polyline(*THIS); %};
 
34
%{
 
35
 
 
36
Line*
 
37
Line::new(...)
 
38
    CODE:
 
39
        RETVAL = new Line ();
 
40
        // ST(0) is class name, ST(1) and ST(2) are endpoints
 
41
        RETVAL->a.from_SV_check( ST(1) );
 
42
        RETVAL->b.from_SV_check( ST(2) );
 
43
    OUTPUT:
 
44
        RETVAL
 
45
 
 
46
void
 
47
Line::rotate(angle, center_sv)
 
48
    double  angle;
 
49
    SV*     center_sv;
 
50
    CODE:
 
51
        Point center;
 
52
        center.from_SV_check(center_sv);
 
53
        THIS->rotate(angle, center);
 
54
 
 
55
bool
 
56
Line::coincides_with(line_sv)
 
57
    SV*     line_sv;
 
58
    CODE:
 
59
        Line line;
 
60
        line.from_SV_check(line_sv);
 
61
        RETVAL = THIS->coincides_with(line);
 
62
    OUTPUT:
 
63
        RETVAL
 
64
 
 
65
%}
 
66
};