- compas.topology.unify_cycles(vertices, faces, root=0)
Unify the cycle directions of the given faces such that adjacent faces share opposite halfedges.
vertices (sequence[[float, float, float] |
Point]) – A list of vertex coordinates.
faces (sequence[sequence[int]]) – A list of faces with each face defined by a list of indices into the list of vertices.
root (int, optional) – The starting face.
list[list[int]] – A list of faces with the same orientation as the root face.
AssertionError – If not all faces were visited.
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.
>>> 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(vertices, faces) [[0, 1, 2], [2, 3, 0]]