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
27 from .geomsmesh import geompy
28 from .geomsmesh import geomPublish
29 from .geomsmesh import geomPublishInFather
33 from .listOfExtraFunctions import createNewMeshesFromCorner
34 from .listOfExtraFunctions import createLinesFromMesh
36 # -----------------------------------------------------------------------------
37 # --- groupe de quadrangles de face transformé en face géométrique par filling
39 def quadranglesToShapeWithCorner(meshQuad, shapeDefaut, listOfCorners):
41 # TODO: rédiger la docstring
45 #fillings = [list(), list()]
48 #bords_Partages = [list(), list()]
53 facesNonCoupees = list()
55 aretesNonCoupees = list()
56 aretesCoupees = list()
61 # On crée une liste contenant le maillage de chaque face.
62 listOfNewMeshes = createNewMeshesFromCorner(meshQuad, listOfCorners)
63 for msh in listOfNewMeshes:
64 # On crée une liste de noeuds correspondant aux faces suivant
65 # le modèle liste[face][ligne][noeud].
66 #lines = createLinesFromMesh(msh, listOfCorners[0])
67 lines = createLinesFromMesh(msh)
68 setOfNodes.append(lines)
70 for face in setOfNodes:
73 # On possède l'information 'ID' de chaque noeud composant chaque
74 # ligne de chaque face. A partir de l'ID, on crée un vertex. Un
75 # ensemble de vertices constitue une ligne. Un ensemble de lignes
77 tmpCoords = [meshQuad.GetNodeXYZ(node) for node in line]
78 tmpPoints = [geompy.MakeVertex(val[0], val[1], val[2]) for val in tmpCoords]
79 line = geompy.MakeInterpol(tmpPoints, False, False)
81 setOfLines.append(tmpFace)
83 for i, face in enumerate(setOfLines):
84 # A partir des lignes de chaque face,
85 # on recrée un objet GEOM temporaire par filling.
86 filling = geompy.MakeFilling(geompy.MakeCompound(face), 2, 5, 0.0001, 0.0001, 0, GEOM.FOM_Default, True)
87 geomPublish(initLog.debug, filling, 'filling_{}'.format(i + 1))
88 tmpFillings.append(filling)
90 for face in setOfNodes:
91 # On prend la première ligne qui correspond aux bords partagés
92 listOfEdges.append(face[0])
94 for edge in listOfEdges:
95 # On utilise les points de bords pour créer des aretes vives
96 tmpCoords = [meshQuad.GetNodeXYZ(node) for node in list(edge)]
97 tmpPoints = [geompy.MakeVertex(val[0], val[1], val[2]) for val in tmpCoords]
98 line = geompy.MakeInterpol(tmpPoints, False, False)
101 for i, filling in enumerate(tmpFillings):
102 tmpPartition = geompy.MakePartition([filling], [shapeDefaut], list(), list(), geompy.ShapeType["FACE"], 0, list(), 0, True)
103 tmpExplodeRef = geompy.ExtractShapes(filling, geompy.ShapeType["EDGE"], True)
104 tmpExplodeNum = geompy.ExtractShapes(tmpPartition, geompy.ShapeType["EDGE"], True)
105 if len(tmpExplodeRef) == len(tmpExplodeNum):
106 geomPublish(initLog.debug, filling, "faceNonCoupee_{}".format(i + 1))
107 facesNonCoupees.append(filling)
109 geomPublish(initLog.debug, filling, "faceCoupee_{}".format(i + 1))
110 facesCoupees.append(filling)
111 fillings = facesCoupees, facesNonCoupees
113 for i, filling in enumerate(tmpBords):
114 tmpPartition = geompy.MakePartition([shapeDefaut], [filling], list(), list(), geompy.ShapeType["SHELL"], 0, list(), 0, True)
115 tmpExplodeRef = geompy.ExtractShapes(shapeDefaut, geompy.ShapeType["EDGE"], True) + geompy.ExtractShapes(shapeDefaut, geompy.ShapeType["VERTEX"], True)
116 tmpExplodeNum = geompy.ExtractShapes(tmpPartition, geompy.ShapeType["EDGE"], True) + geompy.ExtractShapes(tmpPartition, geompy.ShapeType["VERTEX"], True)
117 if len(tmpExplodeRef) == len(tmpExplodeNum):
118 geomPublish(initLog.debug, filling, "areteNonCoupee_{}".format(i + 1))
119 aretesNonCoupees.append(filling)
121 geomPublish(initLog.debug, filling, "areteCoupee_{}".format(i + 1))
122 aretesCoupees.append(filling)
123 bords_Partages = aretesCoupees, aretesNonCoupees
126 # for i, face in enumerate(setOfLines):
127 # for j, line in enumerate(face):
128 # geomPublish(initLog.debug, line, 'face{0}_ligne{1}'.format(i + 1, j + 1))
131 # for i, filling in enumerate(fillings[0]):
132 # geomPublish(initLog.debug, filling, 'filling_{0}'.format(i + 1))
133 # for j, line in enumerate(setOfLines[i]):
134 # geompy.addToStudyInFather(filling, line, 'line_{0}'.format(j + 1))
136 return fillings, noeuds_bords, bords_Partages, fillconts, idFilToCont