m3sh.itertools#

Combinatorial mesh iterators.

The halfedge data structure facilitates efficient neighborhood traversal on a mesh. This module provides generic implementations of the most common traversal schemes using Python’s iterator protocol. Whenever possible and meanigful, adjacent/incident mesh items are visited in counter-clockwise order as determined by the mesh orientation

Example#

To compute the average of the 1-ring neighbors for each vertex of a mesh one can do

import itertools as it

for v in it.verts(mesh):
    avg = sum(w.point for w in it.verts(v))

An equivalent implementation using the interface provided by the halfedge data structure would be

for v in mesh.vertices:
    h = v.halfedge
    avg = 0.0

    while True:
        avg += h.target.point
        h = h.prev.pair

        if h is v.halfedge:
            break

Relation to simplical complexes#

Some basics forms of the provided iterators model notions from algebraic topology, see [1]. A triangle mesh is a simplical complex …

The star operator#

Let \(K\) be a simplicial complex. The (open) star of a simplex \(\sigma \in K\) is defined as

\[\operatorname{st}(\sigma) = \{ \tau \in K | \sigma \subset \tau \}\]

…

References#

[1]

Allen Hatcher: Algebraic Topology, 2001.

Functions

edges(mesh)

Edge iterator.

faces(obj)

Face iterator.

faces_bfs(item[, stop, start])

Breadth-first face neighborhood iterator.

faces_lnk(item)

Face iterator.

fdual_bfs(*seeds[, stop, start])

Dual breadth-first face neighborhood iterator.

halfs(obj)

Halfedge iterator

verts(obj)

Vertex iterator.

verts_bfs(item[, stop, start])

Breadth-first vertex neighborhood iterator.

verts_dij(item[, stop, start])

Dijkstra based vertex neighborhood iterator.