Skip to content

Commit fc9e736

Browse files
committed
Update test_unify_cycles.py
1 parent c13863b commit fc9e736

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

tests/compas/topology/test_unify_cycles.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import compas
66
from compas.datastructures import Mesh
7+
from compas.geometry import volume_polyhedron
78
from compas.tolerance import TOL
89
from compas.topology import unify_cycles
910

@@ -16,11 +17,26 @@ def test_unify_cycles():
1617
test_data = compas.json_load(os.path.join(HERE, "..", "fixtures", "topology", "vertices_faces.json"))
1718
vertices = test_data["vertices"]
1819
faces = test_data["faces"]
20+
21+
max_edge_length = 22.386
22+
max_nbrs = 29
23+
volume = 1121.146165 # only correct if cycles are unified
24+
25+
# no parameters
1926
unify_cycles(vertices, faces)
20-
unify_cycles(vertices, faces, nmax=29, max_distance=22.4) # anything below won't work
27+
assert TOL.is_close(volume, volume_polyhedron((vertices, faces)))
28+
# only max_nbrs
29+
unify_cycles(vertices, faces, nmax=max_nbrs)
30+
assert TOL.is_close(volume, volume_polyhedron((vertices, faces)))
31+
# only max_distance
32+
unify_cycles(vertices, faces, max_distance=max_edge_length)
33+
assert TOL.is_close(volume, volume_polyhedron((vertices, faces)))
34+
# both parameters
35+
unify_cycles(vertices, faces, nmax=max_nbrs, max_distance=max_edge_length)
36+
assert TOL.is_close(volume, volume_polyhedron((vertices, faces)))
2137

2238

23-
def test_face_adjacency():
39+
def test_face_adjacency_and_unify_cycles():
2440
if compas.IPY:
2541
return
2642
for _ in range(10):
@@ -32,3 +48,6 @@ def test_face_adjacency():
3248
vertices, faces = mesh.to_vertices_and_faces()
3349
max_distance = math.sqrt((dx / nx) ** 2 + (dy / ny) ** 2) + TOL.absolute
3450
unify_cycles(vertices, faces, max_distance=max_distance)
51+
mesh = Mesh.from_vertices_and_faces(vertices, faces)
52+
for face in mesh.faces():
53+
assert TOL.is_allclose(mesh.face_normal(face), [0, 0, 1])

0 commit comments

Comments
 (0)