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