11import numpy as np
2- from mesh_model .mesh_analysis .trimesh_analysis import TriMeshGeoAnalysis , TriMeshTopoAnalysis
3- from mesh_model .mesh_struct .mesh_elements import Dart
2+ from mesh_model .mesh_struct .mesh_elements import Dart , Node
43from mesh_model .mesh_struct .mesh import Mesh
54
65
76def get_x (m_analysis , n_darts_selected : int , deep :int , degree : bool , restricted :bool , nodes_scores : list [int ], nodes_adjacency : list [int ]):
87 mesh = m_analysis .mesh
98 if degree :
10- template , darts_id = get_template_deg (m_analysis , deep , nodes_scores , nodes_adjacency )
9+ template , darts_id = get_template_with_quality (m_analysis , deep )
1110 else :
1211 template , darts_id = get_template (m_analysis , deep , nodes_scores )
1312
@@ -48,58 +47,71 @@ def get_template(m_analysis, deep: int, nodes_scores):
4847 C = d11 .get_node ()
4948
5049 # Template niveau 1
51- template [n_darts - 1 , 0 ] = nodes_scores [ C . id ]
52- template [n_darts - 1 , 1 ] = nodes_scores [ A . id ]
53- template [n_darts - 1 , 2 ] = nodes_scores [ B . id ]
50+ template [n_darts - 1 , 0 ] = C . get_score ()
51+ template [n_darts - 1 , 1 ] = A . get_score ()
52+ template [n_darts - 1 , 2 ] = B . get_score ()
5453
5554 if deep > 3 :
5655 # template niveau 2 deep = 6
5756 n_id = m_analysis .find_template_opposite_node (d )
5857 if n_id is not None :
59- template [n_darts - 1 , 3 ] = nodes_scores [ n_id ]
58+ template [n_darts - 1 , 3 ] = n_id . get_score ()
6059 n_id = m_analysis .find_template_opposite_node (d1 )
6160 if n_id is not None :
62- template [n_darts - 1 , 4 ] = nodes_scores [ n_id ]
61+ template [n_darts - 1 , 4 ] = n_id . get_score ()
6362 n_id = m_analysis .find_template_opposite_node (d11 )
6463 if n_id is not None :
65- template [n_darts - 1 , 5 ] = nodes_scores [ n_id ]
64+ template [n_darts - 1 , 5 ] = n_id . get_score ()
6665
6766 if deep > 6 :
6867 # template niveau 3 - deep = 12
6968 d2 , d1 , d11 , d21 , d211 , n1 , n2 , n3 , n4 = m_analysis .mesh .active_triangles (d )
7069 #Triangle F2
7170 n_id = m_analysis .find_template_opposite_node (d21 )
7271 if n_id is not None :
73- template [n_darts - 1 , 6 ] = nodes_scores [ n_id ]
72+ template [n_darts - 1 , 6 ] = n_id . get_score ()
7473 n_id = m_analysis .find_template_opposite_node (d211 )
7574 if n_id is not None :
76- template [n_darts - 1 , 7 ] = nodes_scores [ n_id ]
75+ template [n_darts - 1 , 7 ] = n_id . get_score ()
7776 # Triangle T3
7877 d12 = d1 .get_beta (2 )
7978 d121 = d12 .get_beta (1 )
8079 d1211 = d121 .get_beta (1 )
8180 n_id = m_analysis .find_template_opposite_node (d121 )
8281 if n_id is not None :
83- template [n_darts - 1 , 8 ] = nodes_scores [ n_id ]
82+ template [n_darts - 1 , 8 ] = n_id . get_score ()
8483 n_id = m_analysis .find_template_opposite_node (d1211 )
8584 if n_id is not None :
86- template [n_darts - 1 , 9 ] = nodes_scores [ n_id ]
85+ template [n_darts - 1 , 9 ] = n_id . get_score ()
8786 # Triangle T4
8887 d112 = d11 .get_beta (2 )
8988 d1121 = d112 .get_beta (1 )
9089 d11211 = d1121 .get_beta (1 )
9190 n_id = m_analysis .find_template_opposite_node (d1121 )
9291 if n_id is not None :
93- template [n_darts - 1 , 10 ] = nodes_scores [ n_id ]
92+ template [n_darts - 1 , 10 ] = n_id . get_score ()
9493 n_id = m_analysis .find_template_opposite_node (d11211 )
9594 if n_id is not None :
96- template [n_darts - 1 , 11 ] = nodes_scores [ n_id ]
95+ template [n_darts - 1 , 11 ] = n_id . get_score ()
9796
9897 template = template [:n_darts , :]
9998
10099 return template , dart_ids
101100
102- def get_template_deg (m_analysis , deep : int , nodes_scores , nodes_adjacency ):
101+ def get_template_with_quality (m_analysis , deep : int ):
102+ """
103+ Create a template matrix representing the entire mesh, composed of:
104+
105+ * Node scores: i.e. the difference between ideal adjacency and actual adjacency.
106+ * Dart surrounding quality: a measure of the geometric quality around each dart.
107+
108+ Each column in the matrix corresponds to the local surrounding of a dart,
109+ including the scores of its surrounding nodes and its associated quality.
110+
111+ :param m_analysis: mesh to analyze
112+ :param deep: observation deep (how many nodes observed on each dart surrounding)
113+ :return: template matrix
114+ """
103115 size = len (m_analysis .mesh .dart_info )
104116 template = np .zeros ((size , deep * 2 ), dtype = np .int64 )
105117 dart_ids = []
@@ -117,27 +129,30 @@ def get_template_deg(m_analysis, deep: int, nodes_scores, nodes_adjacency):
117129 C = d11 .get_node ()
118130
119131 # Template niveau 1
120- template [n_darts - 1 , 0 ] = nodes_scores [ C . id ]
121- template [n_darts - 1 , deep ] = nodes_adjacency [ C . id ]
122- template [n_darts - 1 , 1 ] = nodes_scores [ A . id ]
123- template [n_darts - 1 , deep + 1 ] = nodes_adjacency [ A . id ]
124- template [n_darts - 1 , 2 ] = nodes_scores [ B . id ]
125- template [n_darts - 1 , deep + 2 ] = nodes_adjacency [ B . id ]
132+ template [n_darts - 1 , 0 ] = C . get_score ()
133+ template [n_darts - 1 , deep ] = d . get_quality ()
134+ template [n_darts - 1 , 1 ] = A . get_score ()
135+ template [n_darts - 1 , deep + 1 ] = d1 . get_quality ()
136+ template [n_darts - 1 , 2 ] = B . get_score ()
137+ template [n_darts - 1 , deep + 2 ] = d11 . get_quality ()
126138
127139 if deep > 3 :
128140 # template niveau 2
129141 n_id = m_analysis .find_template_opposite_node (d )
130142 if n_id is not None :
131- template [n_darts - 1 , 3 ] = nodes_scores [n_id ]
132- template [n_darts - 1 , deep + 3 ] = nodes_adjacency [n_id ]
143+ n = Node (m_analysis .mesh , n_id )
144+ template [n_darts - 1 , 3 ] = n .get_score ()
145+ template [n_darts - 1 , deep + 3 ] = d .get_quality () #quality around dart d is equivalent to quality around dart d2
133146 n_id = m_analysis .find_template_opposite_node (d1 )
134147 if n_id is not None :
135- template [n_darts - 1 , 4 ] = nodes_scores [n_id ]
136- template [n_darts - 1 , deep + 4 ] = nodes_adjacency [n_id ]
148+ n = Node (m_analysis .mesh , n_id )
149+ template [n_darts - 1 , 3 ] = n .get_score ()
150+ template [n_darts - 1 , deep + 4 ] = d1 .get_quality ()
137151 n_id = m_analysis .find_template_opposite_node (d11 )
138152 if n_id is not None :
139- template [n_darts - 1 , 5 ] = nodes_scores [n_id ]
140- template [n_darts - 1 , deep + 5 ] = nodes_adjacency [n_id ]
153+ n = Node (m_analysis .mesh , n_id )
154+ template [n_darts - 1 , 3 ] = n .get_score ()
155+ template [n_darts - 1 , deep + 5 ] = d11 .get_quality ()
141156
142157 if deep > 6 :
143158 # template niveau 3 - deep = 12
@@ -146,38 +161,44 @@ def get_template_deg(m_analysis, deep: int, nodes_scores, nodes_adjacency):
146161 #Triangle F2
147162 n_id = m_analysis .find_template_opposite_node (d21 )
148163 if n_id is not None :
149- template [n_darts - 1 , 6 ] = nodes_scores [n_id ]
150- template [n_darts - 1 , deep + 6 ] = nodes_adjacency [n_id ]
164+ n = Node (m_analysis .mesh , n_id )
165+ template [n_darts - 1 , 3 ] = n .get_score ()
166+ template [n_darts - 1 , deep + 6 ] = d21 .get_quality ()
151167 n_id = m_analysis .find_template_opposite_node (d211 )
152168 if n_id is not None :
153- template [n_darts - 1 , 7 ] = nodes_scores [n_id ]
154- template [n_darts - 1 , deep + 7 ] = nodes_adjacency [n_id ]
169+ n = Node (m_analysis .mesh , n_id )
170+ template [n_darts - 1 , 3 ] = n .get_score ()
171+ template [n_darts - 1 , deep + 7 ] = d211 .get_quality ()
155172 # Triangle T3
156173 d12 = d1 .get_beta (2 )
157174 if d12 is not None :
158175 d121 = d12 .get_beta (1 )
159176 d1211 = d121 .get_beta (1 )
160177 n_id = m_analysis .find_template_opposite_node (d121 )
161178 if n_id is not None :
162- template [n_darts - 1 , 8 ] = nodes_scores [n_id ]
163- template [n_darts - 1 , deep + 8 ] = nodes_adjacency [n_id ]
179+ n = Node (m_analysis .mesh , n_id )
180+ template [n_darts - 1 , 3 ] = n .get_score ()
181+ template [n_darts - 1 , deep + 8 ] = d121 .get_quality ()
164182 n_id = m_analysis .find_template_opposite_node (d1211 )
165183 if n_id is not None :
166- template [n_darts - 1 , 9 ] = nodes_scores [n_id ]
167- template [n_darts - 1 , deep + 9 ] = nodes_adjacency [n_id ]
184+ n = Node (m_analysis .mesh , n_id )
185+ template [n_darts - 1 , 3 ] = n .get_score ()
186+ template [n_darts - 1 , deep + 9 ] = d1211 .get_quality ()
168187 # Triangle T4
169188 d112 = d11 .get_beta (2 )
170189 if d112 is not None :
171190 d1121 = d112 .get_beta (1 )
172191 d11211 = d1121 .get_beta (1 )
173192 n_id = m_analysis .find_template_opposite_node (d1121 )
174193 if n_id is not None :
175- template [n_darts - 1 , 10 ] = nodes_scores [n_id ]
176- template [n_darts - 1 , deep + 10 ] = nodes_adjacency [n_id ]
194+ n = Node (m_analysis .mesh , n_id )
195+ template [n_darts - 1 , 3 ] = n .get_score ()
196+ template [n_darts - 1 , deep + 10 ] = d1121 .get_quality ()
177197 n_id = m_analysis .find_template_opposite_node (d11211 )
178198 if n_id is not None :
179- template [n_darts - 1 , 11 ] = nodes_scores [n_id ]
180- template [n_darts - 1 , deep + 11 ] = nodes_adjacency [n_id ]
199+ n = Node (m_analysis .mesh , n_id )
200+ template [n_darts - 1 , 3 ] = n .get_score ()
201+ template [n_darts - 1 , deep + 11 ] = d11211 .get_quality ()
181202
182203 template = template [:n_darts , :]
183204 return template , dart_ids
0 commit comments