1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2012 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
24 # VISU VISU_SWIG : binding of C++ implementation and Python
34 if salome.hasDesktop():
35 from libSALOME_Swig import *
38 def getMedObjectFromStudy():
39 mySO = salome.myStudy.FindObject("Objet MED")
40 anAttr = mySO.FindAttribute("AttributeIOR")[1]
41 obj = salome.orb.string_to_object(anAttr.Value())
42 myObj = obj._narrow(SALOME_MED.MED)
45 def getFieldObjectFromStudy(number,subnumber):
46 mySO = salome.myStudy.FindObject("MEDFIELD")
47 mysub = mySO.FindSubObject(number)[1]
49 mysubsub = mysub.FindSubObject(subnumber)[1]
51 Builder = salome.myStudy.NewBuilder()
52 anAttr = Builder.FindOrCreateAttribute(mysubsub, "AttributeIOR")
53 obj = salome.orb.string_to_object(anAttr.Value())
54 myObj = obj._narrow(SALOME_MED.FIELDINT)
56 myObj = obj._narrow(SALOME_MED.FIELDDOUBLE)
59 print "ERROR: No Field Object stored in this Study"
62 med_comp = salome.lcc.FindOrLoadComponent("FactoryServer", "MED")
64 medDir = os.getenv('DATA_DIR') + '/MedFiles/'
66 def importMedFrom(medDir,medFile):
67 medFile = medDir + medFile
68 med_comp.readStructFileWithFieldType(medFile,salome.myStudyName)
69 if salome.hasDesktop():
70 sg.updateObjBrowser(1)
72 def importMed(medFile):
73 importMedFrom(medDir,medFile)
75 #med_obj = getMedObjectFromStudy()
76 myVisu = salome.lcc.FindOrLoadComponent("FactoryServer", "VISU")
77 myVisu.SetCurrentStudy(salome.myStudy)
78 print "Use importMed(medFile) or importMedFrom(medDir,medFile) functions !"
80 #myField = getFieldObjectFromStudy(2,1)
81 #myResult = myVisu.ImportMed(myField)
82 #aMesh = myVisu.CreateMesh(myResult);
83 #aScalarMap = myVisu.CreateScalarMap(myResult,myField.getName(),0)
84 #if(myField.getNumberOfComponents() > 1) :
85 # aScalarMap = myVisu.CreateVectors(myResult,myField.getName(),0)
87 #myResult = myVisu.ImportFile(medFile)
88 #aMesh = myVisu.CreateMesh(myResult);
89 #aScalarMap = myVisu.CreateScalarMap(myResult,myField.getName(),0)
90 #if(myField.getNumberOfComponents() > 1) :
91 # aScalarMap = myVisu.CreateCutPlanes(myResult,myField.getName(),0)