Skip to content

Commit 7cce9d1

Browse files
committed
Improve test coverage
1 parent 79c3522 commit 7cce9d1

File tree

2 files changed

+57
-12
lines changed

2 files changed

+57
-12
lines changed

test_modules/test_quadrangular_mesh_analysis.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from mesh_model.mesh_struct.mesh import Mesh
55
from mesh_model.mesh_struct.mesh_elements import Dart
66
from mesh_model.mesh_analysis.quadmesh_analysis import QuadMeshOldAnalysis
7-
from environment.actions.triangular_actions import split_edge_ids
7+
from environment.actions.quadrangular_actions import split_edge_ids, flip_edge_cw_ids
88
from view.mesh_plotter.mesh_plots import plot_mesh
99
from mesh_model.reader import read_gmsh
1010

@@ -31,30 +31,39 @@ def test_is_valid_action(self):
3131
filename = os.path.join(TESTFILE_FOLDER, 't1_quad.msh')
3232
cmap = read_gmsh(filename)
3333
qma = QuadMeshOldAnalysis(cmap)
34+
3435
#Boundary dart
3536
self.assertEqual(qma.isValidAction(20, 0), (False, True))
3637

37-
# Flip test
38+
# Flip Clockwise test
3839
self.assertEqual(qma.isValidAction(3, 0), (True, True))
3940
self.assertEqual(qma.isValidAction(27, 0), (False, True))
4041

41-
#Split test
42-
self.assertEqual(qma.isValidAction(0, 1), (True, True))
42+
# Flip Counterclockwise test
43+
self.assertEqual(qma.isValidAction(3, 1), (True, True))
4344
self.assertEqual(qma.isValidAction(27, 1), (False, True))
4445

45-
#Collapse test
46+
#Split test
4647
self.assertEqual(qma.isValidAction(0, 2), (True, True))
47-
plot_mesh(cmap)
4848
self.assertEqual(qma.isValidAction(27, 2), (False, True))
4949

50-
#All action test
50+
#Collapse test
51+
self.assertEqual(qma.isValidAction(0, 3), (True, True))
52+
plot_mesh(cmap)
5153
self.assertEqual(qma.isValidAction(27, 3), (False, True))
52-
self.assertEqual(qma.isValidAction(9, 3), (True, True))
54+
55+
#Cleanup test action id = 4
56+
57+
#All action test
58+
self.assertEqual(qma.isValidAction(27, 5), (False, True))
59+
flip_edge_cw_ids(qma,13,37)
60+
self.assertEqual(qma.isValidAction(66, 5), (False, False))
61+
self.assertEqual(qma.isValidAction(9, 5), (True, True))
5362

5463
#One action test
55-
self.assertEqual(qma.isValidAction(0, 4), (True, True))
56-
self.assertEqual(qma.isValidAction(9, 4), (True, True))
57-
self.assertEqual(qma.isValidAction(27, 4), (False, True))
64+
self.assertEqual(qma.isValidAction(0, 6), (True, True))
65+
self.assertEqual(qma.isValidAction(9, 6), (True, True))
66+
self.assertEqual(qma.isValidAction(27, 6), (False, True))
5867

5968
#Invalid action
6069
with self.assertRaises(ValueError):

test_modules/test_triangular_mesh_analysis.py

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import unittest
22

33
from mesh_model.mesh_struct.mesh import Mesh
4-
from mesh_model.mesh_struct.mesh_elements import Dart
4+
from mesh_model.mesh_struct.mesh_elements import Dart, Node
55
from mesh_model.mesh_analysis.trimesh_analysis import TriMeshQualityAnalysis, TriMeshOldAnalysis
66
from environment.actions.triangular_actions import split_edge_ids
77
from view.mesh_plotter.mesh_plots import plot_mesh
@@ -155,6 +155,42 @@ def test_isTruncated(self):
155155
darts_list.append(d_info[0])
156156
self.assertFalse(m_analysis.isTruncated(darts_list))
157157

158+
def test_get_geometric_quality(self):
159+
nodes = [[0.0, 0.0], [1.0, 0.0], [1.0, 1.0], [0.0, 1.0], [2.0, 0.0]]
160+
faces = [[0, 1, 2], [0, 2, 3], [1, 4, 2], [0, 1, 4], [0, 4, 1]]
161+
cmap = Mesh(nodes, faces)
162+
plot_mesh(cmap)
163+
m_analysis = TriMeshQualityAnalysis(cmap)
164+
165+
# Half flat
166+
d_to_test = Dart(cmap, 0)
167+
self.assertEqual(m_analysis.get_dart_geometric_quality(d_to_test), 4)
168+
169+
# Full flat
170+
d_to_test = Dart(cmap, 11)
171+
self.assertEqual(m_analysis.get_dart_geometric_quality(d_to_test), 6)
172+
173+
nodes = [[0.0, 0.0], [1.0, 0.0], [1.0, 1.0], [0.0, 1.0]]
174+
faces = [[0, 1, 2], [2, 1, 3]]
175+
cmap = Mesh(nodes, faces)
176+
plot_mesh(cmap)
177+
m_analysis = TriMeshQualityAnalysis(cmap)
178+
179+
# Crossed
180+
d_to_test = Dart(cmap, 1)
181+
self.assertEqual(m_analysis.get_dart_geometric_quality(d_to_test), 3)
182+
183+
def test_find_star_vertex(self):
184+
# Polygon with ker
185+
nodes = [[0.0, 0.0], [1.0, 1.0], [1.0, -1.0], [0.0, -2.0], [-1.0, 0.0], [-0.5, 0.5], [-0.25, -0.25]]
186+
faces = [[0, 2, 1], [0, 3, 2], [0, 4, 3], [0, 5, 4], [0, 1, 5]]
187+
cmap = Mesh(nodes, faces)
188+
plot_mesh(cmap)
189+
m_analysis = TriMeshQualityAnalysis(cmap)
190+
n_to_test = Node(cmap, 0)
191+
self.assertTrue(m_analysis.find_star_vertex(n_to_test)[0])
192+
193+
158194
class TestMeshOldAnalysis(unittest.TestCase):
159195

160196
def test_mesh_regular_score(self):

0 commit comments

Comments
 (0)