1 # Copyright (C) 2005 CEA/DEN, EDF R&D
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 from omniORB import CORBA
30 host = os.getenv( 'HOST' )
32 orb = CORBA.ORB_init([''], CORBA.ORB_ID)
34 lcc = LifeCycleCORBA.LifeCycleCORBA(orb)
37 ################ GET A MED FIELD FROM FILE pointe.med ###################
39 # This test program is based on the field named fieldcelldoublevector in
40 # med file $MED_ROOT_DIR/share/salome/resources/pointe.med
41 from os import environ
42 filePath=environ["MED_ROOT_DIR"]
43 filePath=filePath+"/share/salome/resources/"
44 medFile=filePath+"pointe.med"
45 fieldname = "fieldcelldoublescalar"
47 # Launch the Med Component and use it to load into memory the test field
48 print "Launch the Med Component: "
49 #CCRTmed_comp = salome.lcc.FindOrLoadComponent("FactoryServer", "MED")
50 med_comp = lcc.FindOrLoadComponent("FactoryServer", "MED")
52 # Get a Corba field proxy on the distant field (located in the med_comp server).
54 studyname = salome.myStudyName
55 studynameId = salome.myStudyId
56 print "We are working in the study ",studyname," with the ID ",studynameId
57 print "Read field ",fieldname
58 fieldcell = med_comp.readFieldInFile(medFile,studyname,fieldname,-1,-1)
59 fieldcelldouble = fieldcell._narrow(SALOME_MED.FIELDDOUBLE)
60 except SALOME.SALOME_Exception, ex:
64 print ex.details.sourceFile
65 print ex.details.lineNumber
68 print "Description of Field : "
70 print fieldcelldouble.getName()
71 print fieldcelldouble.getDescription()
72 print fieldcelldouble.getNumberOfComponents()
75 ############## Load Calculator Component and test it ###################
78 print "Load Calculator Component "
79 # we need to import CALCULATOR_ORB to get a typed object (to perform narrowing)
81 calculator = salome.lcc.FindOrLoadComponent("FactoryServer", "CALCULATOR")
83 print "Appel cloneField : fieldcelldouble -> f1,f2,f3,f4"
84 (f1,f2,f3,f4)=calculator.cloneField(fieldcelldouble) # fieldcelldouble is consumed
86 calculator.printField(f1)
87 print "Add fields f2+f3"
88 f_add=calculator.add(f2, f3)
89 calculator.printField(f_add)
92 print "Apply linear function"
93 f_lin=calculator.applyLin(f4,2.0,1.0)
95 print "Appel Norme Max "
96 norme=calculator.normMax(f_lin)
97 print " -> norme = ",norme
99 print "End of Calculator Test!"