X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FKERNEL_PY%2Fsalome_test.py;h=76dceacd467a9874ce0f7e58d8ff434286e39b21;hb=1119e0f3b0ead5c13e8f458fc9a75b7797420dd8;hp=5bac523fe75a4530508f89b14c9d416b5e339351;hpb=7a07650dd1f183f5af156c1235cc1d67061813ec;p=modules%2Fkernel.git diff --git a/src/KERNEL_PY/salome_test.py b/src/KERNEL_PY/salome_test.py index 5bac523fe..76dceacd4 100755 --- a/src/KERNEL_PY/salome_test.py +++ b/src/KERNEL_PY/salome_test.py @@ -1,5 +1,5 @@ # -*- 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 @@ -7,7 +7,7 @@ # 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 @@ -54,7 +54,7 @@ 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 @@ -63,7 +63,7 @@ print "======================================================================" print " %d. Check modules availability in the module catalog " % step; step+=1 print "======================================================================" -for module in [ "GEOM", "SMESH", "MEDOPFactory", "PARAVIS"]: +for module in [ "GEOM", "SMESH", "MEDFactory", "PVSERVER"]: print print "--- Check %s ..." % module comp = catalog.GetComponent(module) @@ -111,7 +111,8 @@ 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 @@ -162,7 +163,7 @@ print "OK" # ---- update object browser if salome.hasDesktop(): - salome.sg.updateObjBrowser(1); + salome.sg.updateObjBrowser(True); print @@ -170,22 +171,20 @@ 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 ..." @@ -301,7 +300,7 @@ print "OK" # ---- update object browser if salome.hasDesktop(): - salome.sg.updateObjBrowser(1); + salome.sg.updateObjBrowser(True); print @@ -309,16 +308,19 @@ 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 @@ -326,7 +328,7 @@ fieldHandler1 = fieldHandlerList[1] 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." @@ -349,13 +351,10 @@ print "======================================================================" if salome.hasDesktop(): # in gui mode - print "**** Importing paravis... It can take some time." - from presentations import * - import paravis + print "**** Importing pvserver... It can take some time." + import pvserver import pvsimple - my_paravis = paravis.myParavis - #====================Stage1: Importing MED file==================== print "**** Stage1: Importing MED file" @@ -363,7 +362,7 @@ if salome.hasDesktop(): # in gui mode print 'Import "ResOK_0000.med"...............', medFileName = "ResOK_0000.med" medFile = os.path.join(os.getenv('DATA_DIR'), 'MedFiles', medFileName) - my_paravis.ImportFile(medFile) + pvsimple.MEDReader( FileName=medFile ) med_reader = pvsimple.GetActiveSource() if med_reader is None: @@ -371,75 +370,34 @@ if salome.hasDesktop(): # in gui mode else: print "OK" - cell_entity = EntityType.CELL - node_entity = EntityType.NODE - - #====================Stage2: Displaying vector field=============== + #====================Stage2: Displaying presentation=============== - print "**** Stage3: Displaying vector field" + print "**** Stage2: Displaying presentation" print 'Get view...................', view = pvsimple.GetRenderView() if view is None: print "FAILED" else: - reset_view(view) print "OK" - print "Creating Scalar Map.......", - scalarmap = ScalarMapOnField(med_reader, node_entity, 'vitesse', 1) - if scalarmap is None: + print "Creating presentation.......", + prs = pvsimple.GetRepresentation(med_reader) + if prs is None: print "FAILED" else: - bar = get_bar() - bar.Orientation = 'Horizontal' - bar.Position = [0.1, 0.1] - bar.Position2 = [0.1, 0.25] - bar.AspectRatio = 3 + rep_list = view.Representations + for rep in rep_list: + if hasattr(rep, 'Visibility'): + rep.Visibility = (rep == prs) + pvsimple.Render(view=view) - display_only(scalarmap, view) - print "OK" - - view.ResetCamera() - - print "Creating Vectors..........", - vectors = VectorsOnField(med_reader, node_entity, 'vitesse', 1) - if vectors is None: - print "FAILED" - else: - display_only(vectors, view) - print "OK" - - print "Creating Iso Surfaces.....", - isosurfaces = IsoSurfacesOnField(med_reader, node_entity, 'vitesse', 1) - if isosurfaces is None: - print "FAILED" - else: - display_only(isosurfaces, view) - print "OK" - - print "Creating Cut Planes.......", - cutplanes = CutPlanesOnField(med_reader, node_entity, 'vitesse', 1, - nb_planes=30, orientation=Orientation.YZ) - if cutplanes is None: - print "FAILED" - else: - display_only(cutplanes, view) + # ---- surface representation + prs.SetRepresentationType('Surface') + view.ResetCamera() + print "OK" - print "Creating Scalar Map On Deformed Shape.......", - scalarmapondefshape = DeformedShapeAndScalarMapOnField(med_reader, - node_entity, - 'vitesse', 1, - None, - cell_entity, - 'pression') - if scalarmapondefshape is None: - print "FAILED" - else: - display_only(scalarmapondefshape, view) - print "OK" - else: # not in gui mode, Paravis can not be tested print @@ -450,4 +408,4 @@ else: # not in gui mode, Paravis can not be tested # ---- update object browser if salome.hasDesktop(): - salome.sg.updateObjBrowser(1); + salome.sg.updateObjBrowser(True);