Ported get_layer_range() to C

This commit is contained in:
Alessandro Ranellucci 2013-06-23 15:33:07 +02:00
parent ff795f2918
commit 37105e8237
14 changed files with 72 additions and 738 deletions

49
xs/xsp/Object.xsp Normal file
View file

@ -0,0 +1,49 @@
%module{Slic3r::XS};
%package{Slic3r::Object::XS};
#include <list>
#include <vector>
%{
PROTOTYPES: DISABLE
std::vector<unsigned int>
get_layer_range(z_array, min_z, max_z)
std::vector<unsigned int>* z_array;
unsigned int min_z;
unsigned int max_z;
CODE:
RETVAL.resize(2);
unsigned int bottom = 0;
unsigned int top = z_array->size()-1;
while (1) {
unsigned int mid = bottom + floor((top - bottom)/2.0);
if (mid == top || mid == bottom) {
RETVAL[0] = mid;
break;
}
if ((*z_array)[mid] > min_z) {
top = mid;
} else {
bottom = mid;
}
}
top = z_array->size()-1;
while (1) {
unsigned int mid = bottom + ceil((top - bottom)/2.0);
if (mid == top || mid == bottom) {
RETVAL[1] = mid;
break;
}
if ((*z_array)[mid] < max_z) {
bottom = mid;
} else {
top = mid;
}
}
delete z_array;
OUTPUT:
RETVAL
%}

View file

@ -1,4 +1,4 @@
%module{Slic3r::TriangleMesh::XS};
%module{Slic3r::XS};
%package{Slic3r::TriangleMesh::XS};
%{

View file

@ -1,6 +1,8 @@
%module{Slic3r::XS};
%package{Slic3r::XS};
%{
#include <myinit.h>
%{
%}

1
xs/xsp/my.map Normal file
View file

@ -0,0 +1 @@
std::map<uint32_t, uint32_t>* T_PTR

View file

@ -1,2 +1 @@
%typemap{std::string}{simple};
%typemap{std::string&}{reference};
%typemap{std::string};