myLocalVisu = None
myDelay = None
mySession = None
-
-def changeBlankToUnderScore(stringWithBlank):
- blank = ' '
- underscore = '_'
- decompString = split(stringWithBlank,blank)
- length = len(decompString)
- stringWithUnderScore = decompString[0]
- for i in range(1,length):
- stringWithUnderScore += underscore
- stringWithUnderScore += decompString[i]
- return stringWithUnderScore
-
+
def Initialize(theORB, theNamingService, theLifeCycleCORBA, theStudyManager, theStudy, theDelay) :
global myORB, myNamingService, myLifeCycleCORBA, myLocalStudyManager, myLocalStudy
global mySession, myLocalVisu, myDelay
return [aStudy, myViewManager, myView]
raise RuntimeError, "Error: There is no shuch file."
-##def getMedObjectFromStudy(theStudy = myLocalStudy):
-## if theStudy is None:
-## theStudy = myLocalStudy
-## mySO = theStudy.FindObject("Objet MED")
-## anAttr = mySO.FindAttribute("AttributeIOR")[1]
-## obj = myORB.string_to_object(anAttr.Value())
-## myObj = obj._narrow(SALOME_MED.MED)
-## return myObj
-
-def getMedObjectFromStudy(file, theStudy = myLocalStudy):
- objNameInStudy = "MED_OBJECT_FROM_FILE_"+file
- compNameInStudy= "MED"
-
+def getMedObjectFromStudy(theStudy = myLocalStudy):
if theStudy is None:
theStudy = myLocalStudy
+ mySO = theStudy.FindObject("Objet MED")
+ anAttr = mySO.FindAttribute("AttributeIOR")[1]
+ obj = myORB.string_to_object(anAttr.Value())
+ myObj = obj._narrow(SALOME_MED.MED)
+ return myObj
- listOfSO = theStudy.FindObjectByName(objNameInStudy,compNameInStudy)
- listLength = len(listOfSO)
- if (listLength == 0) :
- print "PROBLEME ",objNameInStudy," cannot be found in the Study under the component ",compNameInStudy
- return None
- elif (listLength > 1) :
- print "PROBLEME there are more than one instance of ",objNameInStudy," in the Study under the component ",compNameInStudy
- return None
- mySO = listOfSO[0]
- if (mySO == None) :
- print "PROBLEM ",objNameInStudy," cannot be found in the Study"
- return mySO
- else:
- anAttr = mySO.FindAttribute("AttributeIOR")[1]
- obj = myORB.string_to_object(anAttr.Value())
- myObj = obj._narrow(SALOME_MED.MED)
- if (myObj == None) :
- print "PROBLEM ",objNameInStudy," has been found in the Study but with the wrong type"
- return myObj
-
-##def getMedSObject(theStudy = myLocalStudy ):
-## return theStudy.FindObject("Objet MED")
-
-def getMedSObject(file, theStudy = myLocalStudy ):
- objNameInStudy = "MED_OBJECT_FROM_FILE_"+file
- compNameInStudy= "MED"
+def getMedSObject(theStudy = myLocalStudy ):
+ return theStudy.FindObject("Objet MED")
+def getFieldObjectFromStudy(number, subnumber, theStudy = myLocalStudy):
if theStudy is None:
theStudy = myLocalStudy
-
- listOfSO = theStudy.FindObjectByName(objNameInStudy,compNameInStudy)
- listLength = len(listOfSO)
- if (listLength == 0) :
- print "PROBLEME ",objNameInStudy," cannot be found in the Study under the component ",compNameInStudy
- return None
- elif (listLength > 1) :
- print "PROBLEME there are more than one instance of ",objNameInStudy," in the Study under the component ",compNameInStudy
- return None
- mySO = listOfSO[0]
- return mySO
-
-##def getFieldObjectFromStudy(number, subnumber, theStudy = myLocalStudy):
-## if theStudy is None:
-## theStudy = myLocalStudy
-## mySO = theStudy.FindObject("MEDFIELD")
-## if mySO is None:
-## raise Runtime, "getFieldObjectFromStudy mySO is None"
-## mysub = mySO.FindSubObject(number)[1]
-## if mysub:
-## mysubsub = mysub.FindSubObject(subnumber)[1]
-## if mysubsub:
-## Builder = theStudy.NewBuilder()
-## anAttr = Builder.FindOrCreateAttribute(mysubsub, "AttributeIOR")
-## obj = myORB.string_to_object(anAttr.Value())
-## myObj = obj._narrow(SALOME_MED.FIELDINT)
-## if (myObj == None):
-## myObj = obj._narrow(SALOME_MED.FIELDDOUBLE)
-## return myObj
-## else:
-## print "ERROR: No Field Object stored in this Study"
-## return None
-
-def getFieldObjectFromStudy(dt, it, fieldName, supportName, meshName,
- theStudy = myLocalStudy):
- meshNameStudy = changeBlankToUnderScore(meshName)
- if theStudy is None:
- theStudy = myLocalStudy
-
- objNameInStudy = "/Med/MEDFIELD/"+fieldName+"/("+str(dt)+","+str(it)+")_ON_"+supportName+"_OF_"+meshNameStudy
- mySO = theStudy.FindObjectByPath(objNameInStudy)
- if (mySO == None) :
- print "PROBLEM ",objNameInStudy," cannot be found in the Study"
- return mySO
+ mySO = theStudy.FindObject("MEDFIELD")
+ if mySO is None:
+ raise Runtime, "getFieldObjectFromStudy mySO is None"
+ mysub = mySO.FindSubObject(number)[1]
+ if mysub:
+ mysubsub = mysub.FindSubObject(subnumber)[1]
+ if mysubsub:
+ Builder = theStudy.NewBuilder()
+ anAttr = Builder.FindOrCreateAttribute(mysubsub, "AttributeIOR")
+ obj = myORB.string_to_object(anAttr.Value())
+ myObj = obj._narrow(SALOME_MED.FIELDINT)
+ if (myObj == None):
+ myObj = obj._narrow(SALOME_MED.FIELDDOUBLE)
+ return myObj
else:
- anAttr = mySO.FindAttribute("AttributeIOR")[1]
- obj = myORB.string_to_object(anAttr.Value())
- myObj = obj._narrow(SALOME_MED.FIELDINT)
- if (myObj == None):
- myObj = obj._narrow(SALOME_MED.FIELDDOUBLE)
- if (myObj == None) :
- print "PROBLEM ",objNameInStudy," has been found in the Study but with the wrong type"
- return myObj
+ print "ERROR: No Field Object stored in this Study"
+ return None
def SObjectToObject(theSObject) :
# global myORB
print "aMedComp.readStructFileWithFieldType...",
aMedComp.readStructFileWithFieldType(theFileName,myLocalStudy._get_Name())
- print "reading the med file is OK ..."
-
- # taking the absolute name of theFileName (without the path to it)
- decompFileName = split(theFileName,"/")
- lenDecomp = len(decompFileName)
- absFileName = decompFileName[lenDecomp-1]
-
- aMedSObj = getMedSObject(absFileName,myLocalStudy)
+ aMedSObj = getMedSObject(myLocalStudy)
if aMedSObj is None : raise RuntimeError, "Error"
else : print "OK"
else : print "OK"
aVISUObjList.append(aResult)
aVISUObjList.extend(CreatePrsForResult(theVisu, aResult, myView, thePrsTypeList, thePictureDir, thePictureExt))
-
+
aFolderIter = myLocalStudy.NewChildIterator(aMedSObj.GetFather());
while aFolderIter.More() :
aFolderSObj = aFolderIter.Value()
myVisu = visu_gui.myVisu
medFile = "pointe.med"
-absMedFile = medFile
medFile = os.getenv('KERNEL_ROOT_DIR') + '/examples/' + medFile
print medFile
try:
if os.access(medFile, os.R_OK) :
- print "Reading the .med file ",medFile," and pushing corba objects in the SALOME study"
- med_comp.readStructFileWithFieldType(medFile,studyCurrent)
- med_obj = visu_gui.visu.getMedObjectFromStudy(absMedFile)
- print "med_obj - ", med_obj
-
-
- nbOfMeshes = med_obj.getNumberOfMeshes()
- print "in this med file there is(are) ",nbOfMeshes," mesh(es),"
- meshNames = med_obj.getMeshNames()
- meshName = meshNames[0]
-
- supportName = "SupportOnAll_MED_NOEUD"
-
- nbOfFields = med_obj.getNumberOfFields()
- print "and ",nbOfFields," field(s)."
- fieldNames = med_obj.getFieldNames()
- fieldName = fieldNames[1]
- nbOfIt = med_obj.getFieldNumberOfIteration(fieldName)
- print "the field ",fieldName," has ",nbOfIt," iteration(s)"
- dtitsfield = med_obj.getFieldIterations(fieldName)
- dtitfield = dtitsfield[0:2]
- dt = dtitfield[0]
- it = dtitfield[1]
-
-## myField = visu_gui.visu.getFieldObjectFromStudy(2,1)
- # the first iteration of the second field
- myField = visu_gui.visu.getFieldObjectFromStudy(dt, it, fieldName,
- supportName,
- meshName)
- aMeshName = "FILED_DOUBLE_MESH"
- anEntity = VISU.NODE
- aTimeStampId = 0
+ if os.access(medFile, os.W_OK) :
+ med_comp.readStructFileWithFieldType(medFile,studyCurrent)
+ med_obj = visu_gui.visu.getMedObjectFromStudy()
+ print "med_obj - ", med_obj
+
+ myField = visu_gui.visu.getFieldObjectFromStudy(2,1)
+ aMeshName = "FILED_DOUBLE_MESH"
+ anEntity = VISU.NODE
+ aTimeStampId = 0
- myResult1 = myVisu.ImportMedField(myField)
- aMesh1 = myVisu.MeshOnEntity(myResult1, aMeshName, anEntity);
+ myResult1 = myVisu.ImportMedField(myField)
+ aMesh1 = myVisu.MeshOnEntity(myResult1, aMeshName, anEntity);
- aScalarMap1= myVisu.ScalarMapOnField(myResult1, aMeshName, anEntity, myField.getName(), aTimeStampId)
- if(myField.getNumberOfComponents() > 1) :
- aVectors = myVisu.VectorsOnField(myResult1, aMeshName, anEntity, myField.getName(), aTimeStampId)
+ aScalarMap1= myVisu.ScalarMapOnField(myResult1, aMeshName, anEntity, myField.getName(), aTimeStampId)
+ if(myField.getNumberOfComponents() > 1) :
+ aVectors = myVisu.VectorsOnField(myResult1, aMeshName, anEntity, myField.getName(), aTimeStampId)
- myResult2 = myVisu.ImportFile(medFile)
- aMeshName = "maa1"
- anEntity = VISU.NODE
- aMesh2 = myVisu.MeshOnEntity(myResult2, aMeshName, anEntity)
+ myResult2 = myVisu.ImportFile(medFile)
+ aMeshName = "maa1"
+ anEntity = VISU.NODE
+ aMesh2 = myVisu.MeshOnEntity(myResult2, aMeshName, anEntity)
- aScalarMap2 = myVisu.ScalarMapOnField(myResult2, aMeshName, anEntity, myField.getName(), aTimeStampId)
- if(myField.getNumberOfComponents() > 1) :
- aCutPlanes = myVisu.CutPlanesOnField(myResult2, aMeshName, anEntity, myField.getName(), aTimeStampId)
+ aScalarMap2 = myVisu.ScalarMapOnField(myResult2, aMeshName, anEntity, myField.getName(), aTimeStampId)
+ if(myField.getNumberOfComponents() > 1) :
+ aCutPlanes = myVisu.CutPlanesOnField(myResult2, aMeshName, anEntity, myField.getName(), aTimeStampId)
- sg.updateObjBrowser(0)
+ sg.updateObjBrowser(0)
+ else : print "We have no permission to rewrite medFile, so readStructFileWithFieldType can't open this file";
else : print "We have no permission to read medFile, it will not be opened";
except:
if sys.exc_type == SALOME.SALOME_Exception :