Salome HOME
Update of CheckDone
[modules/smesh.git] / src / Tools / blocFissure / gmu / construitEdgesRadialesDebouchantes_c.py
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2021  EDF R&D
3 #
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
8 #
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 # Lesser General Public License for more details.
13 #
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20 """Construction des listes d'edges radiales sur chaque extrémité débouchante"""
21
22 import logging
23
24 from .geomsmesh import geompy
25 from .geomsmesh import geomPublish
26
27 from . import initLog
28
29 from .sortEdges import sortEdges
30
31 def construitEdgesRadialesDebouchantes_c(facesPipePeau, edgeRadFacePipePeau, \
32                                          listNappes, idFacesDebouchantes):
33   """Construction des listes d'edges radiales sur chaque extrémité débouchante"""
34   logging.info('start')
35   listEdges = list()
36   for n_nappe, nappes in enumerate(listNappes):
37     ifd = idFacesDebouchantes[n_nappe] # indice de face débouchante (facesPipePeau)
38     if ifd < 0:
39       listEdges.append([])
40     else:
41       face = facesPipePeau[ifd]
42       edges = [edgeRadFacePipePeau[ifd]]
43       for n_nappe, nappe in enumerate(nappes):
44         if n_nappe > 0:
45           obj = geompy.MakeSection(face, nappe) # normalement une edge, parfois un compound d'edges dont un tout petit
46           edge = obj
47
48           l_shapes = geompy.ExtractShapes(obj, geompy.ShapeType["VERTEX"], False)
49           if len(l_shapes) > 2:
50             eds = geompy.ExtractShapes(obj, geompy.ShapeType["EDGE"], False)
51             [edsorted, _, maxl] = sortEdges(eds)
52             edge = edsorted[-1]
53           else:
54             maxl = geompy.BasicProperties(edge)[0]
55
56           if maxl < 0.01: # problème MakeSection
57             logging.info("problème MakeSection recherche edge radiale %s, longueur trop faible: %s, utilisation partition", n_nappe, maxl)
58             partNappeFace = geompy.MakePartition([face, nappe], [] , [], [], geompy.ShapeType["FACE"], 0, [], 0)
59             l_shapes= geompy.ExtractShapes(partNappeFace, geompy.ShapeType["EDGE"], False)
60             l_nouv_edges = list()
61             for shape in l_shapes:
62               dmax=100.
63               l_vertex = geompy.ExtractShapes(shape, geompy.ShapeType["VERTEX"], False)
64               distx = [geompy.MinDistance(vertex, face) for vertex in l_vertex]
65               distx += [geompy.MinDistance(vertex, nappe) for vertex in l_vertex]
66               dmax = max(distx)
67               lgedge = geompy.BasicProperties(shape)[0]
68               logging.debug("  dmax %s, longueur edge %s",dmax, lgedge)
69               if dmax < 0.01 and  lgedge > 0.01:
70                 l_nouv_edges.append(shape)
71
72             if l_nouv_edges:
73               logging.debug("  edges issues de la partition: %s", l_nouv_edges)
74               for num, edge in enumerate(l_nouv_edges):
75                 geomPublish(initLog.debug, edge, "l_nouv_edges%d"%num)
76               [edsorted, _, maxl] = sortEdges(l_nouv_edges)
77               logging.debug("  longueur edge trouvée: %s", maxl)
78               edge = edsorted[-1]
79             else:
80               logging.info("problème partition recherche edge radiale %s", n_nappe)
81               l_vertex = geompy.ExtractShapes(partNappeFace, geompy.ShapeType["VERTEX"], False)
82               l_vertexnouv= list()
83               for vertex in l_vertex:
84                 distx = geompy.MinDistance(vertex, face)
85                 distx += geompy.MinDistance(vertex, nappe)
86                 logging.debug("vertex distance: %s", distx)
87                 if distx < 0.005:
88                   l_vertexnouv.append(vertex)
89               logging.debug("nombre vertex candidats %s", len(l_vertexnouv))
90               if len(l_vertexnouv) >= 2:
91                 l_edges = [geompy.MakeEdge(l_vertexnouv[j],l_vertexnouv[(j+1)%len(l_vertexnouv)]) for j in range(len(l_vertexnouv))]
92                 [edsorted2, _, maxl] = sortEdges(l_edges)
93                 edge = edsorted2[-1]
94                 logging.debug("lg edge: %s", maxl)
95               else:
96                 logging.debug("problème recherche edge radiale %s non résolu", n_nappe)
97           edges.append(edge)
98           name = 'edgeEndPipe%d'%n_nappe
99           geomPublish(initLog.debug, edge, name)
100       listEdges.append(edges)
101
102   return listEdges