1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2020 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
21 Created on Tue Jun 24 09:14:13 2014
23 @author: I48174 (Olivier HOAREAU)
27 from .geomsmesh import geompy
28 from .geomsmesh import smesh
29 from .geomsmesh import geomPublish
30 from .geomsmesh import geomPublishInFather
35 from .listOfExtraFunctions import createNewMeshesFromCorner
36 from .listOfExtraFunctions import createLinesFromMesh
38 # -----------------------------------------------------------------------------
39 # --- groupe de quadrangles de face transformé en face géométrique par filling
41 def fusionMaillageDefaut(maillageSain, maillageDefautCible, maillageInterneCible, zoneDefaut_skin, shapeDefaut, listOfCorners):
43 # TODO: rédiger la docstring
49 maillagesNonCoupes = []
52 # On crée une liste contenant le maillage de chaque face.
53 listOfNewMeshes = createNewMeshesFromCorner(maillageDefautCible, listOfCorners)
56 while i < len(listOfNewMeshes):
57 lines = createLinesFromMesh(listOfNewMeshes[i])
60 # On possède l'information 'ID' de chaque noeud composant chaque
61 # ligne de la face. A partir de l'ID, on crée un vertex. Un
62 # ensemble de vertices constitue une ligne. Un ensemble de lignes
64 tmpCoords = [maillageDefautCible.GetNodeXYZ(node) for node in line]
65 tmpPoints = [geompy.MakeVertex(val[0], val[1], val[2]) for val in tmpCoords]
66 line = geompy.MakeInterpol(tmpPoints, False, False)
67 setOfLines.append(line)
69 # A partir des lignes de la face,
70 # on recrée un objet GEOM temporaire par filling.
71 filling = geompy.MakeFilling(geompy.MakeCompound(setOfLines), 2, 5, 0.0001, 0.0001, 0, GEOM.FOM_Default, True)
72 #logging.debug("face de filling")
73 #geomPublish(initLog.debug, filling, 'filling_{0}'.format(i + 1))
75 tmpPartition = geompy.MakePartition([filling], [shapeDefaut], [], [], geompy.ShapeType["FACE"], 0, [], 0)
76 tmpExplodeRef = geompy.ExtractShapes(filling, geompy.ShapeType["EDGE"], True)
77 tmpExplodeNum = geompy.ExtractShapes(tmpPartition, geompy.ShapeType["EDGE"], True)
78 if len(tmpExplodeRef) == len(tmpExplodeNum):
79 logging.debug("face de filling non coupee")
80 geompy.addToStudy( filling, "faceNonCoupee_{0}".format(i + 1)) # doit etre publie pour critere OK plus bas
81 facesNonCoupees.append(filling)
82 maillagesNonCoupes.append(listOfNewMeshes[i])
84 logging.debug("face de filling coupee")
85 geompy.addToStudy( filling, "faceCoupee_{0}".format(i + 1))
86 facesCoupees.append(filling)
87 maillagesCoupes.append(listOfNewMeshes[i])
91 listOfInternMeshes = [maillageInterneCible] + [msh.GetMesh() for msh in maillagesNonCoupes]
93 newMaillageInterne = smesh.Concatenate(listOfInternMeshes, 1, 1, 1e-05, False)
97 criteres = [smesh.GetCriterion(SMESH.FACE, SMESH.FT_BelongToGenSurface, SMESH.FT_Undefined, face) for face in facesNonCoupees]
98 filtres = [smesh.GetFilterFromCriteria([critere]) for critere in criteres]
99 for i, filtre in enumerate(filtres):
100 filtre.SetMesh(maillageSain.GetMesh())
101 faceEnTrop = maillageSain.GroupOnFilter(SMESH.FACE, 'faceEnTrop_{0}'.format(i + 1), filtre)
102 facesEnTrop.append(faceEnTrop)
104 newZoneDefaut_skin = maillageSain.GetMesh().CutListOfGroups([zoneDefaut_skin], facesEnTrop, 'newZoneDefaut_skin')
106 smesh.SetName(newMaillageInterne, 'newInternalBoundary')
108 return newZoneDefaut_skin, newMaillageInterne