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
33 if salome.hasDesktop():
34 from libSALOME_Swig import *
37 def getMedObjectFromStudy():
38 mySO = salome.myStudy.FindObject("Objet MED")
39 anAttr = mySO.FindAttribute("AttributeIOR")[1]
40 obj = salome.orb.string_to_object(anAttr.Value())
41 myObj = obj._narrow(SALOME_MED.MED)
44 def getFieldObjectFromStudy(number,subnumber):
45 mySO = salome.myStudy.FindObject("MEDFIELD")
46 mysub = mySO.FindSubObject(number)[1]
48 mysubsub = mysub.FindSubObject(subnumber)[1]
50 Builder = salome.myStudy.NewBuilder()
51 anAttr = Builder.FindOrCreateAttribute(mysubsub, "AttributeIOR")
52 obj = salome.orb.string_to_object(anAttr.Value())
53 myObj = obj._narrow(SALOME_MED.FIELDINT)
55 myObj = obj._narrow(SALOME_MED.FIELDDOUBLE)
58 print "ERROR: No Field Object stored in this Study"
61 med_comp = salome.lcc.FindOrLoadComponent("FactoryServer", "MED")
63 medDir = os.getenv('DATA_DIR') + '/MedFiles/'
65 def importMedFrom(medDir,medFile):
66 medFile = medDir + medFile
67 med_comp.readStructFileWithFieldType(medFile,salome.myStudyName)
68 if salome.hasDesktop():
69 sg.updateObjBrowser(1)
71 def importMed(medFile):
72 importMedFrom(medDir,medFile)
74 #med_obj = getMedObjectFromStudy()
75 myVisu = salome.lcc.FindOrLoadComponent("FactoryServer", "VISU")
76 myVisu.SetCurrentStudy(salome.myStudy)
77 print "Use importMed(medFile) or importMedFrom(medDir,medFile) functions !"
79 #myField = getFieldObjectFromStudy(2,1)
80 #myResult = myVisu.ImportMed(myField)
81 #aMesh = myVisu.CreateMesh(myResult);
82 #aScalarMap = myVisu.CreateScalarMap(myResult,myField.getName(),0)
83 #if(myField.getNumberOfComponents() > 1) :
84 # aScalarMap = myVisu.CreateVectors(myResult,myField.getName(),0)
86 #myResult = myVisu.ImportFile(medFile)
87 #aMesh = myVisu.CreateMesh(myResult);
88 #aScalarMap = myVisu.CreateScalarMap(myResult,myField.getName(),0)
89 #if(myField.getNumberOfComponents() > 1) :
90 # aScalarMap = myVisu.CreateCutPlanes(myResult,myField.getName(),0)