Salome HOME
7.7 rc0
[tools/eficas.git] / generator / generator_vers3DSalome.py
index f9bf541e369668f7bde17a40c9b76245a909df17..dc5931cbb2b5226d5015e3cbfe07c9d2af3560ee 100644 (file)
@@ -1,23 +1,22 @@
 # -*- coding: utf-8 -*-
-#            CONFIGURATION MANAGEMENT OF EDF VERSION
-# ======================================================================
-# COPYRIGHT (C) 1991 - 2002  EDF R&D                  WWW.CODE-ASTER.ORG
-# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY
-# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY
-# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR
-# (AT YOUR OPTION) ANY LATER VERSION.
+# Copyright (C) 2007-2013   EDF R&D
 #
-# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT
-# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF
-# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU
-# GENERAL PUBLIC LICENSE FOR MORE DETAILS.
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
 #
-# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE
-# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER,
-#    1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE.
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
 #
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
-# ======================================================================
 """
     Ce module contient le plugin generateur de fichier au format 
     python pour EFICAS.
@@ -26,6 +25,7 @@
 """
 import traceback
 import types,string,re
+import math
 
 from Noyau import N_CR
 from Noyau.N_utils import repr_float
@@ -34,18 +34,18 @@ import Extensions
 from Extensions.parametre import ITEM_PARAMETRE
 from Formatage import Formatage
 from generator_python import PythonGenerator
-from Editeur.widgets import showerror
+#from Editeur.widgets import showerror
 
 def entryPoint():
    """
-       Retourne les informations nécessaires pour le chargeur de plugins
+       Retourne les informations nécessaires pour le chargeur de plugins
 
-       Ces informations sont retournées dans un dictionnaire
+       Ces informations sont retournées dans un dictionnaire
    """
    return {
         # Le nom du plugin
           'name' : 'vers3DSalome',
-        # La factory pour créer une instance du plugin
+        # La factory pour créer une instance du plugin
           'factory' : vers3DSalomeGenerator,
           }
 
@@ -66,9 +66,9 @@ class vers3DSalomeGenerator(PythonGenerator):
                             "BARRE", "CABLE", "CARA", "COQUE", "EPAIS", 
                             "EXCENTREMENT", "GROUP_MA", "ORIENTATION", 
                             "POUTRE", "SECTION", "VALE", "VARI_SECT",
-                            "GRILLE", "ANGL_REP",
+                            "GRILLE", "ANGL_REP", "VECTEUR",
                              "b_constant", "b_homothetique", 
-                            "b_rectangle", "b_affine", "b_cercle" )
+                            "b_rectangle", "b_affine", "b_cercle", "b_generale" )
       self.dict_deb_com={"POUTRE":"VisuPoutre", "CABLE" : "VisuCable",
                          "COQUE" : "VisuCoque", "GRILLE" : "VisuGrille",
                          "ORIENTATION" : "Orientation", "BARRE" : "VisuBarre"}
@@ -76,7 +76,7 @@ class vers3DSalomeGenerator(PythonGenerator):
       self.dict_suite_com={"RECTANGLE":"Rectangle","GENERALE":"Generale",
                            "CERCLE":"Cercle"}
 
-      self.dict_traduit={"VARI_SECT":"extrusion","EXCENTREMENT":"Excentre","EPAIS":"Epais"}
+      self.dict_traduit={"VARI_SECT":"extrusion","EXCENTREMENT":"Excentre","EPAIS":"Epais","VECTEUR":"Vecteur"}
 
       self.init_ligne() 
 
@@ -88,12 +88,13 @@ class vers3DSalomeGenerator(PythonGenerator):
       self.commande = ""
       self.dict_attributs = {} 
 
-   def gener(self,node):
+   def gener(self,node,config=None):
       """
       """
       self.node=node
       self.list_commandes=[];
       self.generator(self.node.object)
+      #print self.list_commandes
       return self.list_commandes
 
    def generator(self,obj):
@@ -118,7 +119,16 @@ class vers3DSalomeGenerator(PythonGenerator):
       """
       """
       if obj.isvalid() == 0 :
-         showerror("Element non valide","Salome ne sait pas traiter les élements non valides")
+         #showerror("Element non valide","Salome ne sait pas traiter les elements non valides")
+         return
+      for v in obj.mc_liste:
+         liste=self.generator(v)
+
+   def generMACRO_ETAPE(self,obj):
+      """
+      """
+      if obj.isvalid() == 0 :
+         #showerror("Element non valide","Salome ne sait pas traiter les elements non valides")
          return
       for v in obj.mc_liste:
          liste=self.generator(v)
@@ -127,29 +137,32 @@ class vers3DSalomeGenerator(PythonGenerator):
    def generMCSIMP(self,obj) :
       """
       """
-      #print "MCSIMP : ", obj.nom
       if obj.nom in dir(self) :
          suite = self.__class__.__dict__[obj.nom](self,obj)
       else :
          clef=self.dict_traduit[obj.nom]
-         self.dict_attributs[clef]=obj.val
+         # Traitement des parametres
+         try :
+             self.dict_attributs[clef]=obj.val.eval()
+         except :
+             self.dict_attributs[clef]=obj.val
+
 
    def generMCFACT(self,obj):
       """
-          Convertit un objet MCFACT en une liste de chaines de caractères à la
+          Convertit un objet MCFACT en une liste de chaines de caractères à la
           syntaxe python
       """
       self.init_ligne()
       self.commande=self.dict_deb_com[obj.nom]
-      print self.commande
       for v in obj.mc_liste:
          self.generator(v)
-      #print self.commande
-      #print self.dict_attributs
       if self.boolGpMa == 1:
          self.list_commandes.append((self.commande,self.dict_attributs)) 
       else :
-         showerror("Elements ne portant pas sur un Groupe de Maille","Salome ne sait pas montrer ce type d' element")
+         #showerror("Elements ne portant pas sur un Groupe de Maille","Salome ne sait pas montrer ce type d' element")
+         print ("Elements ne portant pas sur un Groupe de Maille","Salome ne sait pas montrer ce type d' element")
+         pass
 
    def generMCList(self,obj):
       """
@@ -169,8 +182,8 @@ class vers3DSalomeGenerator(PythonGenerator):
 
    def SECTION(self,obj):
       assert (self.commande != "" )
-      if self.commande == "VisuCable" : 
-         self.dict_attributs["R"]=obj.val
+      if self.commande == "VisuCable" :
+         self.dict_attributs["R"]= math.sqrt(obj.val/math.pi).eval()
       elif (self.commande !="VisuGrille")  :
          self.commande=self.commande+self.dict_suite_com[obj.valeur]
 
@@ -188,6 +201,8 @@ class vers3DSalomeGenerator(PythonGenerator):
        for k in range(len(atraiter)) :
            clef=self.clefs[k]
            val =atraiter[k] 
+           if isinstance(val, (types.TupleType, types.ListType)) and len(val) == 1:
+               val = val[0]
            if isinstance (val, Extensions.parametre.PARAMETRE):
               val=val.valeur
               print val.__class__
@@ -219,4 +234,3 @@ class vers3DSalomeGenerator(PythonGenerator):
       self.dict_attributs["axeX"]=alpha
       self.dict_attributs["axeY"]=beta
       self.dict_attributs["axeZ"]=gamma
-