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