@@ -398,80 +398,80 @@ def is_star_vertex2(self, n1:Node, n2:Node, v):
398398 return False
399399 return True
400400
401- def find_star_vertex2 (self , n1 :Node , n2 :Node ) -> (float , float ):
402- adj_nodes = []
403- nodes_coord = []
404- for d_info in self .mesh .active_darts ():
405- if d_info [3 ] == n1 .id or d_info [3 ] == n2 .id :
406- d2 = Dart (self .mesh , d_info [2 ])
407- if d2 is not None :
408- n = d2 .get_node ()
409- adj_nodes .append (n )
410- nodes_coord .append ([n .x (), n .y ()])
411- else :
412- raise ValueError ("Collapse action may not be done near boundary" )
413- nodes_coord = np .array (nodes_coord )
414-
415- # Ordonner les voisins autour de v
416- vectors = nodes_coord - v
417- angles = np .arctan2 (vectors [:, 1 ], vectors [:, 0 ])
418- order = np .argsort (angles )
419- neighbors_ordered = nodes_coord [order ]
420-
421- hull = ConvexHull (nodes_coord )
422- delaunay = Delaunay (nodes_coord )
423- plt .plot (nodes_coord [:, 0 ], nodes_coord [:, 1 ], 'o' )
424-
425- for simplex in hull .simplices :
426- plt .plot (nodes_coord [simplex , 0 ], nodes_coord [simplex , 1 ], 'k-' )
427- plt .plot (nodes_coord [hull .vertices , 0 ], nodes_coord [hull .vertices , 1 ], 'r--' , lw = 2 )
428- plt .plot (nodes_coord [hull .vertices [0 ], 0 ], nodes_coord [hull .vertices [0 ], 1 ], 'ro' )
429- plt .show ()
430-
431- _ = scipy .spatial .delaunay_plot_2d (delaunay )
432- plt .show ()
433-
434- mid = np .array ([(n1 .x () + n2 .x ()) / 2 , (n1 .y () + n2 .y ()) / 2 ])
435- is_star_vertex = delaunay .find_simplex (mid ) >= 0
436-
437- # Calcul des angles des voisins autour de v
438- vectors = nodes_coord - mid
439- angles = np .arctan2 (vectors [:, 1 ], vectors [:, 0 ])
440- order = np .argsort (angles )
441- neighbors_ordered = nodes_coord [order ]
442-
443- # Construire le polygone
444- poly = Polygon (neighbors_ordered )
445-
446- # Vérifier si v est à l'intérieur ou sur la frontière
447- point_v = Point (mid )
448- is_star = poly .contains (point_v ) or poly .touches (point_v )
449-
450- plt .figure (figsize = (6 , 6 ))
451- # Polygone
452- x , y = poly .exterior .xy
453- plt .fill (x , y , alpha = 0.3 , edgecolor = 'red' , facecolor = 'lightcoral' , label = 'Polygone formé par les voisins' )
454-
455- # Voisins
456- plt .scatter (nodes_coord [:, 0 ], nodes_coord [:, 1 ], color = 'blue' , zorder = 5 , label = 'Voisins' )
457-
458- # Sommet testé
459- plt .scatter (mid [0 ], mid [1 ], color = 'green' , s = 100 , zorder = 5 , label = 'Sommet testé' )
460-
461- plt .legend ()
462- plt .gca ().set_aspect ('equal' )
463- plt .title (f"Le sommet est-il étoilé ? { is_star } " )
464- plt .show ()
465-
466- if is_star :
467- return mid
468- elif poly .contains (Point (n1 .x (), n1 .y ())) or poly .touches (Point (n1 .x (), n1 .y ())):
469- return n1 .x (), n1 .y ()
470- elif poly .contains (Point (n2 .x (), n2 .y ())) or poly .touches (Point (n2 .x (), n2 .y ())):
471- return n2 .x (), n2 .y ()
472- else :
473- plot_mesh (self .mesh )
474- raise ValueError ("No star vertex was found" )
401+ # def find_star_vertex2(self, n1:Node, n2:Node) -> (float, float):
402+ # adj_nodes = []
403+ # nodes_coord = []
404+ # for d_info in self.mesh.active_darts():
405+ # if d_info[3] == n1.id or d_info[3] == n2.id:
406+ # d2 = Dart(self.mesh, d_info[2])
407+ # if d2 is not None:
408+ # n = d2.get_node()
409+ # adj_nodes.append(n)
410+ # nodes_coord.append([n.x(), n.y()])
411+ # else:
412+ # raise ValueError("Collapse action may not be done near boundary")
413+ # nodes_coord = np.array(nodes_coord)
414+ #
415+ # # Ordonner les voisins autour de v
416+ # vectors = nodes_coord - v
417+ # angles = np.arctan2(vectors[:, 1], vectors[:, 0])
418+ # order = np.argsort(angles)
419+ # neighbors_ordered = nodes_coord[order]
420+ #
421+ # hull = ConvexHull(nodes_coord)
422+ # delaunay = Delaunay(nodes_coord)
423+ # plt.plot(nodes_coord[:, 0], nodes_coord[:, 1], 'o')
424+ #
425+ # for simplex in hull.simplices:
426+ # plt.plot(nodes_coord[simplex, 0], nodes_coord[simplex, 1], 'k-')
427+ # plt.plot(nodes_coord[hull.vertices, 0], nodes_coord[hull.vertices, 1], 'r--', lw=2)
428+ # plt.plot(nodes_coord[hull.vertices[0], 0], nodes_coord[hull.vertices[0], 1], 'ro')
429+ # plt.show()
430+ #
431+ # _ = scipy.spatial.delaunay_plot_2d(delaunay)
432+ # plt.show()
433+ #
434+ # mid = np.array([(n1.x() + n2.x()) / 2, (n1.y() + n2.y()) / 2])
435+ # is_star_vertex = delaunay.find_simplex(mid) >=0
436+ #
437+ # # Calcul des angles des voisins autour de v
438+ # vectors = nodes_coord - mid
439+ # angles = np.arctan2(vectors[:, 1], vectors[:, 0])
440+ # order = np.argsort(angles)
441+ # neighbors_ordered = nodes_coord[order]
442+ #
443+ # # Construire le polygone
444+ # poly = Polygon(neighbors_ordered)
445+ #
446+ # # Vérifier si v est à l'intérieur ou sur la frontière
447+ # point_v = Point(mid)
448+ # is_star = poly.contains(point_v) or poly.touches(point_v)
449+ #
450+ # plt.figure(figsize=(6, 6))
451+ # # Polygone
452+ # x, y = poly.exterior.xy
453+ # plt.fill(x, y, alpha=0.3, edgecolor='red', facecolor='lightcoral', label='Polygone formé par les voisins')
454+ #
455+ # # Voisins
456+ # plt.scatter(nodes_coord[:, 0], nodes_coord[:, 1], color='blue', zorder=5, label='Voisins')
457+ #
458+ # # Sommet testé
459+ # plt.scatter(mid[0], mid[1], color='green', s=100, zorder=5, label='Sommet testé')
460+ #
461+ # plt.legend()
462+ # plt.gca().set_aspect('equal')
463+ # plt.title(f"Le sommet est-il étoilé ? {is_star}")
464+ # plt.show()
465+ #
466+ # if is_star:
467+ # return mid
468+ # elif poly.contains(Point(n1.x(), n1.y())) or poly.touches(Point(n1.x(), n1.y())):
469+ # return n1.x(), n1.y()
470+ # elif poly.contains(Point(n2.x(), n2.y())) or poly.touches(Point(n2.x(), n2.y())):
471+ # return n2.x(), n2.y()
472+ # else:
473+ # plot_mesh(self.mesh)
474+ # raise ValueError("No star vertex was found")
475475
476476
477477 def get_adjacent_faces (self , n : Node , d_from : Dart , d_to : Dart ) -> list :
0 commit comments