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

Point.xsp « xsp « xs - github.com/supermerill/SuperSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 21c8d9ab1a3e3fc5e6c0f1aa5232759eaa2f8793 (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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
%module{Slic3r::XS};

%{
#include <myinit.h>
#include "Point.hpp"
#include "Polygon.hpp"
#include "Polyline.hpp"
%}

%name{Slic3r::Point} class Point {
    Point(long _x = 0, long _y = 0);
    ~Point();
    Clone<Point> clone()
        %code{% RETVAL=THIS; %}; 
    void scale(double factor);
    void translate(double x, double y);
    SV* arrayref()
        %code{% RETVAL = THIS->to_SV_pureperl(); %};
    SV* pp()
        %code{% RETVAL = THIS->to_SV_pureperl(); %};
    long x()
        %code{% RETVAL = THIS->x; %};
    long y()
        %code{% RETVAL = THIS->y; %};
    int nearest_point_index(Points points);
    Point* nearest_point(Points points)
        %code{% RETVAL = new Point(); THIS->nearest_point(points, RETVAL); %};
    double distance_to(Point* point)
        %code{% RETVAL = THIS->distance_to(*point); %};
    double distance_to_line(Line* line)
        %code{% RETVAL = THIS->distance_to(*line); %};
    double ccw(Point* p1, Point* p2)
        %code{% RETVAL = THIS->ccw(*p1, *p2); %};
    Clone<Point> projection_onto_polygon(Polygon* polygon)
        %code{% RETVAL = new Point(THIS->projection_onto(*polygon)); %};
    Clone<Point> projection_onto_polyline(Polyline* polyline)
        %code{% RETVAL = new Point(THIS->projection_onto(*polyline)); %};
    Clone<Point> projection_onto_line(Line* line)
        %code{% RETVAL = new Point(THIS->projection_onto(*line)); %};
    Clone<Point> negative()
        %code{% RETVAL = new Point(THIS->negative()); %};
    bool coincides_with_epsilon(Point* point)
        %code{% RETVAL = THIS->coincides_with_epsilon(*point); %};

%{

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

bool
Point::coincides_with(point_sv)
    SV*     point_sv;
    CODE:
        Point point;
        point.from_SV_check(point_sv);
        RETVAL = THIS->coincides_with(point);
    OUTPUT:
        RETVAL

%}

};

%name{Slic3r::Point3} class Point3 {
    Point3(long _x = 0, long _y = 0, long _z = 0);
    ~Point3();
    Clone<Point3> clone()
        %code{% RETVAL = THIS; %};
    long x()
        %code{% RETVAL = THIS->x; %};
    long y()
        %code{% RETVAL = THIS->y; %};
    long z()
        %code{% RETVAL = THIS->z; %};
};

%name{Slic3r::Pointf} class Pointf {
    Pointf(double _x = 0, double _y = 0);
    ~Pointf();
    Clone<Pointf> clone()
        %code{% RETVAL = THIS; %};
    SV* arrayref()
        %code{% RETVAL = THIS->to_SV_pureperl(); %};
    SV* pp()
        %code{% RETVAL = THIS->to_SV_pureperl(); %};
    double x()
        %code{% RETVAL = THIS->x; %};
    double y()
        %code{% RETVAL = THIS->y; %};
    void translate(double x, double y);
    void scale(double factor);
    void rotate(double angle, Pointf* center)
        %code{% THIS->rotate(angle, *center); %};
};

%name{Slic3r::Pointf3} class Pointf3 {
    Pointf3(double _x = 0, double _y = 0, double _z = 0);
    ~Pointf3();
    Clone<Pointf3> clone()
        %code{% RETVAL = THIS; %};
    double x()
        %code{% RETVAL = THIS->x; %};
    double y()
        %code{% RETVAL = THIS->y; %};
    double z()
        %code{% RETVAL = THIS->z; %};
};