]> SALOME platform Git repositories - modules/eficas.git/blobdiff - src/EFICASGUI/eficasCL.py
Salome HOME
*** empty log message ***
[modules/eficas.git] / src / EFICASGUI / eficasCL.py
index 7f874875e6d42d1718d1c551c7a6f6b37ec02fd2..8424025597d95939fedf24807dbeb5e49f728bc5 100644 (file)
@@ -1,6 +1,7 @@
 import salome
 import SALOMEDS
 import SMESH
+import GEOM
 import SalomePyQt
 import MonChoixMaillage
 
@@ -9,11 +10,15 @@ dict_CL={}
 
 class CLinit:
     def __init__(self):
+       geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
+       self.GroupOp  = geom.GetIGroupOperations(salome.myStudyId)
        self.smesh=None
+       self.geomcompID=None
        self._d = SalomePyQt.SalomePyQt().getDesktop()
-       self.get_maillages()
        self.correspondanceNomIOR = {}
+       self.correspondanceNomIORshape = {}
        self.name="CL"
+       print "fin init"
 
     def GetOrCreateCL(self,myShapeName):
        if not (dict_CL.has_key(myShapeName)):
@@ -22,73 +27,63 @@ class CLinit:
 
 
     def traiteCL(self):
+       self.get_geoms()
+       self.get_maillages()
        # Récupere tous les Mesh
        if len(dict_CL) > 0:
           Choix=MonChoixMaillage.MonChoixMaillage(self,0,self._d)
        salome.sg.updateObjBrowser(0)
-
+       
+    
     def traiteMaillage(self,indiceIOR,NomMaillage):
        MeshIOR = self.correspondanceNomIOR[str(NomMaillage)]
        Mesh = salome.orb.string_to_object(MeshIOR)
        GEOMIor = dict_CL.keys()[indiceIOR]
        for monIOR in dict_CL[GEOMIor].CLOnNode.keys():
-                  GEOMShape = salome.orb.string_to_object(monIOR)
+           GEOMShape = salome.orb.string_to_object(monIOR)
            aShapeSO = salome.myStudy.FindObjectIOR(monIOR)
            attrName  = aShapeSO.FindAttribute("AttributeName")[1]
-                  anAttr = attrName._narrow(SALOMEDS.AttributeName)
+           anAttr = attrName._narrow(SALOMEDS.AttributeName)
            Name = anAttr.Value()
            Mesh.CreateGroupFromGEOM(SMESH.NODE,Name,GEOMShape)
        for monIOR in dict_CL[GEOMIor].CLOnCell.keys():
-                  GEOMShape = salome.orb.string_to_object(monIOR)
+           GEOMShape = salome.orb.string_to_object(monIOR)
            aShapeSO = salome.myStudy.FindObjectIOR(monIOR)
            attrName  = aShapeSO.FindAttribute("AttributeName")[1]
-                  anAttr = attrName._narrow(SALOMEDS.AttributeName)
+           anAttr = attrName._narrow(SALOMEDS.AttributeName)
            Name = anAttr.Value()
-          #_CS_cbo: ajout de la determination de la dimension de la geometrie
-           #Mesh.CreateGroupFromGEOM(SMESH.FACE,Name,GEOMShape)
-          ShapeType = GEOMShape.GetShapeType()
-          print ShapeType
-          if str(ShapeType) is "EDGE":
-              print "--------------- EDGE existing Mesh"
-               Mesh.CreateGroupFromGEOM(SMESH.EDGE,Name,GEOMShape)
-          else:
-              print "--------------- FACE existing Mesh"
-              Mesh.CreateGroupFromGEOM(SMESH.FACE,Name,GEOMShape)
+           #_CS_cbo: ajout de la determination de la dimension de la geometrie
+           type = self.getShapeType(GEOMShape)
+           Mesh.CreateGroupFromGEOM(type,Name,GEOMShape)           
        del dict_CL[GEOMIor]
            
 
-    def traiteNewMaillage(self,indiceIOR,NomMaillage):
-       GEOMIor = dict_CL.keys()[indiceIOR]
-       shape = salome.orb.string_to_object(GEOMIor)
+    def traiteNewMaillage(self,numero,indiceIOR,NomMaillage):
+       GEOMIor=dict_CL.keys()[numero]
+       GEOMShapeIor=self.correspondanceNomIORshape[str(indiceIOR)]
+       shape = salome.orb.string_to_object(GEOMShapeIor)
        if self.smesh == None :
-         self.smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
-        self.smesh.SetCurrentStudy(salome.myStudy)
+           self.smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
+           self.smesh.SetCurrentStudy(salome.myStudy)
        assert (self.smesh)
        newMesh  = self.smesh.CreateMesh(shape)
        self.SetName(salome.ObjectToID(newMesh),NomMaillage)
        for monIOR in dict_CL[GEOMIor].CLOnNode.keys():
            GEOMShape = salome.orb.string_to_object(monIOR)
-          aShapeSO = salome.myStudy.FindObjectIOR(monIOR)
-          attrName  = aShapeSO.FindAttribute("AttributeName")[1]
-          anAttr = attrName._narrow(SALOMEDS.AttributeName)
-          Name = anAttr.Value()
-          newMesh.CreateGroupFromGEOM(SMESH.NODE,Name,GEOMShape)
+           aShapeSO = salome.myStudy.FindObjectIOR(monIOR)
+           attrName  = aShapeSO.FindAttribute("AttributeName")[1]
+           anAttr = attrName._narrow(SALOMEDS.AttributeName)
+           Name = anAttr.Value()
+           newMesh.CreateGroupFromGEOM(SMESH.NODE,Name,GEOMShape)
        for monIOR in dict_CL[GEOMIor].CLOnCell.keys():
-                  GEOMShape = salome.orb.string_to_object(monIOR)
+           GEOMShape = salome.orb.string_to_object(monIOR)
            aShapeSO = salome.myStudy.FindObjectIOR(monIOR)
            attrName  = aShapeSO.FindAttribute("AttributeName")[1]
-                  anAttr = attrName._narrow(SALOMEDS.AttributeName)
+           anAttr = attrName._narrow(SALOMEDS.AttributeName)
            Name = anAttr.Value()
            #_CS_cbo: ajout de la determination de la dimension de la geometrie
-           #newMesh.CreateGroupFromGEOM(SMESH.FACE,Name,GEOMShape)
-           ShapeType = GEOMShape.GetShapeType()
-           print ShapeType
-           if str(ShapeType) is "EDGE":
-               print "--------------- EDGE newMesh"
-               newMesh.CreateGroupFromGEOM(SMESH.EDGE,Name,GEOMShape)
-           else:
-               print "--------------- FACE newMesh"
-               newMesh.CreateGroupFromGEOM(SMESH.FACE,Name,GEOMShape)
+           type = self.getShapeType(GEOMShape)
+           newMesh.CreateGroupFromGEOM(type,Name,GEOMShape)
        del dict_CL[GEOMIor]
 
     def NomShape(self,numero):
@@ -102,8 +97,8 @@ class CLinit:
 # NodeorCell = 0 on traite des noeuds
 # NodeorCell = 1 on traite des mailles
 
-    def Possibles(self,numero):
-       GEOMIor = dict_CL.keys()[numero]
+    def Possibles(self,numero,GeomChoisie):
+       GEOMIor=self.correspondanceNomIORshape[str(GeomChoisie)]
        liste=[]
        if GEOMIor in self.Liste_maillages.keys():
         for MeshIor in self.Liste_maillages[GEOMIor]:
@@ -115,14 +110,65 @@ class CLinit:
            liste.append(Name)
        return liste
 
+
+    def MainShapes(self,numero):
+       GEOMIor = dict_CL.keys()[numero]
+       listeNoms=[]
+       for MainID in  self.Liste_geoms[GEOMIor]:
+           aSO = salome.myStudy.FindObjectID(MainID)
+          if aSO==None:
+             print "pb dans MainShapes"
+             return listeNoms
+          attrName  = aSO.FindAttribute("AttributeName")[1]
+          anAttr = attrName._narrow(SALOMEDS.AttributeName)
+          Name = anAttr.Value()
+          listeNoms.append(Name)
+          IORAttr = aSO.FindAttribute("AttributeIOR")[1]
+          anAttr  = IORAttr._narrow(SALOMEDS.AttributeIOR)
+          GEOMShapeIOR  = anAttr.Value()
+          self.correspondanceNomIORshape[Name]=GEOMShapeIOR
+       return listeNoms
+
+
+    def getShapeType(self,GEOMShape):
+       """
+       Determination du type de geometrie pour les conditions aux limites.
+       
+       Le type de geometrie determine le type de mailles.
+       Voir le dictionnnaire ShapeType dans geompy.py pour les correspondances type - numero.
+       """ 
+       type = []
+       tgeo = str(GEOMShape.GetShapeType())
+       if tgeo == "VERTEX":
+           type = SMESH.NODE
+       elif tgeo == "EDGE":
+           type = SMESH.EDGE
+       elif tgeo == "FACE":
+           type = SMESH.FACE
+       elif tgeo == "SOLID":
+           type = SMESH.VOLUME
+       elif tgeo == "COMPOUND":
+           tgeo = self.GroupOp.GetType(GEOMShape)
+           if tgeo == 7:
+               type = SMESH.NODE
+           elif tgeo == 6:
+               type = SMESH.EDGE
+           elif tgeo == 4:
+               type = SMESH.FACE
+           elif tgeo == 2:
+               type = SMESH.VOLUME
+       return type
+
     def get_maillages(self):
        self.Liste_maillages={}
        if self.smesh == None :
          self.smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
         self.smesh.SetCurrentStudy(salome.myStudy)
        stringIOR=salome.orb.object_to_string(self.smesh)
+       print stringIOR
        SO_smesh=salome.myStudy.FindObjectIOR(stringIOR)
        if SO_smesh != None:
+         print salome.myStudy
          ChildIterator = salome.myStudy.NewChildIterator(SO_smesh)
         while ChildIterator.More() :
            aSObj = ChildIterator.Value()
@@ -148,6 +194,55 @@ class CLinit:
                    else :
                     self.Liste_maillages[GEOMShapeIOR]=[MeshIOR]
 
+    def get_geoms(self):
+       self.Liste_geoms={}
+       for GeomCLIOR in dict_CL.keys():
+          self.Liste_geoms[GeomCLIOR]=[]
+         self.chercheMain(GeomCLIOR,GeomCLIOR)
+
+    def chercheMain(self,GEOMIor,GeomCLIOR):
+
+
+        sobj = salome.myStudy.FindObjectIOR(GEOMIor)
+       if sobj == None :
+          print "objet nul dans chercheMain"
+          return
+
+       # On cherche les dépendances et
+       # on ajoute l objet lui-même à la liste
+        Listedep=salome.myStudy.FindDependances(sobj)
+       Listedep.append(sobj)
+
+        ListeAtraiter=[]
+       for sobj in Listedep :
+          # tant que l objet est une reference
+          # on cherche son pere
+          current=sobj
+          boo,iorso = sobj.FindAttribute("AttributeIOR")
+          while ( boo==0 ) :
+             current=current.GetFather()
+             boo,iorso = current.FindAttribute("AttributeIOR")
+          iorString = iorso.Value()
+           shapeobj=salome.orb.string_to_object(iorString)
+          Shape=shapeobj._narrow(GEOM.GEOM_Object)
+          if Shape != None :
+             if self.geomcompID == None:
+                self.geomcompID = current.GetFatherComponent().GetID()
+             ListeAtraiter.append(current)
+
+       for sobj in ListeAtraiter:
+          current=sobj
+          while ( current.GetFather().GetID() != self.geomcompID):
+             current=current.GetFather()
+          MainID=current.GetID()
+          if (MainID not in self.Liste_geoms[GeomCLIOR]):
+             self.Liste_geoms[GeomCLIOR].append(MainID)
+             Attr = current.FindAttribute("AttributeIOR")[1]
+             if (Attr != None):
+                MainIORAttr  = Attr._narrow(SALOMEDS.AttributeIOR)
+                MainIor = MainIORAttr.Value()
+                self.chercheMain(MainIor,GeomCLIOR)
+
     def SetName(self,Entry, Name):
        SO = salome.myStudy.FindObjectID( Entry )
        if SO != None :
@@ -172,7 +267,7 @@ class CL:
          else :
             self.CLOnNode[CLName] = 1
       if (nodeOrCell == 1) :
-          print "FFFFFACCE"
+          print "MAILLE"
           if self.CLOnCell.has_key(CLName):
             self.CLOnCell[CLName] = self.CLOnCell[CLName] + 1
          else :