1 # VISU VISU_SWIG : binding of C++ implementation and Python
3 # Copyright (C) 2003 CEA/DEN, EDF R&D
7 # File : visu_prs_exam.py
18 from libSALOME_Swig import *
22 myVisu = visu_gui.myVisu
24 medFile = "pointe.med"
26 medFile = os.getenv('KERNEL_ROOT_DIR') + '/examples/' + medFile
29 studyCurrent = salome.myStudyName
31 med_comp = salome.lcc.FindOrLoadComponent("FactoryServer", "MED")
32 #myVisu = salome.lcc.FindOrLoadComponent("FactoryServer", "Visu")
35 if os.access(medFile, os.R_OK) :
36 print "Reading the .med file ",medFile," and pushing corba objects in the SALOME study"
37 med_comp.readStructFileWithFieldType(medFile,studyCurrent)
38 med_obj = visu_gui.visu.getMedObjectFromStudy(absMedFile)
39 print "med_obj - ", med_obj
42 nbOfMeshes = med_obj.getNumberOfMeshes()
43 print "in this med file there is(are) ",nbOfMeshes," mesh(es),"
44 meshNames = med_obj.getMeshNames()
45 meshName = meshNames[0]
47 supportName = "SupportOnAll_MED_NOEUD"
49 nbOfFields = med_obj.getNumberOfFields()
50 print "and ",nbOfFields," field(s)."
51 fieldNames = med_obj.getFieldNames()
52 fieldName = fieldNames[1]
53 nbOfIt = med_obj.getFieldNumberOfIteration(fieldName)
54 print "the field ",fieldName," has ",nbOfIt," iteration(s)"
55 dtitsfield = med_obj.getFieldIterations(fieldName)
56 dtitfield = dtitsfield[0:2]
60 ## myField = visu_gui.visu.getFieldObjectFromStudy(2,1)
61 # the first iteration of the second field
62 myField = visu_gui.visu.getFieldObjectFromStudy(dt, it, fieldName,
65 aMeshName = "FILED_DOUBLE_MESH"
69 myResult1 = myVisu.ImportMedField(myField)
70 aMesh1 = myVisu.MeshOnEntity(myResult1, aMeshName, anEntity);
72 aScalarMap1= myVisu.ScalarMapOnField(myResult1, aMeshName, anEntity, myField.getName(), aTimeStampId)
73 if(myField.getNumberOfComponents() > 1) :
74 aVectors = myVisu.VectorsOnField(myResult1, aMeshName, anEntity, myField.getName(), aTimeStampId)
76 myResult2 = myVisu.ImportFile(medFile)
79 aMesh2 = myVisu.MeshOnEntity(myResult2, aMeshName, anEntity)
81 aScalarMap2 = myVisu.ScalarMapOnField(myResult2, aMeshName, anEntity, myField.getName(), aTimeStampId)
82 if(myField.getNumberOfComponents() > 1) :
83 aCutPlanes = myVisu.CutPlanesOnField(myResult2, aMeshName, anEntity, myField.getName(), aTimeStampId)
85 sg.updateObjBrowser(0)
86 else : print "We have no permission to read medFile, it will not be opened";
88 if sys.exc_type == SALOME.SALOME_Exception :
89 print "There is no permission to read " + medFile
93 print sys.exc_traceback