Salome HOME
Merge branch 'V9_9_BR'
[modules/smesh.git] / src / Tools / blocFissure / gmu / creeZoneDefautDansObjetSain.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 """TODO: a compléter"""
21
22 import os
23
24 import logging
25
26 from .geomsmesh import smesh
27
28 from .creeZoneDefautMaillage import creeZoneDefautMaillage
29 from .peauInterne import peauInterne
30 from .quadranglesToShapeNoCorner import quadranglesToShapeNoCorner
31 from .creeZoneDefautFilling import creeZoneDefautFilling
32 from .creeZoneDefautGeom import creeZoneDefautGeom
33 from .getCentreFondFiss import getCentreFondFiss
34 from .putName import putName
35
36 def creeZoneDefautDansObjetSain(geometriesSaines, maillagesSains, shapesFissure, \
37                                 shapeFissureParams, maillageFissureParams, \
38                                 nro_cas=None):
39   """
40   #TODO: a compléter
41   """
42   logging.info('start')
43
44   geometrieSaine      = geometriesSaines[0]
45   maillageSain        = maillagesSains[0]
46   isHexa              = maillagesSains[1]
47   shapeDefaut         = shapesFissure[0]
48   tailleDefaut        = shapesFissure[2]
49   coordsNoeudsFissure = shapesFissure[3]
50
51   isElliptique = False
52   if 'elliptique' in shapeFissureParams:
53     isElliptique      = shapeFissureParams['elliptique']
54   if isElliptique:
55     if 'demiGrandAxe' in shapeFissureParams:
56       demiGrandAxe    = shapeFissureParams['demiGrandAxe']
57     else:
58       demiGrandAxe    = shapeFissureParams['longueur']
59     lgExtrusion = 2.0*demiGrandAxe
60   else:
61     lgExtrusion = 50.
62
63   nomRep              = maillageFissureParams['nomRep']
64   nomFicSain          = maillageFissureParams['nomFicSain']
65
66   fichierMaillageSain = os.path.join (nomRep , '{}.med'.format(nomFicSain))
67
68   # --- centre de fond de fissure et tangente
69
70   edgeFondExt, centreFondFiss, tgtCentre = getCentreFondFiss(shapesFissure)
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                 nro_cas)
83
84   facesDefaut = list()
85   centresDefaut = list()
86   normalsDefaut = list()
87   extrusionsDefaut = list()
88   isPlane = False
89   if isHexa and not isPlane:
90     meshQuad =  smesh.CopyMesh( zoneDefaut_skin, 'meshQuad', 0, 0)
91     putName(meshQuad, "meshQuad", i_pref=nro_cas)
92
93     fillings, _, bordsPartages, fillconts, idFilToCont = quadranglesToShapeNoCorner(meshQuad, shapeFissureParams, centreFondFiss)
94
95     for filling in fillings:
96       [faceDefaut, centreDefaut, normalDefaut, extrusionDefaut] = \
97         creeZoneDefautFilling(filling, shapeDefaut, lgExtrusion)
98       facesDefaut.append(faceDefaut)
99       centresDefaut.append(centreDefaut)
100       normalsDefaut.append(normalDefaut)
101       extrusionsDefaut.append(extrusionDefaut)
102   else:
103     [facesDefaut, centreDefaut, normalDefaut, extrusionDefaut] = \
104       creeZoneDefautGeom( geometrieSaine, shapeDefaut, origShapes, verticesShapes, lgExtrusion)
105     bordsPartages = list()
106     for _ in facesDefaut:
107       bordsPartages.append([None,None]) # TODO : traitement des arêtes vives ?
108     fillconts = facesDefaut
109     idFilToCont = list(range(len(facesDefaut)))
110
111   return [facesDefaut, centresDefaut, normalsDefaut, extrusionsDefaut, \
112           dmoyen, bordsPartages, fillconts, idFilToCont, \
113           maillageSain, internalBoundary, \
114           zoneDefaut, zoneDefaut_skin, zoneDefaut_internalFaces, zoneDefaut_internalEdges, \
115           edgeFondExt, centreFondFiss, tgtCentre]