Example #1
0
	def nsteps(self, source, target, bias):
		w = bias.attrib('width')
		e = bias.attrib('edge')
		ps = []
		if not hasattr(source[0], '__getitem__'):
			source= [source]
		if not hasattr(target[0], '__getitem__'):
			target = [target]
		for i in range(len(source)):
			for j in range(len(target)):
				p1 = xyToHexI(source[i], w, e)
				p2 = xyToHexI(target[j],w, e)
				ps.append(pathSeparation(p1,p2,w))
		return min(ps)
Example #2
0
	def prep(self, n, source, target):
		ss = self.space()
		if not hasattr(source[0], '__getitem__'):
			source= [source]
		self.source=ss
		for pt in source:
			spi=hg.xyToHexI(pt[:2], self.width, self.hexedge)
			ss[spi]=pt[2]
		ts = self.space()
		if not hasattr(target[0], '__getitem__'):
			target = [target]
		for pt in target:
			tpi=hg.xyToHexI(pt[:2], self.width, self.hexedge)
			ts[tpi]=pt[2]                                                                                                                         
		self.layers=[]
		self.iter=0
		for i in range(n):
			self.layers.append({'source':None, 'target':None, 'gain':ones(self.nMaps(i)),  'dead':zeros(self.nMaps(i))})
		self.layers[-1]['target']=ts