5 import MonChoixMaillage
13 self._d = SalomePyQt.SalomePyQt().getDesktop()
15 self.listeDejaTraites= []
17 self.correspondanceNomIOR = {}
20 def GetOrCreateCL(self,myShapeName):
21 if not (dict_CL.has_key(myShapeName)):
22 dict_CL[myShapeName] = CL()
23 return dict_CL[myShapeName]
25 def chercheAtraiter(self):
29 print self.listeDejaTraites
30 while curseur < len(dict_CL):
31 GEOMIor=self.Liste_Shape[curseur]
32 if GEOMIor not in self.listeDejaTraites:
39 # Récupere tous les Mesh
40 if self.Liste_Shape == {}:
41 self.Liste_Shape = dict_CL.keys()
42 atraiter=self.chercheAtraiter()
44 Choix=MonChoixMaillage.MonChoixMaillage(self,atraiter,self._d)
45 salome.sg.updateObjBrowser(0)
47 def traiteMaillage(self,indiceIOR,NomMaillage):
48 MeshIOR = self.correspondanceNomIOR[str(NomMaillage)]
49 Mesh = salome.orb.string_to_object(MeshIOR)
50 GEOMIor =self.Liste_Shape[indiceIOR]
51 for monIOR in dict_CL[GEOMIor].CLOnNode.keys():
52 GEOMShape = salome.orb.string_to_object(monIOR)
53 aShapeSO = salome.myStudy.FindObjectIOR(monIOR)
54 attrName = aShapeSO.FindAttribute("AttributeName")[1]
55 anAttr = attrName._narrow(SALOMEDS.AttributeName)
57 Mesh.CreateGroupFromGEOM(SMESH.NODE,Name,GEOMShape)
58 for monIOR in dict_CL[GEOMIor].CLOnCell.keys():
59 GEOMShape = salome.orb.string_to_object(monIOR)
60 aShapeSO = salome.myStudy.FindObjectIOR(monIOR)
61 attrName = aShapeSO.FindAttribute("AttributeName")[1]
62 anAttr = attrName._narrow(SALOMEDS.AttributeName)
64 Mesh.CreateGroupFromGEOM(SMESH.FACE,Name,GEOMShape)
65 self.listeDejaTraites.append(GEOMIor)
68 def traiteNewMaillage(self,indiceIOR,NomMaillage):
69 GEOMIor =self.Liste_Shape[indiceIOR]
71 print dict_CL[GEOMIor].CLOnNode.keys()
72 print dict_CL[GEOMIor].CLOnCell.keys()
73 shape = salome.orb.string_to_object(GEOMIor)
74 if self.smesh == None :
75 self.smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
76 self.smesh.SetCurrentStudy(salome.myStudy)
78 newMesh = self.smesh.CreateMesh(shape)
79 self.SetName(salome.ObjectToID(newMesh),NomMaillage)
80 for monIOR in dict_CL[GEOMIor].CLOnNode.keys():
81 GEOMShape = salome.orb.string_to_object(monIOR)
82 aShapeSO = salome.myStudy.FindObjectIOR(monIOR)
83 attrName = aShapeSO.FindAttribute("AttributeName")[1]
84 anAttr = attrName._narrow(SALOMEDS.AttributeName)
86 newMesh.CreateGroupFromGEOM(SMESH.NODE,Name,GEOMShape)
87 for monIOR in dict_CL[GEOMIor].CLOnCell.keys():
88 GEOMShape = salome.orb.string_to_object(monIOR)
89 aShapeSO = salome.myStudy.FindObjectIOR(monIOR)
90 attrName = aShapeSO.FindAttribute("AttributeName")[1]
91 anAttr = attrName._narrow(SALOMEDS.AttributeName)
93 newMesh.CreateGroupFromGEOM(SMESH.FACE,Name,GEOMShape)
94 self.listeDejaTraites.append(GEOMIor)
96 def NomShape(self,numero):
97 GEOMIor=self.Liste_Shape[numero]
98 aShapeSO = salome.myStudy.FindObjectIOR(GEOMIor)
99 attrName = aShapeSO.FindAttribute("AttributeName")[1]
100 anAttr = attrName._narrow(SALOMEDS.AttributeName)
101 Name = anAttr.Value()
104 # NodeorCell = 0 on traite des noeuds
105 # NodeorCell = 1 on traite des mailles
107 def Possibles(self,numero):
108 GEOMIor=self.Liste_Shape[numero]
110 for MeshIor in self.Liste_maillages[GEOMIor]:
111 aMeshSO = salome.myStudy.FindObjectIOR(MeshIor)
112 attrName = aMeshSO.FindAttribute("AttributeName")[1]
113 anAttr = attrName._narrow(SALOMEDS.AttributeName)
114 Name = anAttr.Value()
115 self.correspondanceNomIOR[Name] = MeshIor
119 def get_maillages(self):
120 self.Liste_maillages={}
121 if self.smesh == None :
122 self.smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
123 self.smesh.SetCurrentStudy(salome.myStudy)
124 stringIOR=salome.orb.object_to_string(self.smesh)
125 SO_smesh=salome.myStudy.FindObjectIOR(stringIOR)
127 ChildIterator = salome.myStudy.NewChildIterator(SO_smesh)
128 while ChildIterator.More() :
129 aSObj = ChildIterator.Value()
131 anAttr =aSObj.FindAttribute("AttributeName")[1]
132 anAttr = anAttr._narrow(SALOMEDS.AttributeName)
133 Name = anAttr.Value()
134 if (Name != "Hypotheses" and Name != "Algorithms"):
135 res, Ref = aSObj.FindSubObject( Tag_RefOnShape )
137 ok,MyShapeSO = Ref.ReferencedObject()
139 IORAttr = MyShapeSO.FindAttribute("AttributeIOR")[1]
140 anAttr = IORAttr._narrow(SALOMEDS.AttributeIOR)
141 GEOMShapeIOR = anAttr.Value()
143 IORAttr2 = aSObj.FindAttribute("AttributeIOR")[1]
144 anAttr2 = IORAttr2._narrow(SALOMEDS.AttributeIOR)
145 MeshIOR = anAttr2.Value()
147 if GEOMShapeIOR in self.Liste_maillages.keys():
148 self.Liste_maillages[GEOMShapeIOR].append(MeshIOR)
150 self.Liste_maillages[GEOMShapeIOR]=[MeshIOR]
152 def SetName(self,Entry, Name):
153 SO = salome.myStudy.FindObjectID( Entry )
155 myStudyBuilder = salome.myStudy.NewBuilder()
156 aName = myStudyBuilder.FindOrCreateAttribute(SO, "AttributeName")
165 # nodeOrCell = 0 on traite des noeuds
166 # nodeOrCell = 1 on traite des faces
168 def SetIdAsCL(self,CLName,nodeOrCell):
169 if (nodeOrCell == 0) :
170 if self.CLOnNode.has_key(CLName):
171 self.CLOnNode[CLName] = self.CLOnNode[CLName] + 1
173 self.CLOnNode[CLName] = 1
174 if (nodeOrCell == 1) :
175 if self.CLOnCell.has_key(CLName):
176 self.CLOnCell[CLName] = self.CLOnCell[CLName] + 1
178 self.CLOnCell[CLName] = 1
180 def UnSetIdAsCL(self,CLName,nodeOrCell):
181 if (nodeOrCell == 0) :
182 if self.CLOnNode.has_key(CLName):
183 self.CLOnNode[CLName] = self.CLOnNode[CLName] - 1
184 if (nodeOrCell == 1) :
185 if self.CLOnCell.has_key(CLName):
186 self.CLOnCell[CLName] = self.CLOnCell[CLName] - 1