def scaleContour(pol, scale):
	# Scale up the polygon relative to its center
	cx = 0
	cy = 0
	for i in range(pol.npoints):
		cx += pol.xpoints[i]
		cy += pol.ypoints[i]

	cx /= pol.npoints
	cy /= pol.npoints

	aff = AffineTransform(1, 0, 0, 1, -cx, -cy)
	aff.preConcatenate(AffineTransform(scale, 0, 0, scale, 0, 0))
	aff.preConcatenate(AffineTransform(1, 0, 0, 1, cx, cy))

	tmp = Area(pol)
	tmp.transform(aff)
	return M.getPolygons(tmp)[0]
def findLocals(project, pol):
	# Test if any node of every treeline is outside the polygon,
	# to determine if a neuron is local or not.
	lys = project.getRootLayerSet()
	trees = [t for t in lys.getZDisplayables(Treeline)]
	trees = trees + [t for t in lys.getZDisplayables(AreaTree)]

	tags = {}

	for tree in trees:
		# Make the polygon local to the tree coordinates
		a = Area(pol)
		a.transform(tree.getAffineTransform().createInverse())
		localPol = M.getPolygons(a)[0]
		isLocal = False
		for node in tree.getRoot().getSubtreeNodes():
			if localPol.contains(node.x, node.y):
				continue
			isLocal = True
			break
		tags[tree.getId()] = isLocal

	return tags