1 # -*- coding: utf-8 -*-
2 # CONFIGURATION MANAGEMENT OF EDF VERSION
3 # ======================================================================
4 # COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG
5 # THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY
6 # IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY
7 # THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR
8 # (AT YOUR OPTION) ANY LATER VERSION.
10 # THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT
11 # WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF
12 # MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU
13 # GENERAL PUBLIC LICENSE FOR MORE DETAILS.
15 # YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE
16 # ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER,
17 # 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE.
20 # ======================================================================
22 Ce module contient le plugin generateur de fichier au format
28 import types,string,re
31 from Noyau import N_CR
32 from Noyau.N_utils import repr_float
35 from Extensions.parametre import ITEM_PARAMETRE
36 from Formatage import Formatage
37 from generator_python import PythonGenerator
38 #from Editeur.widgets import showerror
42 Retourne les informations nécessaires pour le chargeur de plugins
44 Ces informations sont retournées dans un dictionnaire
48 'name' : 'vers3DSalome',
49 # La factory pour créer une instance du plugin
50 'factory' : vers3DSalomeGenerator,
54 class vers3DSalomeGenerator(PythonGenerator):
56 Ce generateur parcourt un objet AFFE-CARA_ELEM
57 et produit un fichier au format texte contenant
58 les instructions idl pour PAL
61 def __init__(self,cr=None):
62 self.list_commandes=[];
66 self.liste_motetat = ("AFFE_CARA_ELEM", "ORIG_AXE", "AXE" ,
67 "BARRE", "CABLE", "CARA", "COQUE", "EPAIS",
68 "EXCENTREMENT", "GROUP_MA", "ORIENTATION",
69 "POUTRE", "SECTION", "VALE", "VARI_SECT",
71 "b_constant", "b_homothetique",
72 "b_rectangle", "b_affine", "b_cercle" )
73 self.dict_deb_com={"POUTRE":"VisuPoutre", "CABLE" : "VisuCable",
74 "COQUE" : "VisuCoque", "GRILLE" : "VisuGrille",
75 "ORIENTATION" : "Orientation", "BARRE" : "VisuBarre"}
77 self.dict_suite_com={"RECTANGLE":"Rectangle","GENERALE":"Generale",
80 self.dict_traduit={"VARI_SECT":"extrusion","EXCENTREMENT":"Excentre","EPAIS":"Epais"}
84 def init_jdc(self,jdc) :
87 def init_ligne (self) :
90 self.dict_attributs = {}
96 self.list_commandes=[];
97 self.generator(self.node.object)
98 return self.list_commandes
100 def generator(self,obj):
101 if (obj.nom in self.liste_motetat) and (self.calcule_ouinon(obj)):
102 PythonGenerator.generator(self,obj)
104 f1=PythonGenerator.generator(self,obj)
109 def calcule_ouinon(self,obj):
111 for l in obj.get_genealogie() :
112 if not l in self.liste_motetat :
118 def generETAPE(self,obj):
121 if obj.isvalid() == 0 :
122 #showerror("Element non valide","Salome ne sait pas traiter les élements non valides")
124 for v in obj.mc_liste:
125 liste=self.generator(v)
128 def generMCSIMP(self,obj) :
131 if obj.nom in dir(self) :
132 suite = self.__class__.__dict__[obj.nom](self,obj)
134 clef=self.dict_traduit[obj.nom]
135 # Traitement des parametres
137 self.dict_attributs[clef]=obj.val.eval()
139 self.dict_attributs[clef]=obj.val
142 def generMCFACT(self,obj):
144 Convertit un objet MCFACT en une liste de chaines de caractères à la
148 self.commande=self.dict_deb_com[obj.nom]
149 for v in obj.mc_liste:
151 if self.boolGpMa == 1:
152 self.list_commandes.append((self.commande,self.dict_attributs))
154 #showerror("Elements ne portant pas sur un Groupe de Maille","Salome ne sait pas montrer ce type d' element")
155 print ("Elements ne portant pas sur un Groupe de Maille","Salome ne sait pas montrer ce type d' element")
158 def generMCList(self,obj):
161 for mcfact in obj.data:
162 self.generator(mcfact)
164 def generMCBLOC(self,obj):
167 for v in obj.mc_liste:
170 def GROUP_MA(self,obj):
172 self.dict_attributs["Group_Maille"]=obj.val
174 def SECTION(self,obj):
175 assert (self.commande != "" )
176 if self.commande == "VisuCable" :
177 self.dict_attributs["R"]= math.sqrt(obj.val/math.pi).eval()
178 elif (self.commande !="VisuGrille") :
179 self.commande=self.commande+self.dict_suite_com[obj.valeur]
183 if type(self.clefs) == types.StringType :
184 self.clefs=(obj.val,)
188 if len(self.clefs) > 1 :
189 assert (len(atraiter) == len(self.clefs))
192 for k in range(len(atraiter)) :
195 if isinstance (val, Extensions.parametre.PARAMETRE):
199 if type(val) == type("aaa") :
200 for p in self.jdc.params:
201 context[p.nom]=eval(p.val,self.jdc.const_context, context)
203 res=eval(val,self.jdc.const_context, context)
205 self.dict_attributs[clef]=val
207 def ANGL_REP(self,obj) :
208 assert (len(obj.val) == 2)
210 self.dict_attributs["angleAlpha"]=alpha
211 self.dict_attributs["angleBeta"]=beta
213 def ORIG_AXE(self,obj) :
214 assert (len(obj.val) == 3)
215 alpha,beta,gamma=obj.val
216 self.dict_attributs["origAxeX"]=alpha
217 self.dict_attributs["origAxeY"]=beta
218 self.dict_attributs["origAxeZ"]=gamma
221 assert (len(obj.val) == 3)
222 alpha,beta,gamma=obj.val
223 self.dict_attributs["axeX"]=alpha
224 self.dict_attributs["axeY"]=beta
225 self.dict_attributs["axeZ"]=gamma