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

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

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

%name{Slic3r::ExPolygon::Collection} class ExPolygonCollection {
    ~ExPolygonCollection();
    Clone<ExPolygonCollection> clone() 
        %code{% RETVAL = THIS; %};
    void clear()
        %code{% THIS->expolygons.clear(); %};
    void scale(double factor);
    void translate(double x, double y);
    void rotate(double angle, Point* center)
        %code{% THIS->rotate(angle, *center); %};
    int count()
        %code{% RETVAL = THIS->expolygons.size(); %};
    bool contains_point(Point* point)
        %code{% RETVAL = THIS->contains_point(*point); %};
    bool contains_line(Line* line)
        %code{% RETVAL = THIS->contains_line(*line); %};
    bool contains_polyline(Polyline* polyline)
        %code{% RETVAL = THIS->contains_polyline(*polyline); %};
    void simplify(double tolerance);
    Polygons polygons()
        %code{% RETVAL = *THIS; %};
%{

ExPolygonCollection*
ExPolygonCollection::new(...)
    CODE:
        RETVAL = new ExPolygonCollection ();
        // ST(0) is class name, others are expolygons
        RETVAL->expolygons.resize(items-1);
        for (unsigned int i = 1; i < items; i++) {
            // Note: a COPY of the input is stored
            RETVAL->expolygons[i-1].from_SV_check(ST(i));
        }
    OUTPUT:
        RETVAL

SV*
ExPolygonCollection::arrayref()
    CODE:
        AV* av = newAV();
        av_fill(av, THIS->expolygons.size()-1);
        int i = 0;
        for (ExPolygons::iterator it = THIS->expolygons.begin(); it != THIS->expolygons.end(); ++it) {
            av_store(av, i++, perl_to_SV_ref(*it));
        }
        RETVAL = newRV_noinc((SV*)av);
    OUTPUT:
        RETVAL

SV*
ExPolygonCollection::pp()
    CODE:
        AV* av = newAV();
        av_fill(av, THIS->expolygons.size()-1);
        int i = 0;
        for (ExPolygons::iterator it = THIS->expolygons.begin(); it != THIS->expolygons.end(); ++it) {
            av_store(av, i++, (*it).to_SV_pureperl());
        }
        RETVAL = newRV_noinc((SV*)av);
    OUTPUT:
        RETVAL

void
ExPolygonCollection::append(...)
    CODE:
        for (unsigned int i = 1; i < items; i++) {
            ExPolygon expolygon;
            expolygon.from_SV_check( ST(i) );
            THIS->expolygons.push_back(expolygon);
        }

Polygon*
ExPolygonCollection::convex_hull()
    CODE:
        RETVAL = new Polygon ();
        THIS->convex_hull(RETVAL);
    OUTPUT:
        RETVAL

%}
};