Skip to content

Commit df3af03

Browse files
committed
Add tests a collapse test
1 parent faef059 commit df3af03

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
lines changed

actions/triangular_actions.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -147,21 +147,6 @@ def collapse_edge(mesh: Mesh, n1: Node, n2: Node) -> True:
147147
return mesh_check(mesh)
148148

149149

150-
def test_boundary(n1: Node, n2: Node) -> bool:
151-
boundary_darts_n1 = []
152-
boundary_darts_n2 = []
153-
for d in adjacent_darts(n1):
154-
if d.get_beta(2) is None:
155-
boundary_darts_n1.append(d)
156-
for d in adjacent_darts(n2):
157-
if d.get_beta(2) is None:
158-
boundary_darts_n2.append(d)
159-
if (len(boundary_darts_n1) + len(boundary_darts_n2)) > 3:
160-
return False
161-
else:
162-
return True
163-
164-
165150
def check_beta2_relation(mesh: Mesh) -> bool:
166151
for dart_info in mesh.active_darts():
167152
d = dart_info[0]

test_modules/test_actions.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import unittest
22
import mesh_model.mesh_struct.mesh as mesh
33
from mesh_model.mesh_struct.mesh_elements import Dart, Node
4-
4+
from mesh_model.random_trimesh import regular_mesh
55
from actions.triangular_actions import split_edge, flip_edge, collapse_edge
6+
from plots.mesh_plotter import plot_mesh
7+
68

79
class TestActions(unittest.TestCase):
810

@@ -61,14 +63,22 @@ def test_collapse(self):
6163
nodes = [[0.0, 0.0], [1.0, 0.0], [1.0, 1.0], [0.0, 1.0]]
6264
faces = [[0, 1, 2], [0, 2, 3]]
6365
cmap = mesh.Mesh(nodes, faces)
66+
plot_mesh(cmap)
6467
n00 = Node(cmap, 0)
6568
n11 = Node(cmap, 2)
6669
split_edge(cmap, n00, n11)
70+
plot_mesh(cmap)
6771
n5 = Node(cmap, 4)
6872
collapse_edge(cmap, n00, n5)
6973
d1_to_test = Dart(cmap, 7)
7074
d2_to_test = Dart(cmap, 0)
7175
self.assertEqual(collapse_edge(cmap, n00, n5), False)
76+
# Test possible collapse
77+
cmap = regular_mesh(16)
78+
d = Dart(cmap, 0)
79+
n0 = d.get_node()
80+
n1 = d.get_beta(1).get_node()
81+
self.assertEqual(collapse_edge(cmap, n0, n1), True)
7282

7383
def test_split_collapse_split(self):
7484
nodes = [[0.0, 0.0], [1.0, 0.0], [1.0, 1.0], [0.0, 1.0]]

0 commit comments

Comments
 (0)