(mesh, config, min_node_in_cc)
| 162 | return point_3d |
| 163 | |
| 164 | def generate_init_node(mesh, config, min_node_in_cc): |
| 165 | mesh_nodes = mesh.nodes |
| 166 | |
| 167 | info_on_pix = {} |
| 168 | |
| 169 | ccs = sorted(netx.connected_components(mesh), key = len, reverse=True) |
| 170 | remove_nodes = [] |
| 171 | |
| 172 | for cc in ccs: |
| 173 | |
| 174 | remove_flag = True if len(cc) < min_node_in_cc else False |
| 175 | if remove_flag is False: |
| 176 | for (nx, ny, nd) in cc: |
| 177 | info_on_pix[(nx, ny)] = [{'depth':nd, |
| 178 | 'color':mesh_nodes[(nx, ny, nd)]['color'], |
| 179 | 'synthesis':False, |
| 180 | 'disp':mesh_nodes[(nx, ny, nd)]['disp']}] |
| 181 | else: |
| 182 | [remove_nodes.append((nx, ny, nd)) for (nx, ny, nd) in cc] |
| 183 | |
| 184 | for node in remove_nodes: |
| 185 | far_nodes = [] if mesh_nodes[node].get('far') is None else mesh_nodes[node]['far'] |
| 186 | for far_node in far_nodes: |
| 187 | if mesh.has_node(far_node) and mesh_nodes[far_node].get('near') is not None and node in mesh_nodes[far_node]['near']: |
| 188 | mesh_nodes[far_node]['near'].remove(node) |
| 189 | near_nodes = [] if mesh_nodes[node].get('near') is None else mesh_nodes[node]['near'] |
| 190 | for near_node in near_nodes: |
| 191 | if mesh.has_node(near_node) and mesh_nodes[near_node].get('far') is not None and node in mesh_nodes[near_node]['far']: |
| 192 | mesh_nodes[near_node]['far'].remove(node) |
| 193 | |
| 194 | [mesh.remove_node(node) for node in remove_nodes] |
| 195 | |
| 196 | return mesh, info_on_pix |
| 197 | |
| 198 | def get_neighbors(mesh, node): |
| 199 | return [*mesh.neighbors(node)] |
no test coverage detected