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
20 """Ce module contient le plugin generateur de fichier au format Code_Carmel3D pour EFICAS.
23 texte_debut="int main() \n{ \n init_var();\n"
24 texte_debut+=' format="med";\n'
26 import types,string,re,os
27 from Extensions.i18n import tr
28 from generator_python import PythonGenerator
32 Retourne les informations necessaires pour le chargeur de plugins
33 Ces informations sont retournees dans un dictionnaire
38 # La factory pour creer une instance du plugin
39 'factory' : PSENGenerator,
43 class PSENGenerator(PythonGenerator):
45 Ce generateur parcourt un objet de type JDC et produit
46 un texte au format eficas et
47 un texte au format dictionnaire
50 # Les extensions de fichier permis?
53 #----------------------------------------------------------------------------------------
54 def gener(self,obj,format='brut',config=None):
58 # Cette instruction genere le contenu du fichier de commandes (persistance)
59 self.text=PythonGenerator.gener(self,obj,format)
63 #----------------------------------------------------------------------------------------
65 #----------------------------------------------------------------------------------------
68 self.textePourRun = texte_debut
71 #----------------------------------------------------------------------------------------
73 #----------------------------------------------------------------------------------------
75 def writeDefault(self,fn) :
76 print self.textePourRun
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+="}"
86 #----------------------------------------------------------------------------------------
87 # analyse de chaque noeud de l'arbre
88 #----------------------------------------------------------------------------------------
90 def generMCSIMP(self,obj) :
91 """recuperation de l objet MCSIMP"""
93 s=PythonGenerator.generMCSIMP(self,obj)
94 if obj.nom in ListeConcatene :
97 stringListe+=str(val)+" "
98 self.textePourRun+=" "+obj.nom+ "='"+ stringListe[0:-1]+ "';\n"
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"
108 self.textePourRun+=" "+obj.nom+ "=" + s[0:-1]+ ";\n"
112 # si repertoire on change tous les noms de fichier