#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
+
+#CALCULATOR_TEST_WITHOUTIHM.py
+
from omniORB import CORBA
import salome
import SALOME
import SALOME_MED
+import SALOMEDS
-#CCRT :
import os
-import Engines
-import LifeCycleCORBA
-
host = os.getenv( 'HOST' )
-
-orb = CORBA.ORB_init([''], CORBA.ORB_ID)
-
-lcc = LifeCycleCORBA.LifeCycleCORBA(orb)
-#endCCRT
+orb, lcc, naming_service, contmgr = salome.salome_kernel.salome_kernel_init()
################ GET A MED FIELD FROM FILE pointe.med ###################
#
# This test program is based on the field named fieldcelldoublevector in
# med file $MED_ROOT_DIR/share/salome/resources/pointe.med
-from os import environ
-filePath=environ["MED_ROOT_DIR"]
-filePath=filePath+"/share/salome/resources/"
+filePath=os.environ["MED_ROOT_DIR"]
+filePath=filePath+"/share/salome/resources/med/"
medFile=filePath+"pointe.med"
-fieldname = "fieldcelldoublescalar"
+fieldname = "fieldcelldoublevector"
# Launch the Med Component and use it to load into memory the test field
print "Launch the Med Component: "
-#CCRTmed_comp = salome.lcc.FindOrLoadComponent("FactoryServer", "MED")
med_comp = lcc.FindOrLoadComponent("FactoryServer", "MED")
# Get a Corba field proxy on the distant field (located in the med_comp server).
try:
- studyname = salome.myStudyName
- studynameId = salome.myStudyId
+ obj = naming_service.Resolve('myStudyManager')
+ myStudyManager = obj._narrow(SALOMEDS.StudyManager)
+ print "studyManager found"
+ myStudy = myStudyManager.NewStudy('CALCULATOR_TEST')
+ studynameId = myStudy._get_StudyId()
+ studyname = myStudy._get_Name()
print "We are working in the study ",studyname," with the ID ",studynameId
print "Read field ",fieldname
fieldcell = med_comp.readFieldInFile(medFile,studyname,fieldname,-1,-1)
print fieldcelldouble.getName()
print fieldcelldouble.getDescription()
print fieldcelldouble.getNumberOfComponents()
+
#
#
-############## Load Calculator Component and test it ###################
-#
+############## Load Calculator Component ###################
+# Calculator Component must be in the Container of MED
#
print "Load Calculator Component "
# we need to import CALCULATOR_ORB to get a typed object (to perform narrowing)
import CALCULATOR_ORB
-calculator = salome.lcc.FindOrLoadComponent("FactoryServer", "CALCULATOR")
+calculator = lcc.FindOrLoadComponent("FactoryServer", "CALCULATOR")
+
+#
#
-print "Appel cloneField : fieldcelldouble -> f1,f2,f3,f4"
+############## Test Calculator Component ###################
+#
+#
+print "Appel cloneField : fieldcelldoublevector -> f1,f2,f3,f4"
(f1,f2,f3,f4)=calculator.cloneField(fieldcelldouble) # fieldcelldouble is consumed
#
+f1.Register()
calculator.printField(f1)
print "Add fields f2+f3"
f_add=calculator.add(f2, f3)
-calculator.printField(f_add)
+f_add.Register()
+calculator.printField( f_add ) # f_add is consumed
#
print "Apply linear function"
f_lin=calculator.applyLin(f4,2.0,1.0)
+f_lin.Register()
+calculator.printField( f_lin ) # f_lin is consumed
#
print "Appel Norme Max "
-norme=calculator.normMax(f_lin)
+f_lin.Register()
+norme=calculator.normMax(f_lin) # f_lin is consumed
print " -> norme = ",norme
#
+
print "End of Calculator Test!"