(n_v, e_list, pos, v_size, radius_increment=0.3)
| 173 | |
| 174 | |
| 175 | def hull_layout(n_v, e_list, pos, v_size, radius_increment=0.3): |
| 176 | line_paths = [None] * len(e_list) |
| 177 | arc_paths = [None] * len(e_list) |
| 178 | |
| 179 | polygons_vertices_index = [] |
| 180 | vertices_radius = np.array(v_size) |
| 181 | vertices_increased_radius = vertices_radius * radius_increment |
| 182 | vertices_radius += vertices_increased_radius |
| 183 | |
| 184 | e_degree = [len(e) for e in e_list] |
| 185 | e_idxs = np.argsort(np.array(e_degree)) |
| 186 | |
| 187 | # for edge in e_list: |
| 188 | for e_idx in e_idxs: |
| 189 | edge = list(e_list[e_idx]) |
| 190 | |
| 191 | line_path_for_e = [] |
| 192 | arc_path_for_e = [] |
| 193 | |
| 194 | if len(edge) == 1: |
| 195 | arc_path_for_e.append([pos[edge[0]], 0, 360, vertices_radius[edge[0]]]) |
| 196 | |
| 197 | vertices_radius[edge] += vertices_increased_radius[edge] |
| 198 | |
| 199 | line_paths[e_idx] = line_path_for_e |
| 200 | arc_paths[e_idx] = arc_path_for_e |
| 201 | continue |
| 202 | |
| 203 | pos_in_edge = pos[edge] |
| 204 | if len(edge) == 2: |
| 205 | vertices_index = np.array((0, 1), dtype=np.int64) |
| 206 | else: |
| 207 | hull = ConvexHull(pos_in_edge) |
| 208 | vertices_index = hull.vertices |
| 209 | |
| 210 | n_vertices = vertices_index.shape[0] |
| 211 | |
| 212 | vertices_index = np.append(vertices_index, vertices_index[0]) # close the loop |
| 213 | |
| 214 | thetas = [] |
| 215 | |
| 216 | for i in range(n_vertices): |
| 217 | # line |
| 218 | i1 = edge[vertices_index[i]] |
| 219 | i2 = edge[vertices_index[i + 1]] |
| 220 | |
| 221 | r1 = vertices_radius[i1] |
| 222 | r2 = vertices_radius[i2] |
| 223 | |
| 224 | p1 = pos[i1] |
| 225 | p2 = pos[i2] |
| 226 | |
| 227 | dp = p2 - p1 |
| 228 | dp_len = vlen(dp) |
| 229 | |
| 230 | beta = radian_from_atan(dp[0], dp[1]) |
| 231 | alpha = common_tangent_radian(r1, r2, dp_len) |
| 232 |
no test coverage detected