1- from math import sqrt , degrees , radians , cos , sin , acos
21import numpy as np
32
43from mesh_model .mesh_struct .mesh_elements import Dart , Node , Face
54from mesh_model .mesh_struct .mesh import Mesh
6- from mesh_model .mesh_analysis .global_mesh_analysis import test_degree , on_boundary , get_angle_by_coord , degree , \
7- get_boundary_angle , adjacent_darts , adjacent_faces
8-
9-
10- def global_score (m : Mesh ):
11- """
12- Calculate the overall mesh score. The mesh cannot achieve a better score than the ideal one.
13- And the current score is the mesh score.
14- :param m: the mesh to be analyzed
15- :return: 4 return: a list of the nodes score, the current mesh score and the ideal mesh score, and the adjacency
16- """
17- mesh_ideal_score = 0
18- mesh_score = 0
19- nodes_score = []
20- nodes_adjacency = []
21- for i in range (len (m .nodes )):
22- if m .nodes [i , 2 ] >= 0 :
23- n_id = i
24- node = Node (m , n_id )
25- n_score , adjacency = score_calculation (node )
26- nodes_score .append (n_score )
27- nodes_adjacency .append (adjacency )
28- mesh_ideal_score += n_score
29- mesh_score += abs (n_score )
30- else :
31- nodes_score .append (0 )
32- nodes_adjacency .append (6 )
33- return nodes_score , mesh_score , mesh_ideal_score , nodes_adjacency
34-
35-
36- def score_calculation (n : Node ) -> (int , int ):
37- """
38- Function to calculate the irregularity of a node in the mesh.
39- :param n: a node in the mesh.
40- :return: the irregularity of the node
41- """
42- adjacency = degree (n )
43- if on_boundary (n ):
44- angle = get_boundary_angle (n )
45- ideal_adjacency = max (round (angle / 90 )+ 1 , 2 )
46- else :
47- ideal_adjacency = 360 / 90
48-
49- return ideal_adjacency - adjacency , adjacency
5+ from mesh_model .mesh_analysis .global_mesh_analysis import test_degree , on_boundary , adjacent_faces
506
517
528def isValidAction (mesh : Mesh , dart_id : int , action : int ) -> (bool , bool ):
@@ -271,50 +227,7 @@ def isValidQuad(A: Node, B: Node, C: Node, D: Node):
271227 return False
272228
273229 """
274- if 0 < signe (cp_A )+ signe (cp_B )+ signe (cp_C )+ signe (cp_D ) < 2 :
230+ if 0 <= signe (cp_A )+ signe (cp_B )+ signe (cp_C )+ signe (cp_D ) < 2 :
275231 return True
276232 else :
277233 return False
278-
279-
280- def orientation (p , q , r ):
281- """ Calcule l'orientation de trois points.
282- Retourne :
283- 0 si colinéaire,
284- 1 si sens anti-horaire,
285- 2 si sens horaire.
286- """
287- val = (q [1 ] - p [1 ]) * (r [0 ] - q [0 ]) - (q [0 ] - p [0 ]) * (r [1 ] - q [1 ])
288- if val == 0 :
289- return 0
290- return 1 if val > 0 else 2
291-
292- def do_intersect (p1 , q1 , p2 , q2 ):
293- """ Vérifie si les segments [p1,q1] et [p2,q2] s'intersectent """
294- o1 = orientation (p1 , q1 , p2 )
295- o2 = orientation (p1 , q1 , q2 )
296- o3 = orientation (p2 , q2 , p1 )
297- o4 = orientation (p2 , q2 , q1 )
298-
299- # Cas général : les orientations sont différentes
300- if o1 != o2 and o3 != o4 :
301- return True
302-
303- return False # Pas d'intersection
304-
305- def is_self_intersecting_quadrilateral (A , B , C , D ):
306- """ Vérifie si le quadrilatère ABCD est croisé """
307- return do_intersect (A , C , B , D ) # Vérifie l'intersection des diagonales
308-
309-
310- """
311- d12 = d1.get_beta(2)
312- d112 = d11.get_beta(2)
313- d1112 = d111.get_beta(2)
314- n7 = ((d1112.get_beta(1)).get_beta(1)).get_node()
315- n8 = ((d112.get_beta(1)).get_beta(1)).get_node()
316- n9 = (((d112.get_beta(1)).get_beta(1)).get_beta(1)).get_node()
317- n11 = ((d12.get_beta(1)).get_beta(1)).get_node()
318- n10 = mesh.add_node((n1.x() + n3.x()) / 2, (n1.y() + n3.y()) / 2)
319- topo = isValidQuad(n10, n5, n6, n2) and isValidQuad(n4, n10, n2, n3) and isValidQuad(n10, n5, n6, n2)
320- """
0 commit comments