@@ -56,105 +56,6 @@ def set_scores(self) -> None:
5656 n .set_score (s )
5757 i += 1
5858
59- def set_geometric_quality (self ) -> None :
60- for d_info in self .mesh .active_darts ():
61- d_id = d_info [0 ]
62- d = Dart (self .mesh , d_id )
63- d .set_quality (self .get_dart_geometric_quality (d ))
64-
65- def get_dart_geometric_quality (self , d : Dart , m = None ) -> int :
66- """
67- Calculate the geometric quality of the surrounding of a dart and his twin dart.
68- * quality = -1: boundary dart
69- * quality = 0: convex quad
70- * quality = 1: concave quad
71- * quality = 2: triangular quad
72- * quality = 3: crossed quad
73- * quality = 4: half flat concave quad
74- * quality = 6: flat quad
75- * quality = 5: one adjacent triangular face is flat
76-
77- :param d: dart
78- :return: geometric quality
79- """
80- if d .get_beta (2 ) is None :
81- return - 1 # boundary dart
82-
83- d2 , d1 , d11 , d21 , d211 , A , B , C , D = self .mesh .active_triangles (d )
84-
85- u1 = np .array ([B .x () - A .x (), B .y () - A .y ()]) # d vector (unused)
86- u2 = np .array ([C .x () - B .x (), C .y () - B .y ()]) # vect(BC)
87- u3 = np .array ([A .x () - C .x (), A .y () - C .y ()]) # vect(CA)
88- u4 = np .array ([D .x () - A .x (), D .y () - A .y ()]) # vect(AD)
89- u5 = np .array ([B .x () - D .x (), B .y () - D .y ()]) # vect(DB)
90-
91- # Checking for near-zero vectors (close to (0,0))
92- if (np .linalg .norm (u2 ) < 1e-8 or
93- np .linalg .norm (u3 ) < 1e-8 or
94- np .linalg .norm (u4 ) < 1e-8 or
95- np .linalg .norm (u5 ) < 1e-8 ):
96- raise ValueError ("near zero vector" ) # Quad invalid because one side is almost zero
97-
98- # Calculate cross product at each node
99- cp_A = self .cross_product (- 1 * u3 , u4 )
100- cp_D = self .cross_product (- 1 * u4 , u5 )
101- cp_B = self .cross_product (- 1 * u5 , u2 )
102- cp_C = self .cross_product (- 1 * u2 , u3 )
103-
104- # Counts how many angles are oriented clockwise. If the angle is clockwise oriented, signe(cp) return 1
105- sum_cp = self .signe (cp_A ) + self .signe (cp_B ) + self .signe (cp_C ) + self .signe (cp_D )
106-
107-
108- zero_count = sum (- 1e-8 < cp < 1e-8 for cp in [cp_A , cp_B , cp_C , cp_D ])
109-
110- if zero_count == 0 : # not angles of 180° or 360° / no coolinear vectors
111- if sum_cp == 0 :
112- return 0 #convexe
113- elif sum_cp == 1 :
114- return 1 # concave
115- elif sum_cp == 2 :
116- return 3 # crossed
117- elif zero_count == 1 :
118- if sum_cp == 0 :
119- return 2 # triangular quad
120- elif sum_cp == 1 :
121- print (cp_A , cp_B , cp_C , cp_D )
122- return 4 # half_face_flat
123- elif sum_cp == 2 :
124- return 5 # half face flat
125- elif zero_count >= 2 :
126- return 6 # full flat face
127- else :
128- raise ValueError ("Quality configuration doesn't exist" )
129-
130- def get_adjacent_faces (self , n : Node , d_from : Dart , d_to : Dart ) -> list :
131- adj_faces = []
132- d2 = d_from
133- d = None if d2 is None else d_from .get_beta (1 )
134- while d != d_to :
135- if d2 is None and d_to is not None :
136- # chercher dans l'autre sens
137- d = d_to
138- adj_faces .append (d .get_face ())
139- d1 = d .get_beta (1 )
140- d11 = d1 .get_beta (1 )
141- d = d11 .get_beta (2 )
142- while d is not None :
143- adj_faces .append (d .get_face ())
144- d1 = d .get_beta (1 )
145- d11 = d1 .get_beta (1 )
146- d = d11 .get_beta (2 )
147- break
148- elif d2 is None and d_to is None :
149- break
150- elif d2 is not None :
151- d = d2 .get_beta (1 )
152- adj_faces .append (d .get_face ())
153- d2 = d .get_beta (2 )
154- else :
155- break
156- return adj_faces
157-
15859class QuadMeshOldAnalysis (QuadMeshAnalysis ):
15960 """
16061 Quadmesh old analysis
0 commit comments