unify_cycles
- compas.topology.unify_cycles(vertices, faces, root=0)[source]
Unify the cycle directions of the given faces such that adjacent faces share opposite halfedges.
- Parameters
vertices (sequence[[float, float, float] |
compas.geometry.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.
- Returns
list[list[int]] – A list of faces with the same orientation as the root face.
- Raises
AssertionError – 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(vertices, faces) [[0, 1, 2], [2, 3, 0]]