]> SALOME platform Git repositories - tools/eficas.git/blob - generator/generator_PSEN.py
Salome HOME
Merge remote branch 'origin/nouvelEficas' into nouvelEficas
[tools/eficas.git] / generator / generator_PSEN.py
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2007-2013   EDF R&D
3 #
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.
8 #
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.
13 #
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
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20 """Ce module contient le plugin generateur de fichier au format  Code_Carmel3D pour EFICAS.
21 """
22
23 texte_debut="int main() \n{ \n   init_var();\n"
24 texte_debut+='   format="med";\n'
25 import traceback
26 import types,string,re,os
27 from Extensions.i18n import tr
28 from generator_python import PythonGenerator
29
30 def entryPoint():
31    """
32       Retourne les informations necessaires pour le chargeur de plugins
33       Ces informations sont retournees dans un dictionnaire
34    """
35    return {
36         # Le nom du plugin
37           'name' : 'PSEN',
38         # La factory pour creer une instance du plugin
39           'factory' : PSENGenerator,
40           }
41
42
43 class PSENGenerator(PythonGenerator):
44    """
45       Ce generateur parcourt un objet de type JDC et produit
46       un texte au format eficas et 
47       un texte au format dictionnaire
48
49    """
50    # Les extensions de fichier permis?
51    extensions=('.comm',)
52
53 #----------------------------------------------------------------------------------------
54    def gener(self,obj,format='brut',config=None):
55
56       self.initDico()
57
58       # Cette instruction genere le contenu du fichier de commandes (persistance)
59       self.text=PythonGenerator.gener(self,obj,format)
60       return self.text
61
62
63 #----------------------------------------------------------------------------------------
64 # initialisations
65 #----------------------------------------------------------------------------------------
66    
67    def initDico(self) :
68       self.textePourRun = texte_debut
69
70
71 #----------------------------------------------------------------------------------------
72 # ecriture
73 #----------------------------------------------------------------------------------------
74
75    def writeDefault(self,fn) :
76         print self.textePourRun
77
78    def ajoutRun(self) :
79         self.textePourRun+="   write_mesh_crack();\n"
80         self.textePourRun+="   do_mesh_crack(0);\n"
81         self.textePourRun+="   nice_cut(20.);\n"
82         self.textePourRun+='   export_mesh("'+self.cracked_name+'","med");\n'
83         self.textePourRun+="}"
84
85
86 #----------------------------------------------------------------------------------------
87 #  analyse de chaque noeud de l'arbre 
88 #----------------------------------------------------------------------------------------
89
90    def generMCSIMP(self,obj) :
91         """recuperation de l objet MCSIMP"""
92         #print dir(obj)
93         s=PythonGenerator.generMCSIMP(self,obj)
94         if obj.nom in ListeConcatene : 
95            stringListe=""
96            for val in obj.val:
97                stringListe+=str(val)+" "
98            self.textePourRun+="   "+obj.nom+ "='"+ stringListe[0:-1]+ "';\n"
99            return s
100         if obj.nom=="elset_radius" :
101            self.textePourRun+="   if_must_define_elset=1;\n"
102         if obj.nom=="sane_name" :
103            self.textePourRun+="   import_mesh('"+obj.val+"');\n"
104         if obj.nom=="cracked_name" : self.cracked_name=obj.val
105         if obj.nom=="repertoire" : 
106            print "PNPNPN a traiter"
107            return s
108         self.textePourRun+="   "+obj.nom+ "=" + s[0:-1]+ ";\n"
109         return s
110
111   
112 # si repertoire on change tous les noms de fichier