6 import MonChoixMaillage
13 geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
14 self.GroupOp = geom.GetIGroupOperations(salome.myStudyId)
17 self._d = SalomePyQt.SalomePyQt().getDesktop()
18 self.correspondanceNomIOR = {}
19 self.correspondanceNomIORshape = {}
23 def GetOrCreateCL(self,myShapeName):
24 if not (dict_CL.has_key(myShapeName)):
25 dict_CL[myShapeName] = CL()
26 return dict_CL[myShapeName]
32 # Récupere tous les Mesh
34 Choix=MonChoixMaillage.MonChoixMaillage(self,0,self._d)
35 salome.sg.updateObjBrowser(0)
38 def traiteMaillage(self,indiceIOR,NomMaillage):
39 MeshIOR = self.correspondanceNomIOR[str(NomMaillage)]
40 Mesh = salome.orb.string_to_object(MeshIOR)
41 GEOMIor = dict_CL.keys()[indiceIOR]
42 for monIOR in dict_CL[GEOMIor].CLOnNode.keys():
43 GEOMShape = salome.orb.string_to_object(monIOR)
44 aShapeSO = salome.myStudy.FindObjectIOR(monIOR)
45 attrName = aShapeSO.FindAttribute("AttributeName")[1]
46 anAttr = attrName._narrow(SALOMEDS.AttributeName)
48 Mesh.CreateGroupFromGEOM(SMESH.NODE,Name,GEOMShape)
49 for monIOR in dict_CL[GEOMIor].CLOnCell.keys():
50 GEOMShape = salome.orb.string_to_object(monIOR)
51 aShapeSO = salome.myStudy.FindObjectIOR(monIOR)
52 attrName = aShapeSO.FindAttribute("AttributeName")[1]
53 anAttr = attrName._narrow(SALOMEDS.AttributeName)
55 #_CS_cbo: ajout de la determination de la dimension de la geometrie
56 type = self.getShapeType(GEOMShape)
57 Mesh.CreateGroupFromGEOM(type,Name,GEOMShape)
61 def traiteNewMaillage(self,numero,indiceIOR,NomMaillage):
62 GEOMIor=dict_CL.keys()[numero]
63 GEOMShapeIor=self.correspondanceNomIORshape[str(indiceIOR)]
64 shape = salome.orb.string_to_object(GEOMShapeIor)
65 if self.smesh == None :
66 self.smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
67 self.smesh.SetCurrentStudy(salome.myStudy)
69 newMesh = self.smesh.CreateMesh(shape)
70 self.SetName(salome.ObjectToID(newMesh),NomMaillage)
71 for monIOR in dict_CL[GEOMIor].CLOnNode.keys():
72 GEOMShape = salome.orb.string_to_object(monIOR)
73 aShapeSO = salome.myStudy.FindObjectIOR(monIOR)
74 attrName = aShapeSO.FindAttribute("AttributeName")[1]
75 anAttr = attrName._narrow(SALOMEDS.AttributeName)
77 newMesh.CreateGroupFromGEOM(SMESH.NODE,Name,GEOMShape)
78 for monIOR in dict_CL[GEOMIor].CLOnCell.keys():
79 GEOMShape = salome.orb.string_to_object(monIOR)
80 aShapeSO = salome.myStudy.FindObjectIOR(monIOR)
81 attrName = aShapeSO.FindAttribute("AttributeName")[1]
82 anAttr = attrName._narrow(SALOMEDS.AttributeName)
84 #_CS_cbo: ajout de la determination de la dimension de la geometrie
85 type = self.getShapeType(GEOMShape)
86 newMesh.CreateGroupFromGEOM(type,Name,GEOMShape)
89 def NomShape(self,numero):
90 GEOMIor = dict_CL.keys()[numero]
91 aShapeSO = salome.myStudy.FindObjectIOR(GEOMIor)
92 attrName = aShapeSO.FindAttribute("AttributeName")[1]
93 anAttr = attrName._narrow(SALOMEDS.AttributeName)
97 # NodeorCell = 0 on traite des noeuds
98 # NodeorCell = 1 on traite des mailles
100 def Possibles(self,numero,GeomChoisie):
101 GEOMIor=self.correspondanceNomIORshape[str(GeomChoisie)]
103 if GEOMIor in self.Liste_maillages.keys():
104 for MeshIor in self.Liste_maillages[GEOMIor]:
105 aMeshSO = salome.myStudy.FindObjectIOR(MeshIor)
106 attrName = aMeshSO.FindAttribute("AttributeName")[1]
107 anAttr = attrName._narrow(SALOMEDS.AttributeName)
108 Name = anAttr.Value()
109 self.correspondanceNomIOR[Name] = MeshIor
114 def MainShapes(self,numero):
115 GEOMIor = dict_CL.keys()[numero]
117 for MainID in self.Liste_geoms[GEOMIor]:
118 aSO = salome.myStudy.FindObjectID(MainID)
120 print "pb dans MainShapes"
122 attrName = aSO.FindAttribute("AttributeName")[1]
123 anAttr = attrName._narrow(SALOMEDS.AttributeName)
124 Name = anAttr.Value()
125 listeNoms.append(Name)
126 IORAttr = aSO.FindAttribute("AttributeIOR")[1]
127 anAttr = IORAttr._narrow(SALOMEDS.AttributeIOR)
128 GEOMShapeIOR = anAttr.Value()
129 self.correspondanceNomIORshape[Name]=GEOMShapeIOR
133 def getShapeType(self,GEOMShape):
135 Determination du type de geometrie pour les conditions aux limites.
137 Le type de geometrie determine le type de mailles.
138 Voir le dictionnnaire ShapeType dans geompy.py pour les correspondances type - numero.
141 tgeo = str(GEOMShape.GetShapeType())
148 elif tgeo == "SOLID":
150 elif tgeo == "COMPOUND":
151 tgeo = self.GroupOp.GetType(GEOMShape)
162 def get_maillages(self):
163 self.Liste_maillages={}
164 if self.smesh == None :
165 self.smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
166 self.smesh.SetCurrentStudy(salome.myStudy)
167 stringIOR=salome.orb.object_to_string(self.smesh)
169 SO_smesh=salome.myStudy.FindObjectIOR(stringIOR)
172 ChildIterator = salome.myStudy.NewChildIterator(SO_smesh)
173 while ChildIterator.More() :
174 aSObj = ChildIterator.Value()
176 anAttr =aSObj.FindAttribute("AttributeName")[1]
177 anAttr = anAttr._narrow(SALOMEDS.AttributeName)
178 Name = anAttr.Value()
179 if (Name != "Hypotheses" and Name != "Algorithms"):
180 res, Ref = aSObj.FindSubObject( Tag_RefOnShape )
182 ok,MyShapeSO = Ref.ReferencedObject()
184 IORAttr = MyShapeSO.FindAttribute("AttributeIOR")[1]
185 anAttr = IORAttr._narrow(SALOMEDS.AttributeIOR)
186 GEOMShapeIOR = anAttr.Value()
188 IORAttr2 = aSObj.FindAttribute("AttributeIOR")[1]
189 anAttr2 = IORAttr2._narrow(SALOMEDS.AttributeIOR)
190 MeshIOR = anAttr2.Value()
192 if GEOMShapeIOR in self.Liste_maillages.keys():
193 self.Liste_maillages[GEOMShapeIOR].append(MeshIOR)
195 self.Liste_maillages[GEOMShapeIOR]=[MeshIOR]
199 for GeomCLIOR in dict_CL.keys():
200 self.Liste_geoms[GeomCLIOR]=[]
201 self.chercheMain(GeomCLIOR,GeomCLIOR)
203 def chercheMain(self,GEOMIor,GeomCLIOR):
206 sobj = salome.myStudy.FindObjectIOR(GEOMIor)
208 print "objet nul dans chercheMain"
211 # On cherche les dépendances et
212 # on ajoute l objet lui-même à la liste
213 Listedep=salome.myStudy.FindDependances(sobj)
214 Listedep.append(sobj)
217 for sobj in Listedep :
218 # tant que l objet est une reference
219 # on cherche son pere
221 boo,iorso = sobj.FindAttribute("AttributeIOR")
223 current=current.GetFather()
224 boo,iorso = current.FindAttribute("AttributeIOR")
225 iorString = iorso.Value()
226 shapeobj=salome.orb.string_to_object(iorString)
227 Shape=shapeobj._narrow(GEOM.GEOM_Object)
229 if self.geomcompID == None:
230 self.geomcompID = current.GetFatherComponent().GetID()
231 ListeAtraiter.append(current)
233 for sobj in ListeAtraiter:
235 while ( current.GetFather().GetID() != self.geomcompID):
236 current=current.GetFather()
237 MainID=current.GetID()
238 if (MainID not in self.Liste_geoms[GeomCLIOR]):
239 self.Liste_geoms[GeomCLIOR].append(MainID)
240 Attr = current.FindAttribute("AttributeIOR")[1]
242 MainIORAttr = Attr._narrow(SALOMEDS.AttributeIOR)
243 MainIor = MainIORAttr.Value()
244 self.chercheMain(MainIor,GeomCLIOR)
246 def SetName(self,Entry, Name):
247 SO = salome.myStudy.FindObjectID( Entry )
249 myStudyBuilder = salome.myStudy.NewBuilder()
250 aName = myStudyBuilder.FindOrCreateAttribute(SO, "AttributeName")
259 # nodeOrCell = 0 on traite des noeuds
260 # nodeOrCell = 1 on traite des faces
262 def SetIdAsCL(self,CLName,nodeOrCell):
263 if (nodeOrCell == 0) :
265 if self.CLOnNode.has_key(CLName):
266 self.CLOnNode[CLName] = self.CLOnNode[CLName] + 1
268 self.CLOnNode[CLName] = 1
269 if (nodeOrCell == 1) :
271 if self.CLOnCell.has_key(CLName):
272 self.CLOnCell[CLName] = self.CLOnCell[CLName] + 1
274 self.CLOnCell[CLName] = 1
276 def UnSetIdAsCL(self,CLName,nodeOrCell):
277 if (nodeOrCell == 0) :
278 if self.CLOnNode.has_key(CLName):
279 self.CLOnNode[CLName] = self.CLOnNode[CLName] - 1
280 if (nodeOrCell == 1) :
281 if self.CLOnCell.has_key(CLName):
282 self.CLOnCell[CLName] = self.CLOnCell[CLName] - 1