1 #=============================================================================
2 # File : SMESH_utils.py
3 # Created : jeu fév 20 18:53:34 CET 2003
4 # Author : Paul RASCLE, EDF
7 # $Header: /home/salome/PlateFormePAL/Bases_CVS_EDF/Modules_EDF/EFICAS_SRC/src/EFICASGUI/SMESH_utils.py,v 1.4 2005/02/01 10:55:41 salome Exp $
8 #=============================================================================
10 from omniORB import CORBA
15 from eficasCL import *
18 orb = CORBA.ORB_init([''], CORBA.ORB_ID)
20 # create an LifeCycleCORBA instance
21 lcc = LifeCycleCORBA.LifeCycleCORBA(orb)
23 geom = lcc.FindOrLoadComponent("FactoryServer", "GEOM")
24 smesh = lcc.FindOrLoadComponent("FactoryServer", "SMESH")
26 #--------------------------------------------------------------------------
28 def entryToIor(myStudy,entry):
30 Retourne une référence ior de l'entry passée en argument.
33 iorString = entryToIorString(myStudy,entry)
35 ior = orb.string_to_object(iorString)
38 def entryToIorString(myStudy,entry):
40 Retourne la sérialisation de l'ior de l'entry passée en
41 argument. Il s'agit de l'attribut AttributeIOR associé à l'entry
44 myBuilder = myStudy.NewBuilder()
48 SO = myStudy.FindObjectID(entry)
50 print "invalid entry: ",entry
53 boo,iorso = myBuilder.FindAttribute(SO,"AttributeIOR")
55 print "no IOR attribute on study object: ", entry
57 iorString = iorso.Value()
61 #--------------------------------------------------------------------------
63 def singleEntryToName(myStudy,entry):
65 Retourne le nom l'entry passée en argument. Il s'agit de
66 l'attribut AttributeName associé à l'entry dans l'arbre d'étude.
68 myBuilder = myStudy.NewBuilder()
72 SO = myStudy.FindObjectID(entry)
74 print "invalid entry: ",entry
77 boo,nameso = myBuilder.FindAttribute(SO,"AttributeName")
79 print "no Name attribute on study object: ", entry
81 name.append(nameso.Value())
84 def entryListToName(myStudy,entryList):
86 Récupération de la liste des noms à partir d'une liste d'entry.
88 myBuilder = myStudy.NewBuilder()
91 for entry in entryList:
93 SO = myStudy.FindObjectID(entry)
95 print "invalid entry: ",entry
98 boo,nameso = myBuilder.FindAttribute(SO,"AttributeName")
100 print "no Name attribute on study object: ", entry
102 name.append(nameso.Value())
105 def entryToName(myStudy,entryList):
107 Cette méthode sert juste à assurer la compatibilité avec le
108 logiciel Eficas. Eficas (panelsSalome.py) fait appel à entryToList
109 en passant une entryList en argument.
111 return entryListToName(myStudy,entryList)
114 #--------------------------------------------------------------------------
115 def getMainShape(anObject):
117 Cette méthode retourne une référence ior de l'objet principal qui
118 contient l'entry passée en argument.
121 subShape=anObject._narrow(GEOM.GEOM_Object)
122 objMain = subShape.GetMainShape()
123 IORobjMain = orb.object_to_string(objMain)
128 def getShapeContenante(myStudy,entry):
130 anObject=entryToIor(myStudy,entry)
131 Shape=anObject._narrow(GEOM.GEOM_Object)
132 ShapeIor=orb.object_to_string(Shape)
134 print "pb avec l IOR: pas un objet"
137 MainShapeIOR=ShapeIor
138 while anObject != None :
139 iorStringMain = getMainShape(anObject)
140 if iorStringMain == None :
142 if ( MainShapeIOR != iorStringMain ):
143 anObject = orb.string_to_object(iorStringMain)
145 MainShapeIOR=iorStringMain
151 #--------------------------------------------------------------------------
153 def getSMESHSubShapeIndexes(myStudy, entryList, typenoeudorcell = 0):
154 # typenoeudorcell = 0 on traite des noeuds
155 # typenoeudorcell = 1 on traite des faces
159 if len(entryList) > 0:
160 # PN : prévoir une boucle ???
161 # Pour etre sure que toutes les faces appartiennent à la meme strucute ??
162 iorStringMain = getShapeContenante(myStudy, entryList[0])
164 if iorStringMain == None:
165 # C'est le cas ou on a loade un fichier hdf et on est pas passe par geom
170 myCL=myCLinit.GetOrCreateCL(iorStringMain)
172 if len(entryList) > 0:
173 for idShape in entryList:
174 refShape = singleEntryToName(myStudy,idShape)
176 for Shape in refShape:
177 refList.append(Shape)
178 IORShape = entryToIor(myStudy,idShape)
179 myCL.SetIdAsCL(orb.object_to_string(IORShape),typenoeudorcell)
183 #--------------------------------------------------------------------------
185 def getAsterGroupNo(myStudy,entryList):
187 subShapeIndexes = getSMESHSubShapeIndexes(myStudy, entryList,typenoeudorcell)
189 for val in subShapeIndexes:
190 labelGroupNo.append(val)
193 #--------------------------------------------------------------------------
195 def getAsterGroupMa(myStudy,entryList):
197 subShapeIndexes = getSMESHSubShapeIndexes(myStudy, entryList,typenoeudorcell)
199 for val in subShapeIndexes:
200 labelGroupMa.append(val)
203 #--------------------------------------------------------------------------