1 # -*- coding: latin-1 -*-
2 # Copyright (C) 2009-2013 CEA/DEN, 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.
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 # Francis KLOSS : 2012 : CEA-Saclay, DEN, DM2S, SFME, LGLS, F-91191 Gif-sur-Yvette, France
22 # ========================================================================================
27 # Charger la géométrie
28 # ====================
32 geometrie = geompy.ImportBREP(nom+".brep")
34 # Sélectionner des sous-parties de la géométrie
35 # ---------------------------------------------
37 aretes = geompy.SubShapeAllSortedCentres(geometrie, geompy.ShapeType["EDGE"])
38 faces = geompy.SubShapeAllSortedCentres(geometrie, geompy.ShapeType["FACE"])
40 arc_int_bas = aretes[12]
41 arc_int_haut = aretes[13]
42 arc_ext_bas = aretes[11]
43 arc_ext_haut = aretes[14]
45 ell_int_bas = aretes[2]
46 ell_int_haut = aretes[3]
47 ell_ext_bas = aretes[1]
48 ell_ext_haut = aretes[4]
50 gen_int_avan = aretes[8]
51 gen_int_arri = aretes[7]
52 gen_ext_avan = aretes[9]
53 gen_ext_arri = aretes[6]
55 face_int_bas = faces[4]
56 face_int_haut = faces[5]
57 face_ext_bas = faces[2]
58 face_ext_haut = faces[3]
60 # Construire le modèle de bloc
61 # ============================
63 doc = hexablock.addDocument(nom)
68 base = doc.addVertex(0, 0, 0)
70 direction = doc.addVector(1, 0, 0)
72 tuyau = doc.addPipe(base, direction, 1, 2, 10)
74 # Construire le modele de blocs du tuyau
75 # --------------------------------------
77 depart = doc.addVector(0, 1, 0)
79 modele = doc.makePipe(tuyau, depart, 1, 4, 1)
81 # Associer le modèle de bloc à la géométrie
82 # =========================================
84 doc.setShape(geometrie)
86 # Associer les cercles
87 # --------------------
89 cer_int_dep = modele.getVertexIJK(0, 0, 0)
90 cer_ext_dep = modele.getVertexIJK(1, 0, 0)
95 a = modele.getEdgeJ(0, j, 0)
98 a = modele.getEdgeJ(1, j, 0)
101 doc.associateClosedLine(cer_int_dep, cer_int[0], cer_int[1:], arc_int_haut, 1, True, [arc_int_bas])
102 doc.associateClosedLine(cer_ext_dep, cer_ext[0], cer_ext[1:], arc_ext_haut, 1, True, [arc_ext_bas])
104 # Associer les ellipses
105 # ---------------------
107 ell_int_dep = modele.getVertexIJK(0, 0, 1)
108 ell_ext_dep = modele.getVertexIJK(1, 0, 1)
113 a = modele.getEdgeJ(0, j, 1)
116 a = modele.getEdgeJ(1, j, 1)
119 doc.associateClosedLine(ell_int_dep, ell_int[0], ell_int[1:], ell_int_haut, 1, True, [ell_int_bas])
120 doc.associateClosedLine(ell_ext_dep, ell_ext[0], ell_ext[1:], ell_ext_haut, 1, True, [ell_ext_bas])
122 # Associer les génératrices
123 # -------------------------
125 def generatrice(face):
128 for i in xrange(0, n+1):
130 s = geompy.MakeVertexOnSurface(face, 0.5, v)
133 return geompy.MakeInterpol(l)
135 gen_int_haut = generatrice(face_int_haut)
136 gen_ext_haut = generatrice(face_ext_haut)
137 gen_int_bas = generatrice(face_int_bas )
138 gen_ext_bas = generatrice(face_ext_bas )
140 modele.getEdgeK(0, 0, 0).addAssociation(gen_int_arri, 0, 1)
141 modele.getEdgeK(1, 0, 0).addAssociation(gen_ext_arri, 0, 1)
143 modele.getEdgeK(0, 1, 0).addAssociation(gen_int_haut, 0, 1)
144 modele.getEdgeK(1, 1, 0).addAssociation(gen_ext_haut, 0, 1)
146 modele.getEdgeK(0, 2, 0).addAssociation(gen_int_avan, 0, 1)
147 modele.getEdgeK(1, 2, 0).addAssociation(gen_ext_avan, 0, 1)
149 modele.getEdgeK(0, 3, 0).addAssociation(gen_int_bas , 0, 1)
150 modele.getEdgeK(1, 3, 0).addAssociation(gen_ext_bas , 0, 1)
152 # Associer les faces courbées
153 # ---------------------------
155 modele.getQuadJK(0, 0, 0).addAssociation(face_int_haut)
156 modele.getQuadJK(0, 1, 0).addAssociation(face_int_haut)
157 modele.getQuadJK(0, 2, 0).addAssociation(face_int_bas )
158 modele.getQuadJK(0, 3, 0).addAssociation(face_int_bas )
160 modele.getQuadJK(1, 0, 0).addAssociation(face_ext_haut)
161 modele.getQuadJK(1, 1, 0).addAssociation(face_ext_haut)
162 modele.getQuadJK(1, 2, 0).addAssociation(face_ext_bas )
163 modele.getQuadJK(1, 3, 0).addAssociation(face_ext_bas )
165 # Mailler le modèle de bloc
166 # =========================
168 # Définir 3 groupes d'arêtes
169 # --------------------------
171 groupe_cercles = doc.addEdgeGroup("Cercles")
172 groupe_ellipses = doc.addEdgeGroup("Ellipses")
173 groupe_generatrices = doc.addEdgeGroup("Generatrices")
175 # Définir 4 groupes de faces
176 # --------------------------
178 groupe_couronne = doc.addQuadGroup("Couronne")
179 groupe_ovale = doc.addQuadGroup("Ovale")
180 groupe_interieur = doc.addQuadGroup("Interieur")
181 groupe_exterieur = doc.addQuadGroup("Exterieur")
183 # Constituer les groupes d'arêtes
184 # -------------------------------
188 arete = modele.getEdgeJ(i, j, 0)
189 groupe_cercles.addElement(arete)
191 arete = modele.getEdgeJ(i, j, 1)
192 groupe_ellipses.addElement(arete)
194 arete = modele.getEdgeK(i, j, 0)
195 groupe_generatrices.addElement(arete)
197 # Constituer les groupes de faces
198 # -------------------------------
201 quad = modele.getQuadIJ(0, j, 0)
202 groupe_couronne.addElement(quad)
204 quad = modele.getQuadIJ(0, j, 1)
205 groupe_ovale.addElement(quad)
207 quad = modele.getQuadJK(0, j, 0)
208 groupe_interieur.addElement(quad)
210 quad = modele.getQuadJK(1, j, 0)
211 groupe_exterieur.addElement(quad)
213 # Mailler le modèle de bloc avec ses associations
214 # -----------------------------------------------
216 hexablock.addLaws(doc, 0.7, True)
218 blocs = hexablock.mesh(doc)
220 muv, mue, muq, muh = hexablock.dump(doc, blocs)