halfedges

property Mesh.halfedges

Halfedge dictionary.

Dictionary that maps pairs of Vertex objects to Halfedge instances. Hence, to visit Halfedge instances one can use

for h in mesh.halfedges.values():
    v = h.origin
    w = h.target
    ...

to directly visit halfedges as Vertex instance pairs use

for v, w in mesh.halfedges.keys():
    ...

To check whether two vertices of a mesh are adjacent (connected by an edge) we can do one of the following. The resulting value depends on the chosen query method:

(v, w) in mesh.halfedges                 # True or False
h = mesh.halfedges[v, w]                 # may raise KeyError
h = mesh.halfedges.get((v, w))           # can result in h = None