Salome HOME
Build under Windows.
[modules/smesh.git] / src / Tools / blocFissure / gmu / creeZoneDefautDansObjetSain.py
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2020  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 from .geomsmesh import smesh
23 import SMESH
24 import SALOMEDS
25
26 from .creeZoneDefautMaillage import creeZoneDefautMaillage
27 from .peauInterne import peauInterne
28 from .quadranglesToShapeNoCorner import quadranglesToShapeNoCorner
29 from .creeZoneDefautFilling import creeZoneDefautFilling
30 from .creeZoneDefautGeom import creeZoneDefautGeom
31 from .getCentreFondFiss import getCentreFondFiss
32
33 # -----------------------------------------------------------------------------
34 # ---
35
36 def creeZoneDefautDansObjetSain(geometriesSaines, maillagesSains, shapesFissure,
37                                 shapeFissureParams, maillageFissureParams):
38   """
39   #TODO: a compléter
40   """
41   logging.info('start')
42
43   geometrieSaine      = geometriesSaines[0]
44   maillageSain        = maillagesSains[0]
45   isHexa              = maillagesSains[1]
46   shapeDefaut         = shapesFissure[0]
47   tailleDefaut        = shapesFissure[2]
48   coordsNoeudsFissure = shapesFissure[3]
49
50   isElliptique = False
51   if 'elliptique' in shapeFissureParams:
52     isElliptique      = shapeFissureParams['elliptique']
53   if isElliptique:
54     if 'demiGrandAxe' in shapeFissureParams:
55       demiGrandAxe    = shapeFissureParams['demiGrandAxe']
56     else:
57       demiGrandAxe    = shapeFissureParams['longueur']
58     lgExtrusion = 2.0*demiGrandAxe
59   else:
60     lgExtrusion = 50.
61
62   nomRep              = maillageFissureParams['nomRep']
63   nomFicSain          = maillageFissureParams['nomFicSain']
64
65   fichierMaillageSain    = nomRep + '/' + nomFicSain + '.med'
66   
67   # --- centre de fond de fissure et tangente
68   
69   edgeFondExt, centreFondFiss, tgtCentre = getCentreFondFiss(shapesFissure)
70   
71
72   # --- zone de défaut
73   nomZones = "zoneDefaut"
74
75   [origShapes, verticesShapes, dmoyen] = \
76     creeZoneDefautMaillage(maillagesSains, shapeDefaut, tailleDefaut, nomZones, coordsNoeudsFissure)
77
78   maillageSain.ExportMED(fichierMaillageSain)
79   logging.debug("fichier maillage sain %s", fichierMaillageSain)
80   [maillageSain, internalBoundary, zoneDefaut, zoneDefaut_skin, zoneDefaut_internalFaces, zoneDefaut_internalEdges] = \
81     peauInterne(fichierMaillageSain, shapeDefaut, nomZones)
82
83   facesDefaut = []
84   centresDefaut = []
85   normalsDefaut =[]
86   extrusionsDefaut = []
87   isPlane = False
88   if isHexa and not isPlane:
89     meshQuad =  smesh.CopyMesh( zoneDefaut_skin, 'meshQuad', 0, 0)
90     
91     fillings, noeuds_bords, bordsPartages, fillconts, idFilToCont = quadranglesToShapeNoCorner(meshQuad, shapeFissureParams, centreFondFiss)
92     
93     for filling in fillings:
94       [faceDefaut, centreDefaut, normalDefaut, extrusionDefaut] = \
95         creeZoneDefautFilling(filling, shapeDefaut, lgExtrusion)
96       facesDefaut.append(faceDefaut)
97       centresDefaut.append(centreDefaut)
98       normalsDefaut.append(normalDefaut)
99       extrusionsDefaut.append(extrusionDefaut)
100   else:
101     [facesDefaut, centreDefaut, normalDefaut, extrusionDefaut] = \
102       creeZoneDefautGeom( geometrieSaine, shapeDefaut, origShapes, verticesShapes, dmoyen, lgExtrusion)
103     bordsPartages = []
104     for face in facesDefaut:
105       bordsPartages.append([None,None]) # TODO : traitement des arêtes vives ?
106     fillconts = facesDefaut
107     idFilToCont = list(range(len(facesDefaut)))
108
109   return [facesDefaut, centresDefaut, normalsDefaut, extrusionsDefaut, dmoyen, bordsPartages, fillconts, idFilToCont,
110           maillageSain, internalBoundary, zoneDefaut, zoneDefaut_skin, zoneDefaut_internalFaces, zoneDefaut_internalEdges,
111           edgeFondExt, centreFondFiss, tgtCentre]
112