def enclose_pin_grids(self, ll, dir1=direction.NORTH, dir2=direction.EAST): """ This encloses a single pin component with a rectangle starting with the seed and expanding dir1 until blocked and then dir2 until blocked. dir1 and dir2 should be two orthogonal directions. """ offset1 = direction.get_offset(dir1) offset2 = direction.get_offset(dir2) # We may have started with an empty set debug.check(len(self.grids) > 0, "Cannot seed an grid empty set.") # Start with the ll and make the widest row row = [ll] # Move in dir1 while we can while True: next_cell = row[-1] + offset1 # Can't move if not in the pin shape if next_cell in self.grids and next_cell not in self.router.get_blocked_grids( ): row.append(next_cell) else: break # Move in dir2 while we can while True: next_row = [x + offset2 for x in row] for cell in next_row: # Can't move if any cell is not in the pin shape if cell not in self.grids or cell in self.router.get_blocked_grids( ): break else: row = next_row # Skips the second break continue # Breaks from the nested break break # Add a shape from ll to ur ur = row[-1] return (ll, ur)
def neighbor(self, d): offset = direction.get_offset(d) newwave = [point + offset for point in self.pathlist[-1]] if newwave in self.pathlist: return None elif newwave[0].z > 1 or newwave[0].z < 0: return None return newwave
def increment_set(curset, direct): """ Return the cells incremented in given direction """ offset = direction.get_offset(direct) newset = set() for c in curset: newc = c + offset newset.add(newc) return newset