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.2 2004/12/10 16:43:25 salome Exp $
8 #=============================================================================
10 from omniORB import CORBA
17 orb = CORBA.ORB_init([''], CORBA.ORB_ID)
19 # create an LifeCycleCORBA instance
20 lcc = LifeCycleCORBA.LifeCycleCORBA(orb)
22 geom = lcc.FindOrLoadComponent("FactoryServer", "GEOM")
23 smesh = lcc.FindOrLoadComponent("FactoryServer", "SMESH")
25 #--------------------------------------------------------------------------
27 def entryToIor(myStudy,entry):
29 Retourne une référence ior de l'entry passée en argument.
32 iorString = entryToIorString(myStudy,entry)
34 ior = orb.string_to_object(iorString)
37 def entryToIorString(myStudy,entry):
39 Retourne la sérialisation de l'ior de l'entry passée en
40 argument. Il s'agit de l'attribut AttributeIOR associé à l'entry
43 myBuilder = myStudy.NewBuilder()
47 SO = myStudy.FindObjectID(entry)
49 print "invalid entry: ",entry
52 boo,iorso = myBuilder.FindAttribute(SO,"AttributeIOR")
54 print "no IOR attribute on study object: ", entry
56 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(myStudy,entry):
117 Cette méthode retourne une référence ior de l'objet principal qui
118 contient l'entry passée en argument.
120 anObject=entryToIor(myStudy,entry)
121 subShape=anObject._narrow(GEOM.GEOM_Object)
122 iorMain = subShape.GetMainShape()
126 def getMainShapeName(myStudy,entry):
128 Retourne la sérialisation de l'ior du MainShape de l'entry passé
131 iorMain = getMainShape(myStudy,entry)
134 iorStringMain= orb.object_to_string(iorMain)
137 #--------------------------------------------------------------------------
139 def getSMESHSubShapeIndexes(myStudy, entryList, typenoeudorcell = 0):
140 # typenoeudorcell = 0 on traite des noeuds
141 # typenoeudorcell = 1 on traite des faces
145 print "################ len(entryList)=", len(entryList)
146 if len(entryList) > 0:
147 iorStringMain = getMainShapeName(myStudy, entryList[0])
149 if iorStringMain == None:
150 raise RuntimeException("L'ior CORBA n'est pas défini")
152 print "################ iorStringMain=", iorStringMain
154 myCL=smesh.GetOrCreateCL(str(iorStringMain))
156 if len(entryList) > 0:
157 for idShape in entryList:
160 refShape = singleEntryToName(myStudy,idShape)
162 for Shape in refShape:
163 refList.append(Shape)
164 IORShape = entryToIor(myStudy,idShape)
165 myCL.SetIdAsCL(orb.object_to_string(IORShape),typenoeudorcell)
167 studyId = myStudy._get_StudyId()
170 #--------------------------------------------------------------------------
172 def getAsterGroupNo(myStudy,entryList):
174 subShapeIndexes = getSMESHSubShapeIndexes(myStudy, entryList,typenoeudorcell)
176 for val in subShapeIndexes:
177 labelGroupNo.append(val)
180 #--------------------------------------------------------------------------
182 def getAsterGroupMa(myStudy,entryList):
184 subShapeIndexes = getSMESHSubShapeIndexes(myStudy, entryList,typenoeudorcell)
186 for val in subShapeIndexes:
188 print "################> val = ", val
189 labelGroupMa.append(val)
192 #--------------------------------------------------------------------------