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
20 #CALCULATOR_TEST_WITHOUTIHM.py
22 from omniORB import CORBA
30 host = os.getenv( 'HOST' )
31 orb, lcc, naming_service, contmgr = salome.salome_kernel.salome_kernel_init()
33 ################ GET A MED FIELD FROM FILE pointe.med ###################
35 # This test program is based on the field named fieldcelldoublevector in
36 # med file $MED_ROOT_DIR/share/salome/resources/pointe.med
37 filePath=os.environ["MED_ROOT_DIR"]
38 filePath=filePath+"/share/salome/resources/med/"
39 medFile=filePath+"pointe.med"
40 fieldname = "fieldcelldoublevector"
42 # Launch the Med Component and use it to load into memory the test field
43 print "Launch the Med Component: "
44 med_comp = lcc.FindOrLoadComponent("FactoryServer", "MED")
46 # Get a Corba field proxy on the distant field (located in the med_comp server).
48 obj = naming_service.Resolve('myStudyManager')
49 myStudyManager = obj._narrow(SALOMEDS.StudyManager)
50 print "studyManager found"
51 myStudy = myStudyManager.NewStudy('CALCULATOR_TEST')
52 studynameId = myStudy._get_StudyId()
53 studyname = myStudy._get_Name()
54 print "We are working in the study ",studyname," with the ID ",studynameId
55 print "Read field ",fieldname
56 fieldcell = med_comp.readFieldInFile(medFile,studyname,fieldname,-1,-1)
57 fieldcelldouble = fieldcell._narrow(SALOME_MED.FIELDDOUBLE)
58 except SALOME.SALOME_Exception, ex:
62 print ex.details.sourceFile
63 print ex.details.lineNumber
66 print "Description of Field : "
68 print fieldcelldouble.getName()
69 print fieldcelldouble.getDescription()
70 print fieldcelldouble.getNumberOfComponents()
74 ############## Load Calculator Component ###################
75 # Calculator Component must be in the Container of MED
77 print "Load Calculator Component "
78 # we need to import CALCULATOR_ORB to get a typed object (to perform narrowing)
80 calculator = lcc.FindOrLoadComponent("FactoryServer", "CALCULATOR")
84 ############## Test Calculator Component ###################
87 print "Appel cloneField : fieldcelldoublevector -> f1,f2,f3,f4"
88 (f1,f2,f3,f4)=calculator.cloneField(fieldcelldouble) # fieldcelldouble is consumed
91 calculator.printField(f1)
92 print "Add fields f2+f3"
93 f_add=calculator.add(f2, f3)
95 calculator.printField( f_add ) # f_add is consumed
98 print "Apply linear function"
99 f_lin=calculator.applyLin(f4,2.0,1.0)
101 calculator.printField( f_lin ) # f_lin is consumed
103 print "Appel Norme Max "
105 norme=calculator.normMax(f_lin) # f_lin is consumed
106 print " -> norme = ",norme
109 print "End of Calculator Test!"