def apply_fp(self, obj): fp = obj.footprint success = True if fp.is_square: vector = Vector.from_point(obj.coords) for pt in fp.points: pt = pt + vector if not self.get(pt).occupy(obj): success = False if not success: self.release_fp(obj) return False else: cx, cy = obj.coords.get() radius = fp.size / 2 gr = radius / self.CORE.sub_per_cell for y in range(int(cy-gr/2)-1, int(cy+gr/2)+2): if not success: break for x in range(int(cx-gr/2)-1, int(cx+gr/2)+2): if not self.get((x,y)).occupy(obj): success = False break if not success: self.release_fp(obj) return False return True
def release_fp(self, obj): fp = obj.footprint if fp.is_square: vector = Vector.from_point(obj.coords) for pt in fp.points: pt = pt + vector self.get(pt).release(obj) else: cx, cy = obj.coords.get() radius = fp.size / 2 gr = radius / self.CORE.sub_per_cell for y in range(int(cy-gr/2)-1, int(cy+gr/2)+2): for x in range(int(cx-gr/2)-1, int(cx+gr/2)+2): self.get((x,y)).release(obj)