def get_intersection_dictionary(bm, edge_indices): permutations = get_valid_permutations(bm, edge_indices) k = defaultdict(list) d = defaultdict(list) for edges in permutations: raw_vert_indices = cm.vertex_indices_from_edges_tuple(bm, edges) vert_vectors = cm.vectors_from_indices(bm, raw_vert_indices) points = LineIntersect(*vert_vectors) # some can be skipped. (NaN, None, not on both edges) if can_skip(points, vert_vectors): continue # reaches this point only when an intersection happens on both edges. [k[edge].append(points[0]) for edge in edges] # k will contain a dict of edge indices and points found on those edges. for edge_idx, unordered_points in k.items(): tv1, tv2 = bm.edges[edge_idx].verts v1 = bm.verts[tv1.index].co v2 = bm.verts[tv2.index].co ordered_points = order_points((v1, v2), unordered_points) d[edge_idx].extend(ordered_points) return d
def remove_permutations_that_share_a_vertex(bm, permutations): ''' Get useful Permutations ''' final_permutations = [] for edges in permutations: raw_vert_indices = cm.vertex_indices_from_edges_tuple(bm, edges) if cm.duplicates(raw_vert_indices): continue # reaches this point if they do not share. final_permutations.append(edges) return final_permutations