Skip to content

Instantly share code, notes, and snippets.

@DavidGeorge528
Last active May 6, 2017 13:01
Show Gist options
  • Save DavidGeorge528/ff99dc5a8a8c9a9d0e942042c9d2c8c4 to your computer and use it in GitHub Desktop.
Save DavidGeorge528/ff99dc5a8a8c9a9d0e942042c9d2c8c4 to your computer and use it in GitHub Desktop.
edges = {}
F = meshes[0]["Faces"].copy()
F.sort(1)
nf = F.shape[0]
for i in range(nf):
edges.setdefault(tuple(F[i,:2]), []).append(i)
edges.setdefault(tuple(F[i,1:3]), []).append(i)
edges.setdefault(tuple(F[i,[0,2]]), []).append(i)
neighbours = {}
for e in edges.values():
neighbours.setdefault(e[0], []).append(e[1])
neighbours.setdefault(e[1], []).append(e[0])
neighbours = array(list(neighbours.values()))
neighbours.sort(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment