1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2007-2013 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 Ce module contient le plugin generateur de fichier au format
26 import types,string,re
28 from Noyau import N_CR
29 from Noyau.N_utils import repr_float
30 from Accas import ETAPE,PROC_ETAPE,MACRO_ETAPE,ETAPE_NIVEAU,JDC,FORM_ETAPE
31 from Accas import MCSIMP,MCFACT,MCBLOC,MCList,EVAL
32 from Accas import GEOM,ASSD,MCNUPLET
33 from Accas import COMMENTAIRE,PARAMETRE, PARAMETRE_EVAL,COMMANDE_COMM
34 from Formatage import Formatage
35 from generator_python import PythonGenerator
39 Retourne les informations necessaires pour le chargeur de plugins
41 Ces informations sont retournees dans un dictionnaire
46 # La factory pour creer une instance du plugin
47 'factory' : HomardGenerator,
51 class HomardGenerator(PythonGenerator):
53 Ce generateur parcourt un objet de type JDC et produit
54 un texte au format eficas et
55 un texte au format homard
58 # Les extensions de fichier preconis�es
61 def __init__(self,cr=None):
62 # Si l'objet compte-rendu n'est pas fourni, on utilise le compte-rendu standard
66 self.cr=N_CR.CR(debut='CR generateur format homard pour homard',
67 fin='fin CR format homard pour homard')
68 # Le texte au format homard est stock� dans l'attribut text
76 self.lmots_clef_calcules = ('SuivFron','TypeBila','ModeHOMA','CCAssoci', 'CCNoChaI','HOMaiN__','HOMaiNP1','CCNumOrI', 'CCNumPTI')
77 self.lmot_clef = ('CCMaiN__', 'CCNoMN__', 'CCIndica', 'CCSolN__', 'CCFronti', 'CCNoMFro', 'CCMaiNP1',
78 'CCNoMNP1', 'CCSolNP1', 'TypeRaff', 'TypeDera', 'NiveauMa', 'SeuilHau', 'SeuilHRe',
79 'SeuilHPE', 'NiveauMi', 'SeuilBas', 'SeuilBRe', 'SeuilBPE', 'ListeStd', 'NumeIter',
80 'Langue ', 'CCGroFro', 'CCNoChaI', 'CCNumOrI', 'CCNumPTI', 'SuivFron', 'TypeBila',
81 'ModeHOMA', 'HOMaiN__', 'HOMaiNP1','CCCoChaI')
83 # Bizarre demander a Gerald :
85 self.assoc['CCMaiN__']='FICHIER_MED_MAILLAGE_N'
86 self.assoc['CCNoMN__']='NOM_MED_MAILLAGE_N'
87 self.assoc['CCIndica']='FICHIER_MED_MAILLAGE_N'
88 self.assoc['CCSolN__']='FICHIER_MED_MAILLAGE_N'
89 self.assoc['CCFronti']='FIC_FRON'
90 self.assoc['CCNoMFro']='NOM_MED_MAILLAGE_FRONTIERE'
91 self.assoc['CCMaiNP1']='FICHIER_MED_MAILLAGE_NP1'
92 self.assoc['CCNoMNP1']='NOM_MED_MAILLAGE_NP1'
93 self.assoc['CCSolNP1']='FICHIER_MED_MAILLAGE_NP1'
94 self.assoc['TypeRaff']='RAFFINEMENT'
95 self.assoc['TypeDera']='DERAFFINEMENT'
96 self.assoc['NiveauMa']='NIVE_MAX'
97 self.assoc['SeuilHau']='CRIT_RAFF_ABS'
98 self.assoc['SeuilHRe']='CRIT_RAFF_REL'
99 self.assoc['SeuilHPE']='CRIT_RAFF_PE'
100 self.assoc['NiveauMi']='NIVE_MIN'
101 self.assoc['SeuilBas']='CRIT_DERA_ABS'
102 self.assoc['SeuilBRe']='CRIT_DERA_REL'
103 self.assoc['SeuilBPE']='CRIT_DERA_PE'
104 self.assoc['ListeStd']='MESSAGES'
105 self.assoc['NumeIter']='NITER'
106 self.assoc['Langue ']='LANGUE'
107 self.assoc['CCGroFro']='GROUP_MA'
108 # self.assoc['CCNoChaI']='NOM_MED' (on doit aussi ajouter 'COMPOSANTE')
109 self.assoc['CCNumOrI']='NUME_ORDRE'
110 self.assoc['CCNumPTI']='NUME_PAS_TEMPS'
111 self.assoc['CCCoChaI']='COMPOSANTE'
113 self.dico_mot_depend={}
115 # Attention a la synthaxe
116 self.dico_mot_depend['CCIndica'] ='self.dico_mot_clef["RAFFINEMENT"] == "LIBRE" or self.dico_mot_clef["DERAFFINEMENT"] == "LIBRE"'
117 self.dico_mot_depend['CCSolN__'] ='self.dico_mot_clef.has_key("NITER")'
118 self.dico_mot_depend['CCSolNP1'] ='self.dico_mot_clef.has_key("NITER")'
120 def gener(self,obj,format='brut',config=None):
121 self.text=PythonGenerator.gener(self,obj,format)
122 self.genereConfiguration()
125 def generMCSIMP(self,obj) :
127 Convertit un objet MCSIMP en une liste de chaines de caract�res � la
130 s=PythonGenerator.generMCSIMP(self,obj)
132 self.dico_mot_clef[clef]=obj.val
135 def cherche_dependance(self,mot):
137 a_eval=self.dico_mot_depend[mot]
139 b_eval=eval(self.dico_mot_depend[mot])
141 for l in a_eval.split(" or "):
144 if not (b_eval == 0 ):
151 def genereConfiguration(self):
154 for mot in self.lmot_clef:
156 # on verifie d'abord que le mot clef doit bien etre calcule
157 if self.dico_mot_depend.has_key(mot) :
158 if self.cherche_dependance(mot) == 0 :
161 if mot not in self.lmots_clef_calcules :
162 clef_eficas=self.assoc[mot]
163 if self.dico_mot_clef.has_key(clef_eficas):
164 val=self.dico_mot_clef[clef_eficas]
169 ligne=mot+' '+repr(val)
171 self.textehomard.append(ligne)
173 val=apply(HomardGenerator.__dict__[mot],(self,))
178 self.textehomard.append(ligne)
180 def get_homard(self):
181 return self.textehomard
185 if self.dico_mot_clef.has_key('NOM_MED_MAILLAGE_FRONTIERE'):
186 if self.dico_mot_clef['NOM_MED_MAILLAGE_FRONTIERE'] != None:
193 dict_val={'NOMBRE':7,'INTERPENETRATION':3,'QUALITE':5,'CONNEXITE':11,'TAILLE':13}
194 for mot in ('NOMBRE','QUALITE','INTERPENETRATION','CONNEXITE','TAILLE'):
195 if self.dico_mot_clef.has_key(mot):
196 if (self.dico_mot_clef[mot] == "OUI"):
197 inttypeBilan=inttypeBilan*dict_val[mot]
198 retour = repr(inttypeBilan)
204 if self.dico_mot_clef.has_key('INFORMATION'):
205 if self.dico_mot_clef['INFORMATION'] == "OUI":
207 return repr(intModeHOMA)
213 if not (self.dico_mot_clef.has_key('NOM_MED')):
215 if (self.dico_mot_clef['NOM_MED']== None):
217 if not (self.dico_mot_clef.has_key('COMPOSANTE')):
219 if (self.dico_mot_clef['COMPOSANTE']== None):
221 chaine=self.dico_mot_clef['COMPOSANTE']+' '+self.dico_mot_clef['NOM_MED']
226 if self.dico_mot_clef.has_key('NITER'):
227 if self.dico_mot_clef['NITER'] != None :
228 num="M"+repr(self.dico_mot_clef['NITER'])
229 chaine=num+" "+num+".hom"
234 if self.dico_mot_clef.has_key('NITER'):
235 if self.dico_mot_clef['NITER'] != None :
236 num="M"+repr(self.dico_mot_clef['NITER']+1)
237 chaine=num+" "+num+".hom"
242 if self.dico_mot_clef.has_key('NUME_ORDRE'):
243 if self.dico_mot_clef['NUME_ORDRE'] != None :
244 chaine=repr(self.dico_mot_clef['NUME_ORDRE'])
249 if self.dico_mot_clef.has_key('NUME_PAS_TEMPS'):
250 if self.dico_mot_clef['NUME_PAS_TEMPS'] != None :
251 chaine=repr(self.dico_mot_clef['NUME_PAS_TEMPS'])