Salome HOME
Update of CheckDone
[modules/smesh.git] / src / Tools / blocFissure / gmu / fusionMaillageAttributionDefaut.py
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2024  EDF
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 """Groupe de quadrangles de face transformé en face géométrique par filling
21
22 Created on Tue Jun 24 09:14:13 2014
23 @author: I48174 (Olivier HOAREAU)
24 """
25
26 import logging
27
28 import GEOM
29 import SMESH
30
31 from .geomsmesh import geompy
32 from .geomsmesh import smesh
33
34 from .listOfExtraFunctions import createNewMeshesFromCorner
35 from .listOfExtraFunctions import createLinesFromMesh
36 from .putName import putName
37
38 def fusionMaillageDefaut(maillageSain, maillageDefautCible, maillageInterneCible, \
39                          zoneDefaut_skin, shapeDefaut, listOfCorners, \
40                          nro_cas=None):
41   """Groupe de quadrangles de face transformé en face géométrique par filling"""
42
43   logging.info("start")
44   logging.info("Pour le cas n°%s", nro_cas)
45
46   facesNonCoupees = list()
47   facesCoupees = list()
48   maillagesNonCoupes = list()
49   maillagesCoupes = list()
50
51   # On crée une liste contenant le maillage de chaque face.
52   listOfNewMeshes = createNewMeshesFromCorner(maillageDefautCible, listOfCorners, nro_cas)
53
54   i_aux = 0
55   while i_aux < len(listOfNewMeshes):
56     lines = createLinesFromMesh(listOfNewMeshes[i_aux])
57     setOfLines = list()
58     for line in lines:
59       # On possède l'information 'ID' de chaque noeud composant chaque
60       # ligne de la face. A partir de l'ID, on crée un vertex. Un
61       # ensemble de vertices constitue une ligne. Un ensemble de lignes
62       # constitue la face.
63       tmpCoords = [maillageDefautCible.GetNodeXYZ(node) for node in line]
64       tmpPoints = [geompy.MakeVertex(val[0], val[1], val[2]) for val in tmpCoords]
65       line = geompy.MakeInterpol(tmpPoints, False, False)
66       setOfLines.append(line)
67
68     # A partir des lignes de la face,
69     # on recrée un objet GEOM temporaire par filling.
70     filling = geompy.MakeFilling(geompy.MakeCompound(setOfLines), 2, 5, 0.0001, 0.0001, 0, GEOM.FOM_Default, True)
71     #logging.debug("face de filling")
72     #geomPublish(initLog.debug, filling, 'filling_{0}'.format(i_aux+1))
73
74     tmpPartition = geompy.MakePartition([filling], [shapeDefaut], list(), list(), geompy.ShapeType["FACE"], 0, list(), 0)
75     tmpExplodeRef = geompy.ExtractShapes(filling, geompy.ShapeType["EDGE"], True)
76     tmpExplodeNum = geompy.ExtractShapes(tmpPartition, geompy.ShapeType["EDGE"], True)
77     if len(tmpExplodeRef) == len(tmpExplodeNum):
78       logging.debug("face de filling non coupee")
79       geompy.addToStudy( filling, "faceNonCoupee_{0}".format(i_aux+1)) # doit etre publié pour critère OK plus bas
80       facesNonCoupees.append(filling)
81       maillagesNonCoupes.append(listOfNewMeshes[i_aux])
82     else:
83       logging.debug("face de filling coupee")
84       geompy.addToStudy( filling, "faceCoupee_{0}".format(i_aux+1))
85       facesCoupees.append(filling)
86       maillagesCoupes.append(listOfNewMeshes[i_aux])
87     i_aux += 1
88
89   listOfInternMeshes = [maillageInterneCible] + [msh.GetMesh() for msh in maillagesNonCoupes]
90
91   newMaillageInterne = smesh.Concatenate(listOfInternMeshes, 1, 1, 1e-05, False)
92   putName(newMaillageInterne, 'newInternalBoundary', i_pref=nro_cas)
93
94   facesEnTrop = list()
95   criteres = [smesh.GetCriterion(SMESH.FACE, SMESH.FT_BelongToGenSurface, SMESH.FT_Undefined, face) for face in facesNonCoupees]
96   filtres = [smesh.GetFilterFromCriteria([critere]) for critere in criteres]
97   for i_aux, filtre in enumerate(filtres):
98     filtre.SetMesh(maillageSain.GetMesh())
99     faceEnTrop = maillageSain.GroupOnFilter(SMESH.FACE, 'faceEnTrop_{0}'.format(i_aux+1), filtre)
100     facesEnTrop.append(faceEnTrop)
101
102   newZoneDefaut_skin = maillageSain.GetMesh().CutListOfGroups([zoneDefaut_skin], facesEnTrop, 'newZoneDefaut_skin')
103
104   return newZoneDefaut_skin, newMaillageInterne