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

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

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

%name{Slic3r::Object::XS::ZTable} class ZTable {
    ZTable(std::vector<unsigned int>* z_array);
    ~ZTable();

%{
std::vector<unsigned int>
get_range(THIS, min_z, max_z)
    ZTable* THIS;
    unsigned int min_z;
    unsigned int max_z;
    CODE:
        RETVAL.resize(2);
        
        unsigned int bottom = 0;
        unsigned int top = THIS->z.size()-1;
        while (1) {
            unsigned int mid = bottom + floor((top - bottom)/2.0);
            if (mid == top || mid == bottom) {
                RETVAL[0] = mid;
                break;
            }
            if (THIS->z[mid] > min_z) {
                top = mid;
            } else {
                bottom = mid;
            }
        }
        top = THIS->z.size()-1;
        while (1) {
            unsigned int mid = bottom + ceil((top - bottom)/2.0);
            if (mid == top || mid == bottom) {
                RETVAL[1] = mid;
                break;
            }
            if (THIS->z[mid] < max_z) {
                bottom = mid;
            } else {
                top = mid;
            }
        }
    OUTPUT:
        RETVAL

unsigned int
ZTable::lower_bound(z, offset = 0)
    unsigned int z
    unsigned int offset
    CODE:
        RETVAL = std::lower_bound(THIS->z.begin() + offset, THIS->z.end(), z) - THIS->z.begin();
    OUTPUT:
        RETVAL

unsigned int
ZTable::upper_bound(z, offset = 0)
    unsigned int z
    unsigned int offset
    CODE:
        RETVAL = std::upper_bound(THIS->z.begin() + offset, THIS->z.end(), z) - THIS->z.begin();
    OUTPUT:
        RETVAL

%}

};

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

%{
#include <myinit.h>
#include <vector>
%}