Salome HOME
Copyright update 2022
[modules/smesh.git] / src / Tools / blocFissure / gmu / identifieElementsFissure.py
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2022  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 edges fond de fissure, edges pipe sur la face de fissure,
21 edges prolongées
22 edges internes communes pipe et fissure, points communs edges fissure peau et edges circulaires
23 """
24
25 import logging
26
27 from . import initLog
28
29 from .geomsmesh import geompy
30 from .geomsmesh import geomPublishInFather
31
32 from .extractionOrientee import extractionOrientee
33 from .extractionOrienteeMulti import extractionOrienteeMulti
34
35 def identifieElementsFissure(ifil, facesDefaut, partitionPeauFissFond,
36                              edgesPipeFiss, edgesFondFiss, aretesVivesC,
37                              fillingFaceExterne, centreFondFiss):
38   """
39   # -----------------------------------------------------------------------
40   # --- identification edges fond de fissure, edges pipe sur la face de fissure,
41   #     edges prolongées
42   #     edges internes communes pipe et fissure, points communs edges fissure peau et edges circulaires
43   """
44
45   logging.info('start')
46
47   edgesPipeC = geompy.GetInPlace(partitionPeauFissFond, geompy.MakeCompound(edgesPipeFiss))
48   geomPublishInFather(initLog.debug, partitionPeauFissFond, edgesPipeC, "edgesPipeFiss")
49   edgesFondC = geompy.GetInPlace(partitionPeauFissFond, geompy.MakeCompound(edgesFondFiss))
50   geomPublishInFather(initLog.debug, partitionPeauFissFond, edgesFondC, "edgesFondFiss")
51
52   if aretesVivesC is None:
53     [edgesInside, _, _] = extractionOrientee(fillingFaceExterne, partitionPeauFissFond, centreFondFiss, "EDGE", 1.e-3)
54     [facesInside, _, facesOnside] = extractionOrientee(fillingFaceExterne, partitionPeauFissFond, centreFondFiss, "FACE", 1.e-3)
55   else:
56     [edgesInside, _, _] = extractionOrienteeMulti(facesDefaut, ifil, partitionPeauFissFond, centreFondFiss, "EDGE", 1.e-3)
57     [facesInside, _, facesOnside] = extractionOrienteeMulti(facesDefaut, ifil, partitionPeauFissFond, centreFondFiss, "FACE", 1.e-3)
58
59   edgesPipeIn = geompy.GetSharedShapesMulti([edgesPipeC, geompy.MakeCompound(edgesInside)], geompy.ShapeType["EDGE"])
60   verticesPipePeau = list()
61
62   for i_aux, edge in enumerate(edgesPipeIn):
63     try:
64       vertices = geompy.GetSharedShapesMulti([edge, geompy.MakeCompound(facesOnside)], geompy.ShapeType["VERTEX"])
65       verticesPipePeau.append(vertices[0])
66       name = "edgePipeIn{}".format(i_aux)
67       geomPublishInFather(initLog.debug, partitionPeauFissFond, edge, name)
68       name = "verticePipePeau{}".format(i_aux)
69       geomPublishInFather(initLog.debug, partitionPeauFissFond, vertices[0], name)
70       logging.debug("edgePipeIn%s coupe les faces OnSide", i_aux)
71     except:
72       logging.debug("edgePipeIn%s ne coupe pas les faces OnSide", i_aux)
73
74   edgesFondIn = list()
75   if verticesPipePeau: # au moins une extrémité du pipe sur cette face de peau
76     tmp = geompy.GetSharedShapesMulti([edgesFondC, geompy.MakeCompound(edgesInside)], geompy.ShapeType["EDGE"])
77     edgesFondIn = [ ed for ed in tmp if geompy.MinDistance(ed, geompy.MakeCompound(facesOnside)) < 1.e-3]
78
79   return (edgesPipeIn, verticesPipePeau, edgesFondIn, facesInside, facesOnside)