1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
4 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License.
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this library; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 # VISU VISU_SWIG : binding of C++ implementation and Python
24 # File : visu_prs_exam.py
35 if salome.hasDesktop():
36 from libSALOME_Swig import *
39 myVisu = visu_gui.myVisu
41 myVisu.SetCurrentStudy(salome.myStudy)
43 medFile = "pointe.med"
44 medFile = os.getenv('DATA_DIR') + '/MedFiles/' + medFile
47 studyCurrent = salome.myStudyName
49 med_comp = salome.lcc.FindOrLoadComponent("FactoryServer", "MED")
50 #myVisu = salome.lcc.FindOrLoadComponent("FactoryServer", "Visu")
53 if os.access(medFile, os.R_OK) :
54 if os.access(medFile, os.W_OK) :
55 med_comp.readStructFileWithFieldType(medFile,studyCurrent)
56 med_obj = visu_gui.visu.getMedObjectFromStudy()
57 print "med_obj - ", med_obj
59 myField = visu_gui.visu.getFieldObjectFromStudy(2,1)
60 aMeshName = "FILED_DOUBLE_MESH"
64 myResult1 = myVisu.ImportMedField(myField)
65 aMesh1 = myVisu.MeshOnEntity(myResult1, aMeshName, anEntity);
67 aScalarMap1= myVisu.ScalarMapOnField(myResult1, aMeshName, anEntity, myField.getName(), aTimeStampId)
68 if(myField.getNumberOfComponents() > 1) :
69 aVectors = myVisu.VectorsOnField(myResult1, aMeshName, anEntity, myField.getName(), aTimeStampId)
71 myResult2 = myVisu.ImportFile(medFile)
74 aMesh2 = myVisu.MeshOnEntity(myResult2, aMeshName, anEntity)
76 aScalarMap2 = myVisu.ScalarMapOnField(myResult2, aMeshName, anEntity, myField.getName(), aTimeStampId)
77 if(myField.getNumberOfComponents() > 1) :
78 aCutPlanes = myVisu.CutPlanesOnField(myResult2, aMeshName, anEntity, myField.getName(), aTimeStampId)
79 if salome.hasDesktop():
80 sg.updateObjBrowser(0)
81 else : print "We have no permission to rewrite medFile, so readStructFileWithFieldType can't open this file";
82 else : print "We have no permission to read medFile, it will not be opened";
84 if sys.exc_type == SALOME.SALOME_Exception :
85 print "There is no permission to read " + medFile
89 print sys.exc_traceback