Salome HOME
simplification
[modules/smesh.git] / src / Tools / blocFissure / gmu / identifieEdgesPeau_a.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 """Identification précise des edges et disques des faces de peau selon index extremité fissure"""
21
22 import logging
23
24 from . import initLog
25
26 from .geomsmesh import geompy
27 from .geomsmesh import geomPublish
28 from .geomsmesh import geomPublishInFather
29
30 def identifieEdgesPeau_a(edgesFissExtPipe, facePeau, facesPeauSorted, edgesPeauFondIn, \
31                          endsEdgeFond, facesPipePeau, edgeRadFacePipePeau, edgesListees, \
32                         nro_cas=None):
33   """Identification précise des edges et disques des faces de peau selon index extremité fissure"""
34   logging.info('start')
35
36   for face in facesPeauSorted[:-1]: # la ou les faces débouchantes, pas la grande face de peau
37     logging.debug("examen face debouchante circulaire")
38     for i_aux,efep in enumerate(edgesFissExtPipe):
39       dist = geompy.MinDistance(face, efep)
40       logging.debug("  distance face circulaire edge %s", dist)
41       if dist < 1e-3:
42         for j_aux, edpfi in enumerate(edgesPeauFondIn):
43           if geompy.MinDistance(face, edpfi) < 1e-3:
44             j_aux_0 = j_aux
45             break
46         sharedVertices = geompy.GetSharedShapesMulti([face, edgesPeauFondIn[j_aux_0]], geompy.ShapeType["VERTEX"])
47         nameFace = "facePipePeau{}".format(i_aux)
48         nameVert = "endEdgeFond{}".format(i_aux)
49         nameEdge = "edgeRadFacePipePeau{}".format(i_aux)
50         facesPipePeau[i_aux] = face
51         endsEdgeFond[i_aux] = sharedVertices[0]
52         geomPublish(initLog.debug, face, nameFace, nro_cas)
53         geomPublish(initLog.debug, sharedVertices[0], nameVert, nro_cas)
54         edgesFace = geompy.ExtractShapes(face, geompy.ShapeType["EDGE"], True)
55         for edge in edgesFace:
56           if geompy.MinDistance(edge, sharedVertices[0]) < 1e-3:
57             edgeRadFacePipePeau[i_aux] = edge
58             geomPublish(initLog.debug, edge, nameEdge, nro_cas)
59             break
60
61   # --- edges circulaires de la face de peau et points de jonction de la face externe de fissure
62   logging.debug("facesPipePeau: %s", facesPipePeau)
63   edgesCircPeau = [None for _ in range(len(facesPipePeau))]
64   verticesCircPeau = [None for _ in range(len(facesPipePeau))]
65   for i_aux,fcirc in enumerate(facesPipePeau):
66     edges = geompy.GetSharedShapesMulti([facePeau, fcirc], geompy.ShapeType["EDGE"])
67     grpEdgesCirc = geompy.CreateGroup(facePeau, geompy.ShapeType["EDGE"])
68     geompy.UnionList(grpEdgesCirc, edges)
69     edgesCircPeau[i_aux] = grpEdgesCirc
70     name = "edgeCirc{}".format(i_aux)
71     geomPublishInFather(initLog.always, facePeau, grpEdgesCirc, name)
72     edgesListees = edgesListees + edges
73     vertices = geompy.GetSharedShapesMulti([facePeau, fcirc], geompy.ShapeType["VERTEX"])
74     grpVertCircPeau = geompy.CreateGroup(facePeau, geompy.ShapeType["VERTEX"])
75     geompy.UnionList(grpVertCircPeau, vertices)
76     verticesCircPeau[i_aux] = grpVertCircPeau
77     name = "pointEdgeCirc{}".format(i_aux)
78     geomPublishInFather(initLog.debug, facePeau, grpVertCircPeau, name)
79
80   return edgesCircPeau, verticesCircPeau