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

ExPolygon.xsp « xsp « xs - github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0c8bdbf9e0e263e73274e1910d01038c4f0a4cc4 (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
%module{Slic3r::XS};

%{
#include <myinit.h>
#include "ExPolygon.hpp"
%}

%name{Slic3r::ExPolygon::XS} class ExPolygon {
%{

ExPolygon*
ExPolygon::new(...)
    CODE:
        RETVAL = new ExPolygon ();
        // ST(0) is class name, ST(1) is contour and others are holes
        RETVAL->contour = *perl2polygon(ST(1));
        for (unsigned int i = 2; i < items; i++) {
            RETVAL->holes.push_back(*perl2polygon(ST(i)));
        }
    OUTPUT:
        RETVAL

SV*
ExPolygon::_toPerl()
    CODE:
        const unsigned int num_holes = THIS->holes.size();
        AV* av = newAV();
        av_fill(av, num_holes);  // -1 +1
        av_store(av, 0, polygon2perl(THIS->contour));
        for (unsigned int i = 0; i < num_holes; i++) {
            av_store(av, i+1, polygon2perl(THIS->holes[i]));
        }
        RETVAL = (SV*)newRV_noinc((SV*)av);
    OUTPUT:
        RETVAL

%}
};

%package{Slic3r::ExPolygon::XS};

%{
PROTOTYPES: DISABLE

std::string
hello_world()
  CODE:
    RETVAL = "Hello world!";
  OUTPUT:
    RETVAL
%}