def _mark_grid_bounds(self, plane, region_bbox):
<EOL>vbars = np.zeros([self.num_rows, self.num_cols + <NUM_LIT:1>], dtype=np.bool)<EOL>hbars = np.zeros([self.num_rows + <NUM_LIT:1>, self.num_cols], dtype=np.bool)<EOL>def closest_idx(arr, elem):<EOL><INDENT>left = bisect.bisect_left(arr, elem) - <NUM_LIT:1><EOL>right = bisect.bisect_right(arr, elem) - <NUM_LIT:1><EOL>return left if abs(arr[left] - elem) < abs(arr[right] - elem) else right<EOL><DEDENT>for row, (y0, y1) in enumerate(self.yranges):<EOL><INDENT>yc = (y0 + y1) // <NUM_LIT:2><EOL>for l in plane.find((region_bbox.x0, yc, region_bbox.x1, yc)):<EOL><INDENT>vbars[row, closest_idx(self.xs, l.xc)] = True<EOL><DEDENT><DEDENT>for col, (x0, x1) in enumerate(self.xranges):<EOL><INDENT>xc = (x0 + x1) // <NUM_LIT:2><EOL>for l in plane.find((xc, region_bbox.y0, xc, region_bbox.y1)):<EOL><INDENT>hbars[closest_idx(self.ys, l.yc), col] = True<EOL><DEDENT><DEDENT>return vbars, hbars<EOL>
Assume all lines define a complete grid over the region_bbox.
Detect which lines are missing so that we can recover merged
cells.