Skip to content

Instantly share code, notes, and snippets.

@JossWhittle
Forked from DavidGeorge528/getEdges.py
Last active May 6, 2017 13:46
Show Gist options
  • Save JossWhittle/ad9d9d4e0bc2197db349d76fc329ae33 to your computer and use it in GitHub Desktop.
Save JossWhittle/ad9d9d4e0bc2197db349d76fc329ae33 to your computer and use it in GitHub Desktop.
F = meshes[0]["Faces"].copy().sort(1)
num_faces = F.shape[0]
edges = {}
for i in range(num_faces):
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 = np.zeros((num_faces, 3), dtype=np.uint32)
idx = np.zeros((num_faces), dtype=np.uint32)
for ef in edges.values():
neighbours[ef[0], idx[ef[0]]] = ef[1]
neighbours[ef[1], idx[ef[1]]] = ef[0]
idx[ef[0]] += 1
idx[ef[1]] += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment