1 # VISU VISU_SWIG : binding of C++ implementation and Python
3 # Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License.
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
31 if salome.hasDesktop():
32 from libSALOME_Swig import *
35 def getMedObjectFromStudy():
36 mySO = salome.myStudy.FindObject("Objet MED")
37 anAttr = mySO.FindAttribute("AttributeIOR")[1]
38 obj = salome.orb.string_to_object(anAttr.Value())
39 myObj = obj._narrow(SALOME_MED.MED)
42 def getFieldObjectFromStudy(number,subnumber):
43 mySO = salome.myStudy.FindObject("MEDFIELD")
44 mysub = mySO.FindSubObject(number)[1]
46 mysubsub = mysub.FindSubObject(subnumber)[1]
48 Builder = salome.myStudy.NewBuilder()
49 anAttr = Builder.FindOrCreateAttribute(mysubsub, "AttributeIOR")
50 obj = salome.orb.string_to_object(anAttr.Value())
51 myObj = obj._narrow(SALOME_MED.FIELDINT)
53 myObj = obj._narrow(SALOME_MED.FIELDDOUBLE)
56 print "ERROR: No Field Object stored in this Study"
59 med_comp = salome.lcc.FindOrLoadComponent("FactoryServer", "MED")
61 medDir = os.getenv('DATA_DIR') + '/MedFiles/'
63 def importMedFrom(medDir,medFile):
64 medFile = medDir + medFile
65 med_comp.readStructFileWithFieldType(medFile,salome.myStudyName)
66 if salome.hasDesktop():
67 sg.updateObjBrowser(1)
69 def importMed(medFile):
70 importMedFrom(medDir,medFile)
72 #med_obj = getMedObjectFromStudy()
73 myVisu = salome.lcc.FindOrLoadComponent("FactoryServer", "VISU")
74 print "Use importMed(medFile) or importMedFrom(medDir,medFile) functions !"
76 #myField = getFieldObjectFromStudy(2,1)
77 #myResult = myVisu.ImportMed(myField)
78 #aMesh = myVisu.CreateMesh(myResult);
79 #aScalarMap = myVisu.CreateScalarMap(myResult,myField.getName(),0)
80 #if(myField.getNumberOfComponents() > 1) :
81 # aScalarMap = myVisu.CreateVectors(myResult,myField.getName(),0)
83 #myResult = myVisu.ImportFile(medFile)
84 #aMesh = myVisu.CreateMesh(myResult);
85 #aScalarMap = myVisu.CreateScalarMap(myResult,myField.getName(),0)
86 #if(myField.getNumberOfComponents() > 1) :
87 # aScalarMap = myVisu.CreateCutPlanes(myResult,myField.getName(),0)