1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2021 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"""
25 from .geomsmesh import geompy
26 from .geomsmesh import geomPublish
28 from .sortEdges import sortEdges
30 def construitEdgesRadialesDebouchantes_c(facesPipePeau, edgeRadFacePipePeau, \
31 listNappes, idFacesDebouchantes):
32 """Construction des listes d'edges radiales sur chaque extrémité débouchante"""
35 for n_nappe, nappes in enumerate(listNappes):
36 ifd = idFacesDebouchantes[n_nappe] # indice de face débouchante (facesPipePeau)
40 face = facesPipePeau[ifd]
41 edges = [edgeRadFacePipePeau[ifd]]
42 for n_nappe, nappe in enumerate(nappes):
44 obj = geompy.MakeSection(face, nappe) # normalement une edge, parfois un compound d'edges dont un tout petit
47 l_shapes = geompy.ExtractShapes(obj, geompy.ShapeType["VERTEX"], False)
49 eds = geompy.ExtractShapes(obj, geompy.ShapeType["EDGE"], False)
50 [edsorted, _, maxl] = sortEdges(eds)
53 maxl = geompy.BasicProperties(edge)[0]
55 if maxl < 0.01: # problème MakeSection
56 logging.info("problème MakeSection recherche edge radiale %s, longueur trop faible: %s, utilisation partition", n_nappe, maxl)
57 partNappeFace = geompy.MakePartition([face, nappe], [] , [], [], geompy.ShapeType["FACE"], 0, [], 0)
58 l_shapes= geompy.ExtractShapes(partNappeFace, geompy.ShapeType["EDGE"], False)
60 for shape in l_shapes:
62 l_vertex = geompy.ExtractShapes(shape, geompy.ShapeType["VERTEX"], False)
63 distx = [geompy.MinDistance(vertex, face) for vertex in l_vertex]
64 distx += [geompy.MinDistance(vertex, nappe) for vertex in l_vertex]
66 lgedge = geompy.BasicProperties(shape)[0]
67 logging.debug(" dmax %s, longueur edge %s",dmax, lgedge)
68 if dmax < 0.01 and lgedge > 0.01:
69 l_nouv_edges.append(shape)
72 logging.debug(" edges issues de la partition: %s", l_nouv_edges)
73 for num, edge in enumerate(l_nouv_edges):
74 geomPublish(initLog.debug, edge, "l_nouv_edges%d"%num)
75 [edsorted, _, maxl] = sortEdges(l_nouv_edges)
76 logging.debug(" longueur edge trouvée: %s", maxl)
79 logging.info("problème partition recherche edge radiale %s", n_nappe)
80 l_vertex = geompy.ExtractShapes(partNappeFace, geompy.ShapeType["VERTEX"], False)
82 for vertex in l_vertex:
83 distx = geompy.MinDistance(vertex, face)
84 distx += geompy.MinDistance(vertex, nappe)
85 logging.debug("vertex distance: %s", distx)
87 l_vertexnouv.append(vertex)
88 logging.debug("nombre vertex candidats %s", len(l_vertexnouv))
89 if len(l_vertexnouv) >= 2:
90 l_edges = [geompy.MakeEdge(l_vertexnouv[j],l_vertexnouv[(j+1)%len(l_vertexnouv)]) for j in range(len(l_vertexnouv))]
91 [edsorted2, _, maxl] = sortEdges(l_edges)
93 logging.debug("lg edge: %s", maxl)
95 logging.debug("problème recherche edge radiale %s non résolu", n_nappe)
97 name = 'edgeEndPipe%d'%n_nappe
98 geomPublish(initLog.debug, edge, name)
99 listEdges.append(edges)