Removed ZTable code

This commit is contained in:
Alessandro Ranellucci 2013-09-17 23:55:38 +02:00
parent a7989e382c
commit 4fe0675380
5 changed files with 0 additions and 146 deletions

View file

@ -1,23 +0,0 @@
#ifndef slic3r_ZTable_hpp_
#define slic3r_ZTable_hpp_
#include <vector>
namespace Slic3r {
class ZTable
{
public:
ZTable(std::vector<unsigned int>* z_array);
std::vector<unsigned int> get_range(unsigned int min_z, unsigned int max_z);
std::vector<unsigned int> z;
};
ZTable::ZTable(std::vector<unsigned int>* ztable) :
z(*ztable)
{
}
}
#endif

View file

@ -1,25 +0,0 @@
#!/usr/bin/perl
use strict;
use warnings;
use Slic3r::XS;
use Test::More tests => 10;
my $table = Slic3r::Object::XS::ZTable->new([ 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 ]);
is_deeply $table->get_range(31, 61), [2, 6], 'get_layer_range';
is_deeply $table->get_range(39, 69), [2, 6], 'get_layer_range';
is_deeply $table->get_range(30, 60), [2, 5], 'get_layer_range';
# upper_bound points to the first element that is greater than argument
is $table->upper_bound(30), 3, 'upper_bound';
is $table->upper_bound(31), 3, 'upper_bound';
is $table->upper_bound(39), 3, 'upper_bound';
is $table->upper_bound(39, 4), 4, 'upper_bound with offset';
# lower_bound points to the first element that is not less than argument
is $table->lower_bound(31), 3, 'lower_bound';
is $table->lower_bound(39), 3, 'lower_bound';
is $table->lower_bound(40), 3, 'lower_bound';
__END__

View file

@ -1,80 +0,0 @@
%module{Slic3r::XS};
%{
#include <myinit.h>
#include "ZTable.hpp"
#include <vector>
#include <algorithm>
%}
%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>
%}