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.5 2005/02/03 15:15:09 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
161 if len(entryList) > 0:
162 for idShape in entryList:
164 anObject=entryToIor(myStudy,idShape)
165 Shape=anObject._narrow(GEOM.GEOM_Object)
166 iorStringMain=orb.object_to_string(Shape)
168 print "pb avec l IOR: pas un objet"
170 if iorStringMain == None:
171 # C'est le cas ou on a loade un fichier hdf et on est pas passe par geom
175 myCL=myCLinit.GetOrCreateCL(iorStringMain)
176 refShape = singleEntryToName(myStudy,idShape)
178 for Shape in refShape:
179 refList.append(Shape)
180 IORShape = entryToIor(myStudy,idShape)
181 myCL.SetIdAsCL(orb.object_to_string(IORShape),typenoeudorcell)
185 #--------------------------------------------------------------------------
187 def getAsterGroupNo(myStudy,entryList):
189 subShapeIndexes = getSMESHSubShapeIndexes(myStudy, entryList,typenoeudorcell)
191 if subShapeIndexes == None :
192 print "*************************************"
193 print "Pb au chargement de Geom --> pas d IOR"
194 print "*************************************"
196 for val in subShapeIndexes:
197 labelGroupNo.append(val)
200 #--------------------------------------------------------------------------
202 def getAsterGroupMa(myStudy,entryList):
204 subShapeIndexes = getSMESHSubShapeIndexes(myStudy, entryList,typenoeudorcell)
206 if subShapeIndexes == None :
207 print "*************************************"
208 print "Pb au chargement de Geom --> pas d IOR"
209 print "*************************************"
211 for val in subShapeIndexes:
212 labelGroupMa.append(val)
215 #--------------------------------------------------------------------------
217 def VisuGroupe(myStudy,GroupesListe):
219 aGuiDS=salomedsgui.guiDS()
220 aGuiDS.ClearSelection()
221 aGuiDS.DisplayByNameInGeom(GroupesListe)