def _get_tree(paths, closed): """ Add all paths to the tree and create mapping from ids of elements added to the tree to the elements data: Closed paths: [id of path, 1st point of segment, 2nd point of segment] Open paths [id of path, point of segment] """ # TODO: use models aabb? aabb = get_aabb(np.concatenate(paths)) tree = Quadtree([aabb.min[0], aabb.min[1], aabb.max[0], aabb.max[1]]) mapping = {} for path in paths: if closed: for i, j in zip(range(-1, len(path) - 1), range(len(path))): # add whole edge into the tree _add_edge(tree, mapping, path, i, j) else: _add_point(tree, mapping, path, 0) _add_point(tree, mapping, path, -1) tree.prune() return tree, mapping