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