Looking for input on how to process some polygonal data, that’s just a nested list of connected faces. I’d like an algorithm that scales up, and am not sure if a solution already exists as a standard python pattern/process. This seems like a problem that’s been solved a bajillion times already.
I’d like to turn this list of sets, that contain overlapping values, into a list of sets with no overlaps. I can do it for small chunks of data, but this solution doesn’t scale well at all.
#two cubes, combined into one object = two shells.
poly_lists = [[0, 5, 1, 4, 3],
[1, 5, 2, 4, 0],
[2, 5, 3, 4, 1],
[3, 0, 5, 4, 2],
[4, 1, 0, 2, 3],
[5, 1, 2, 0, 3],
[6, 11, 7, 10, 9],
[7, 11, 8, 10, 6],
[8, 11, 9, 10, 7],
[9, 6, 11, 10, 8],
[10, 7, 6, 8, 9],
[11, 7, 8, 6, 9]]
shell_sets = []
shell_sets_temp = []
for poly_list in poly_lists:
shell_sets_temp = shell_sets
found = False
for i, a_shell in enumerate(shell_sets_temp):
if len(set(a_shell ) & set(poly_list)):
shell_sets[i] = set(a_shell ) | set(poly_list)
found = True
break
if not found:
shell_sets.append(set(poly_list))
print shell_sets
#shell_sets = [set([0, 1, 2, 3, 4, 5]), set([6, 7, 8, 9, 10, 11])]
#Two sets == Two polygonal shells! It works!
#but not for very large lists, takes too long.