def _construct_ordered_GET(self): """ Construct a Global Edge Table (GET) The GET is an OrderedDict. Keys are scan line numbers, ordered from bbox.ymin to bbox.ymax, where bbox is the bounding box of the polygon. Values are lists of edges for which edge.ymin==scan_line_number. Returns ------- GET: OrderedDict {scan_line: [edge1, edge2]} """ # edges is a list of Edge objects which define a polygon # with these vertices edges = self.get_edges() GET = OrderedDict.fromkeys(self._scan_line_range) ymin = np.asarray([e._ymin for e in edges]) for i in self._scan_line_range: ymin_ind = (ymin == i).nonzero()[0] if ymin_ind.any(): GET[i] = [edges[ymin_ind[0]]] for j in ymin_ind[1:]: GET[i].append(edges[j]) return GET