def __init__(self,mesh,scale,length,time,gen_num,c_mesh=None):
		print "Hello!"
		Mesh.__init__(self,mesh) #this is why we needed to use it I think
		self.bd = du.boundary_dict(mesh)
		self.ibd = du.boundary_id_dict(mesh,self.bd)
		self.point_index = {}
#		self.particles_point = {}
		self.p_region = {}
		self.n_region = {}
		self.particles = []
		self.trajectories = {}
		self.scale = scale
		self.c_mesh = None
		self.super_particles_count = 0
		self.dim=self.topology().dim()
		if self.dim == 2:
			self.kdt = kdtree_c.new_kdtree(mesh.coordinates())
		else:
			self.kdt = kdtree_c.new_kdtree3(mesh.coordinates())
		#self.bandstructure = bandstructure.ParabolicBand(self) #should be part of the material
		self.material = {}
		self.length_scale = length
		self.dt = time
		self.charge_particle = constants.eC
		self.gen_num= gen_num

		#init point->index map, point->particle map
		for x,id in it.izip(mesh.coordinates(),it.count()):
			self.point_index[tuple(x)] = id
import kdtree_c as kd
import kdtree3_c as kd3
import numpy as np
import numpy.random as random


def dist(point1, point2):
    vec1, vec2 = np.array(point1), np.array(point2)
    return np.linalg.norm(vec1 - vec2)


n = 100000
no_fail = True
points = map(list, zip(random.rand(n), random.rand(n)))
tree = kd.new_kdtree(points)

for id, point in zip(range(len(points)), points):
    offset = list((point[0] + 0.01, point[1] + 0.01))
    res = kd.find_point_id(tree, offset)
    if id != res:
        better = dist(offset, points[res])
        expected = dist(offset, point)
        if better > expected:
            no_fail = False
            print "point:", point, expected
            print "offset:", offset
            print "believed:", points[res], better
            break
if no_fail == True:
    print "Success for 2d!", id
else: