1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2023 EDF R&D
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.
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.
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
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 """Construction des listes d'edges radiales sur chaque extrémité débouchante"""
24 from .geomsmesh import geompy
25 from .geomsmesh import geomPublish
29 from .sortEdges import sortEdges
31 def construitEdgesRadialesDebouchantes_c(facesPipePeau, edgeRadFacePipePeau, \
32 listNappes, idFacesDebouchantes):
33 """Construction des listes d'edges radiales sur chaque extrémité débouchante"""
36 for n_nappe, nappes in enumerate(listNappes):
37 ifd = idFacesDebouchantes[n_nappe] # indice de face débouchante (facesPipePeau)
41 face = facesPipePeau[ifd]
42 edges = [edgeRadFacePipePeau[ifd]]
43 for n_nappe, nappe in enumerate(nappes):
45 obj = geompy.MakeSection(face, nappe) # normalement une edge, parfois un compound d'edges dont un tout petit
48 l_shapes = geompy.ExtractShapes(obj, geompy.ShapeType["VERTEX"], False)
50 eds = geompy.ExtractShapes(obj, geompy.ShapeType["EDGE"], False)
51 [edsorted, _, maxl] = sortEdges(eds)
54 maxl = geompy.BasicProperties(edge)[0]
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)
61 for shape in l_shapes:
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]
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)
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)
80 logging.info("problème partition recherche edge radiale %s", n_nappe)
81 l_vertex = geompy.ExtractShapes(partNappeFace, geompy.ShapeType["VERTEX"], False)
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)
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)
94 logging.debug("lg edge: %s", maxl)
96 logging.debug("problème recherche edge radiale %s non résolu", n_nappe)
98 name = 'edgeEndPipe%d'%n_nappe
99 geomPublish(initLog.debug, edge, name)
100 listEdges.append(edges)