unify_cycles_numpy

compas.topology.unify_cycles_numpy(vertices, faces, root=0)[source]

Unify the cycle directions of the given faces such that adjacent faces share opposite halfedges.

Parameters:
verticessequence[[float, float, float] | compas.geometry.Point]

A list of vertex coordinates.

facessequence[sequence[int]]

A list of faces with each face defined by a list of indices into the list of vertices.

rootint, optional

The starting face.

Returns:
list[list[int]]

A list of faces with the same orientation as the root face.

Raises:
Exception

If not all faces were visited.

Notes

The algorithm works by first building an adjacency dict of the faces, which can be traversed efficiently to unify all face cycles. Although this process technically only requires the connectivity information contained in the faces, the locations of the vertices can be used to speed up execution for very large collections of faces.

Examples

>>> vertices = [[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [1.0, 1.0, 0.0], [0.0, 1.0, 1.0]]
>>> faces = [[0, 1, 2], [0, 3, 2]]
>>> unify_cycles_numpy(vertices, faces)
[[0, 1, 2], [2, 3, 0]]