1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2021 EDF R&D
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.
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.
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
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 """Groupe de quadrangles de face transformé en face géométrique par filling
22 Created on Tue Jun 24 09:14:13 2014
23 @author: I48174 (Olivier HOAREAU)
31 from .geomsmesh import geompy
32 from .geomsmesh import smesh
34 from .listOfExtraFunctions import createNewMeshesFromCorner
35 from .listOfExtraFunctions import createLinesFromMesh
37 def fusionMaillageDefaut(maillageSain, maillageDefautCible, maillageInterneCible, zoneDefaut_skin, shapeDefaut, listOfCorners):
38 """Groupe de quadrangles de face transformé en face géométrique par filling"""
42 facesNonCoupees = list()
44 maillagesNonCoupes = list()
45 maillagesCoupes = list()
47 # On crée une liste contenant le maillage de chaque face.
48 listOfNewMeshes = createNewMeshesFromCorner(maillageDefautCible, listOfCorners)
51 while i_aux < len(listOfNewMeshes):
52 lines = createLinesFromMesh(listOfNewMeshes[i_aux])
55 # On possède l'information 'ID' de chaque noeud composant chaque
56 # ligne de la face. A partir de l'ID, on crée un vertex. Un
57 # ensemble de vertices constitue une ligne. Un ensemble de lignes
59 tmpCoords = [maillageDefautCible.GetNodeXYZ(node) for node in line]
60 tmpPoints = [geompy.MakeVertex(val[0], val[1], val[2]) for val in tmpCoords]
61 line = geompy.MakeInterpol(tmpPoints, False, False)
62 setOfLines.append(line)
64 # A partir des lignes de la face,
65 # on recrée un objet GEOM temporaire par filling.
66 filling = geompy.MakeFilling(geompy.MakeCompound(setOfLines), 2, 5, 0.0001, 0.0001, 0, GEOM.FOM_Default, True)
67 #logging.debug("face de filling")
68 #geomPublish(initLog.debug, filling, 'filling_{0}'.format(i_aux+1))
70 tmpPartition = geompy.MakePartition([filling], [shapeDefaut], list(), list(), geompy.ShapeType["FACE"], 0, list(), 0)
71 tmpExplodeRef = geompy.ExtractShapes(filling, geompy.ShapeType["EDGE"], True)
72 tmpExplodeNum = geompy.ExtractShapes(tmpPartition, geompy.ShapeType["EDGE"], True)
73 if len(tmpExplodeRef) == len(tmpExplodeNum):
74 logging.debug("face de filling non coupee")
75 geompy.addToStudy( filling, "faceNonCoupee_{0}".format(i_aux+1)) # doit etre publie pour critere OK plus bas
76 facesNonCoupees.append(filling)
77 maillagesNonCoupes.append(listOfNewMeshes[i_aux])
79 logging.debug("face de filling coupee")
80 geompy.addToStudy( filling, "faceCoupee_{0}".format(i_aux+1))
81 facesCoupees.append(filling)
82 maillagesCoupes.append(listOfNewMeshes[i_aux])
85 listOfInternMeshes = [maillageInterneCible] + [msh.GetMesh() for msh in maillagesNonCoupes]
87 newMaillageInterne = smesh.Concatenate(listOfInternMeshes, 1, 1, 1e-05, False)
90 criteres = [smesh.GetCriterion(SMESH.FACE, SMESH.FT_BelongToGenSurface, SMESH.FT_Undefined, face) for face in facesNonCoupees]
91 filtres = [smesh.GetFilterFromCriteria([critere]) for critere in criteres]
92 for i_aux, filtre in enumerate(filtres):
93 filtre.SetMesh(maillageSain.GetMesh())
94 faceEnTrop = maillageSain.GroupOnFilter(SMESH.FACE, 'faceEnTrop_{0}'.format(i_aux+1), filtre)
95 facesEnTrop.append(faceEnTrop)
97 newZoneDefaut_skin = maillageSain.GetMesh().CutListOfGroups([zoneDefaut_skin], facesEnTrop, 'newZoneDefaut_skin')
99 smesh.SetName(newMaillageInterne, 'newInternalBoundary')
101 return newZoneDefaut_skin, newMaillageInterne