Salome HOME
modif PSEN
[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_dicoImbrique import DicoImbriqueGenerator
29 import pdb
30 from numpy import zeros
31
32 def entryPoint():
33    """
34       Retourne les informations necessaires pour le chargeur de plugins
35       Ces informations sont retournees dans un dictionnaire
36    """
37    return {
38         # Le nom du plugin
39           'name' : 'PSEN',
40         # La factory pour creer une instance du plugin
41           'factory' : PSENGenerator,
42           }
43
44
45 class PSENGenerator(DicoImbriqueGenerator):
46    """
47       Ce generateur parcourt un objet de type JDC et produit
48       un texte au format eficas et 
49       un texte au format dictionnaire
50
51    """
52    # Les extensions de fichier permis?
53    extensions=('.comm',)
54
55 #----------------------------------------------------------------------------------------
56    def gener(self,obj,format='brut',config=None):
57
58       print "je passe dans gener"
59       #self.MachineDico = obj.MachineDico
60       #self.LoadDico = obj.LoadDico
61       #self.LineDico = obj.LineDico
62       #self.TransfoDico = obj.TransfoDico
63       
64       self.initDico()
65       # Cette instruction genere le contenu du fichier de commandes (persistance)
66       self.text=DicoImbriqueGenerator.gener(self,obj,format)
67       return self.text
68
69
70 #----------------------------------------------------------------------------------------
71 # initialisations
72 #----------------------------------------------------------------------------------------
73    
74    def initDico(self) :
75       DicoImbriqueGenerator.initDico(self)
76       #self.Entete = 'MachineDico = ' + str(self.MachineDico) +'\n'
77       #self.Entete += 'LoadDico = ' + str(self.LoadDico) +'\n'
78       #self.Entete += 'LineDico = ' + str(self.LineDico) +'\n'
79       #self.Entete += 'TransfoDico = ' + str(self.TransfoDico) +'\n'
80       #self.Entete +='\n'
81
82
83 #----------------------------------------------------------------------------------------
84 # ecriture
85 #----------------------------------------------------------------------------------------
86
87    def writeDefault(self,fn) :
88         DicoImbriqueGenerator.writeDefault(self,fn)
89         return
90
91    
92
93 #----------------------------------------------------------------------------------------
94 #  analyse de chaque noeud de l'arbre 
95 #----------------------------------------------------------------------------------------
96
97 ##   def generMCSIMP(self,obj) :
98 ##        """recuperation de l objet MCSIMP"""
99 ##        #print dir(obj)
100 ##        self.dicoMCSIMP[obj.nom]=obj.val
101 ##        self.dicoTemp[obj.nom]=obj.val
102 ##        s=DicoImbriqueGenerator.generMCSIMP(self,obj)
103 ##        return s
104 ##
105 ##   def generETAPE(self,obj):
106 ##        self.dicoTemp={}
107 ##        s=DicoImbriqueGenerator.generETAPE(self,obj)
108 ##        if obj.nom=="DISTRIBUTION" : self.dicoLois[obj.sd.nom]=self.dicoTemp
109 ##        self.dicoTemp={}
110 ##        return s
111
112   
113 # si repertoire on change tous les noms de fichier