# -*- coding: iso-8859-1 -*-
-# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
#
# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
-# version 2.1 of the License.
+# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
#
print
-print "Perform quick test of the application by loading of the GEOM, SMESH, VISU, MED"
+print "Perform quick test of the application by loading of the GEOM, SMESH, MED, PARAVIS"
print "components and doing some operation within the components."
print
obj = salome.naming_service.Resolve('Kernel/ModulCatalog')
catalog = obj._narrow(SALOME_ModuleCatalog.ModuleCatalog)
if not catalog:
- raise RuntimeError, "Can't accesss module catalog"
+ raise RuntimeError, "Can't access module catalog"
print "OK"
print
print " %d. Check modules availability in the module catalog " % step; step+=1
print "======================================================================"
-print
-print "--- Check GEOM ..."
-comp = catalog.GetComponent("GEOM")
-if not comp:
- raise RuntimeError, "Component GEOM is not found in Module Catalog."
-print "OK"
-
-print
-print "--- Check SMESH ..."
-comp = catalog.GetComponent("SMESH")
-if not comp:
- raise RuntimeError, "Component SMESH is not found in Module Catalog."
-print "OK"
-
-print
-print "--- Check MED ..."
-comp = catalog.GetComponent("MED")
-if not comp:
- raise RuntimeError, "Component MED is not found in Module Catalog."
-print "OK"
-
-print
-print "--- Check VISU ..."
-comp = catalog.GetComponent("VISU")
-if not comp:
- raise RuntimeError, "Component VISU is not found in Module Catalog."
-print "OK"
+for module in [ "GEOM", "SMESH", "MEDFactory", "PVSERVER"]:
+ print
+ print "--- Check %s ..." % module
+ comp = catalog.GetComponent(module)
+ if not comp:
+ raise RuntimeError, "Component %s is not found in Module Catalog." % module
+ print "OK"
+ pass
print
print " %d. Test Geometry " % step; step+=1
print "======================================================================"
-import geompy
+from salome.geom import geomBuilder
+geompy = geomBuilder.New(salome.myStudy)
ShapeTypeCompSolid = 1
ShapeTypeSolid = 2
# ---- update object browser
if salome.hasDesktop():
- salome.sg.updateObjBrowser(1);
+ salome.sg.updateObjBrowser(True);
print
print " %d. Test Mesh " % step; step+=1
print "======================================================================"
-import StdMeshers
+from salome.StdMeshers import StdMeshersBuilder
import SMESH
+from salome.smesh import smeshBuilder
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
if salome.hasDesktop():
smeshgui = salome.ImportComponentGUI("SMESH")
smeshgui.Init(salome.myStudyId);
else:
- smesh.SetCurrentStudy(salome.myStudy)
+ smesh = smeshBuilder.New(salome.myStudy)
# ---- create hypotheses
-if sys.platform == "win32":
- stdMeshersEngine = "StdMeshersEngine"
-else:
- stdMeshersEngine = "libStdMeshersEngine.so"
+stdMeshersEngine = "StdMeshersEngine"
print
print "--- Create hypotheses ..."
# ---- update object browser
if salome.hasDesktop():
- salome.sg.updateObjBrowser(1);
+ salome.sg.updateObjBrowser(True);
print
print " %d. Test Med " % step; step+=1
print "======================================================================"
-import xmed
-from xmed import properties
-from xmed.fieldproxy import FieldProxy
+import medcalc
+#from medcalc import properties
+from medcalc.fieldproxy import FieldProxy
-xmed.setConsoleGlobals(globals())
+medcalc.medconsole.setConsoleGlobals(globals())
+try:
+ med_root=os.environ["MED_ROOT_DIR"]
+except KeyError, e:
+ raise RuntimeError("MED_ROOT_DIR should be defined to load the test data")
-# Load some test data in the MedDataManager
-filepath = properties.testFilePath
-xmed.dataManager.addDatasource(filepath)
-fieldHandlerList = xmed.dataManager.getFieldHandlerList()
+filepath = os.path.join(med_root,"share","salome","resources","med","medcalc_testfiles","smallmesh_varfield.med")
+medcalc.medio.LoadDataSource(filepath)
+fieldHandlerList = medcalc.medevents.dataManager.getFieldHandlerList()
fieldHandler0 = fieldHandlerList[0]
print "---Field Handler 0:\n%s" % fieldHandler0
print "---Field Handler 1:\n%s" % fieldHandler1
print "--- The addition of two fields can be done using field handler directly."
-addFieldHandler = xmed.calculator.add(fieldHandler0, fieldHandler1)
+addFieldHandler = medcalc.fieldproxy.calculator.add(fieldHandler0,fieldHandler1)
print "--- Result handler:\n%s" % addFieldHandler
print "--- Or with a field proxy that easy the writing of operations."
print
+
print "======================================================================"
-print " %d. Test Post-Pro " % step; step+=1
+print " %d. Test Paravis " % step; step+=1
print "======================================================================"
-import VISU
-
-medFileName = "pointe.med"
-medFile = os.path.join(os.getenv('DATA_DIR'), 'MedFiles', medFileName)
-
-aMeshName = "maa1"
-anEntity = VISU.NODE
-field_name = "fieldnodedouble"
-
if salome.hasDesktop(): # in gui mode
-
- import visu_gui
- visu = salome.lcc.FindOrLoadComponent("FactoryServer", "VISU")
-
- print
- print "--- Import med file %s to the VISU ..." % medFile
- result2 = visu.ImportFile(medFile);
- if not result2:
- raise RuntimeError, "Can't import file"
- print "OK"
- print
- print "--- Create mesh presentation ..."
- mesh2 = visu.MeshOnEntity(result2, aMeshName, anEntity);
- if not mesh2:
- raise RuntimeError, "Can't create mesh presentation"
- print "OK"
-
- print
- print "--- Create scalar map ..."
- scalarMap2 = visu.ScalarMapOnField(result2, aMeshName, anEntity, field_name, 3)
- if not scalarMap2:
- raise RuntimeError, "Can't create scalar map"
- print "OK"
- pass
-
-else: # not in gui mode, visu can not be tested
+ print "**** Importing pvserver... It can take some time."
+ import pvserver
+ import pvsimple
+
+ #====================Stage1: Importing MED file====================
+
+ print "**** Stage1: Importing MED file"
+
+ print 'Import "ResOK_0000.med"...............',
+ medFileName = "ResOK_0000.med"
+ medFile = os.path.join(os.getenv('DATA_DIR'), 'MedFiles', medFileName)
+ pvsimple.MEDReader( FileName=medFile )
+ med_reader = pvsimple.GetActiveSource()
+
+ if med_reader is None:
+ print "FAILED"
+ else:
+ print "OK"
+
+ #====================Stage2: Displaying presentation===============
+
+ print "**** Stage2: Displaying presentation"
+
+ print 'Get view...................',
+ view = pvsimple.GetRenderView()
+ if view is None:
+ print "FAILED"
+ else:
+ print "OK"
+
+ print "Creating presentation.......",
+ prs = pvsimple.GetRepresentation(med_reader)
+ if prs is None:
+ print "FAILED"
+ else:
+ rep_list = view.Representations
+ for rep in rep_list:
+ if hasattr(rep, 'Visibility'):
+ rep.Visibility = (rep == prs)
+ pvsimple.Render(view=view)
+
+ # ---- surface representation
+ prs.SetRepresentationType('Surface')
+ view.ResetCamera()
+
+ print "OK"
+
+else: # not in gui mode, Paravis can not be tested
print
- print "VISU module requires SALOME to be running in GUI mode."
+ print "PARAVIS module requires SALOME to be running in GUI mode."
print
- print "Skipping test for VISU..."
+ print "Skipping test for PARAVIS..."
pass
# ---- update object browser
if salome.hasDesktop():
- salome.sg.updateObjBrowser(1);
+ salome.sg.updateObjBrowser(True);