60 lines
1.2 KiB
Plaintext
60 lines
1.2 KiB
Plaintext
%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);
|
|
|
|
%{
|
|
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
|
|
%}
|
|
|
|
};
|
|
|
|
%package{Slic3r::Object::XS};
|
|
|
|
%{
|
|
#include <myinit.h>
|
|
#include <vector>
|
|
%}
|