Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Line.xsp « xsp « xs - github.com/supermerill/SuperSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7ee6444947fda1bbfacef7cc3f8aa9fe29667ab6 (plain)
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
%module{Slic3r::XS};

%{
#include <myinit.h>
#include "libslic3r/Line.hpp"
#include "libslic3r/Polyline.hpp"
%}

%name{Slic3r::Line} class Line {
    ~Line();
    Clone<Line> clone()
        %code{% RETVAL = THIS; %};
    SV* arrayref()
        %code{% RETVAL = THIS->to_AV(); %};
    SV* pp()
        %code{% RETVAL = THIS->to_SV_pureperl(); %};
    Ref<Point> a()
        %code{% RETVAL=&THIS->a; %};
    Ref<Point> b()
        %code{% RETVAL=&THIS->b; %};
    void reverse();
    void scale(double factor);
    void translate(double x, double y);
    double length();
    double atan2_();
    double orientation();
    double direction();
    bool parallel_to(double angle);
    bool parallel_to_line(Line* line)
        %code{% RETVAL = THIS->parallel_to(*line); %};
    Clone<Point> midpoint();
    Clone<Point> point_at(double distance);
    Clone<Point> intersection_infinite(Line* other)
        %code{%
            Point p;
            bool res = THIS->intersection_infinite(*other, &p);
            if (!res) CONFESS("Intersection failed");
            RETVAL = p;
        %};
    Clone<Polyline> as_polyline()
        %code{% RETVAL = Polyline(*THIS); %};
    Clone<Point> normal();
    Clone<Point> vector();
%{

Line*
Line::new(...)
    CODE:
        RETVAL = new Line ();
        // ST(0) is class name, ST(1) and ST(2) are endpoints
        RETVAL->a.from_SV_check( ST(1) );
        RETVAL->b.from_SV_check( ST(2) );
    OUTPUT:
        RETVAL

void
Line::rotate(angle, center_sv)
    double  angle;
    SV*     center_sv;
    CODE:
        Point center;
        center.from_SV_check(center_sv);
        THIS->rotate(angle, center);

bool
Line::coincides_with(line_sv)
    SV*     line_sv;
    CODE:
        Line line;
        line.from_SV_check(line_sv);
        RETVAL = THIS->coincides_with(line);
    OUTPUT:
        RETVAL

%}
};


%name{Slic3r::Linef3} class Linef3 {
    Linef3(Pointf3* a, Pointf3* b)
        %code{% RETVAL = new Linef3(*a, *b); %};
    ~Linef3();
    Clone<Linef3> clone()
        %code{% RETVAL = THIS; %};
    Ref<Pointf3> a()
        %code{% RETVAL = &THIS->a; %};
    Ref<Pointf3> b()
        %code{% RETVAL = &THIS->b; %};
    Clone<Pointf3> intersect_plane(double z);
    void scale(double factor);
};