From c7d14d3fa3d9468fe1465f540f46e31a7754f9b4 Mon Sep 17 00:00:00 2001 From: vsr Date: Mon, 11 Apr 2011 12:05:28 +0000 Subject: [PATCH] Modify basic salome test for series 6x --- src/KERNEL_PY/salome_test.py | 653 ++++++++++++++--------------------- 1 file changed, 253 insertions(+), 400 deletions(-) diff --git a/src/KERNEL_PY/salome_test.py b/src/KERNEL_PY/salome_test.py index 7ecdf9e52..b61d149dd 100755 --- a/src/KERNEL_PY/salome_test.py +++ b/src/KERNEL_PY/salome_test.py @@ -21,94 +21,130 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -# SALOME SALOME_SWIG : binding of C++ implementation and Python -# File : salome_test.py -# Module : SALOME -# -print "Test the application loading GEOM, SMESH, VISU, MED, components and doing some" -print "operation within the components." +print +print "Perform quick test of the application by loading of the GEOM, SMESH, VISU, MED" +print "components and doing some operation within the components." +print import salome -from salome import sg import SALOMEDS import os import sys - import SALOME_ModuleCatalog +step = 1 + print "======================================================================" -print " Check, that there is no data of MED component in the Study " +print " %d. Initialize study " % step; step+=1 print "======================================================================" -MedComp = salome.myStudy.FindComponent("MED") -if MedComp is not None: - print "" - print "This script cannot work properly, because there are" - print "some MED component data already exists in the study." - print "Execution aborted." - print "" - raise RuntimeError, "Please, run this script only in a new empty study." +# initialize study +salome.salome_init() +# get study builder +builder = salome.myStudy.NewBuilder() +print "OK" + +print print "======================================================================" -print " Get Catalog " +print " %d. Retrieve module catalog " % step; step+=1 print "======================================================================" + obj = salome.naming_service.Resolve('Kernel/ModulCatalog') catalog = obj._narrow(SALOME_ModuleCatalog.ModuleCatalog) +if not catalog: + raise RuntimeError, "Can't accesss module catalog" +print "OK" + +print print "======================================================================" -print " Create Study " +print " %d. Check modules availability in the module catalog " % step; step+=1 print "======================================================================" +print +print "--- Check GEOM ..." comp = catalog.GetComponent("GEOM") -if comp is None: - raise RuntimeError,"Component GEOM not found in Module Catalog." +if not comp: + raise RuntimeError, "Component GEOM is not found in Module Catalog." +print "OK" -import geompy +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 " create AttributeReal " -print "=================================" -A = geompy.myBuilder.FindOrCreateAttribute(geompy.father, "AttributeReal") -if A == None : - raise RuntimeError, "Can't create AttributeReal attribute" -A = A._narrow(SALOMEDS.AttributeReal) -A.SetValue(0.0001) -if A.Value() != 0.0001: - raise RuntimeError, "Error : wrong value of AttributeReal" +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 " =========== Test Geometry ==========================" +print "--- Check VISU ..." +comp = catalog.GetComponent("VISU") +if not comp: + raise RuntimeError, "Component VISU is not found in Module Catalog." +print "OK" + print -print "===================================" -print " define a box" -print "===================================" +print "======================================================================" +print " %d. Check, that there is no data of MED component in the Study " % step; step+=1 +print "======================================================================" -box = geompy.MakeBox(0., 0., 0., 100., 200., 300.) -idbox = geompy.addToStudy(box,"box") +MedComp = salome.myStudy.FindComponent("MED") +if not comp: + print "" + print "This script cannot work properly, because there is" + print "some MED component data already existing in the study." + print "Execution aborted." + print "" + raise RuntimeError, "Please, run this script only in a new empty study." -print -print "============= Test SMESH =============================" print -import StdMeshers +print "======================================================================" +print " %d. Test Data Server " % step; step+=1 +print "======================================================================" -comp = catalog.GetComponent("SMESH") -if comp is None: - raise RuntimeError,"Component SMESH not found in Module Catalog." +print +print "--- Create new component ..." +comp = builder.NewComponent("TEST") +if not comp: + raise RuntimeError, "Can't create new component" +print "OK" -comp = catalog.GetComponent("MED") -if comp is None: - raise RuntimeError,"Component MED not found in Module Catalog." +print +print "--- Create AttributeName ..." +A = builder.FindOrCreateAttribute(comp, "AttributeName") +if not A: + raise RuntimeError, "Can't create AttributeName attribute" +A.SetValue("TEST") +if A.Value() != "TEST": + raise RuntimeError, "Error : wrong value of AttributeName" +print "OK" -import SMESH +print +print "--- Create AttributeReal ..." +A = builder.FindOrCreateAttribute(comp, "AttributeReal") +if not A: + raise RuntimeError, "Can't create AttributeReal attribute" +A.SetValue(0.0001) +if A.Value() != 0.0001: + raise RuntimeError, "Error : wrong value of AttributeReal" +print "OK" -geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM") -myBuilder = salome.myStudy.NewBuilder() +print -smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH") -smeshgui = salome.ImportComponentGUI("SMESH") -smeshgui.Init(salome.myStudyId); +print "======================================================================" +print " %d. Test Geometry " % step; step+=1 +print "======================================================================" + +import geompy ShapeTypeCompSolid = 1 ShapeTypeSolid = 2 @@ -118,435 +154,252 @@ ShapeTypeWire = 5 ShapeTypeEdge = 6 ShapeTypeVertex = 7 -# ---- define a box - +print +print "--- Create a box ..." box = geompy.MakeBox(0., 0., 0., 100., 200., 300.) -idbox = geompy.addToStudy(box,"box") +idbox = geompy.addToStudy(box, "box") +box_obj = salome.myStudy.FindObjectByPath("/Geometry/box") +if not box_obj: + raise RuntimeError, "Error : wrong value of AttributeReal" +print "OK" + +# ---- add shell from box in study +print +print "--- Extract shell ..." +subShellList = geompy.SubShapeAll(box, ShapeTypeShell) +shell = subShellList[0] +name = geompy.SubShapeName(shell, box) +idshell = geompy.addToStudyInFather(box, shell, name) +print name +print "OK" # ---- add first face of box in study - -subShapeList=geompy.SubShapeAll(box,ShapeTypeFace) -face=subShapeList[0] +print +print "--- Extract face ..." +subShapeList = geompy.SubShapeAll(box, ShapeTypeFace) +face = subShapeList[0] name = geompy.SubShapeName(face, box) +idface = geompy.addToStudyInFather(box, face, name) print name -idface=geompy.addToStudyInFather(box,face,name) - -# ---- add shell from box in study - -subShellList=geompy.SubShapeAll(box,ShapeTypeShell) -shell = subShellList[0] -name = geompy.SubShapeName(shell, box) -print name -idshell=geompy.addToStudyInFather(box,shell,name) +print "OK" # ---- add first edge of face in study - -edgeList = geompy.SubShapeAll(face,ShapeTypeEdge) -edge=edgeList[0]; +print +print "--- Extract edge ..." +edgeList = geompy.SubShapeAll(face, ShapeTypeEdge) +edge = edgeList[0]; name = geompy.SubShapeName(edge, face) +idedge = geompy.addToStudyInFather(face, edge, name) print name -idedge=geompy.addToStudyInFather(face,edge,name) +print "OK" +print -# ---- SMESH +print "======================================================================" +print " %d. Test Mesh " % step; step+=1 +print "======================================================================" -# ---- create Hypothesis +import StdMeshers +import SMESH + +smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH") +smeshgui = salome.ImportComponentGUI("SMESH") +smeshgui.Init(salome.myStudyId); + +# ---- create hypotheses if sys.platform == "win32": stdMeshersEngine = "StdMeshersEngine" else: stdMeshersEngine = "libStdMeshersEngine.so" -print "-------------------------- create Hypothesis" -print "-------------------------- LocalLength" +print +print "--- Create hypotheses ..." + +print +print "------ LocalLength ..." hypLen1 = smesh.CreateHypothesis( "LocalLength", stdMeshersEngine ) hypLen1.SetLength(100) print hypLen1.GetName() print hypLen1.GetId() print hypLen1.GetLength() - smeshgui.SetName(salome.ObjectToID(hypLen1), "Local_Length_100") +print "OK" -print "-------------------------- NumberOfSegments" +print +print "------ NumberOfSegments ..." hypNbSeg1= smesh.CreateHypothesis( "NumberOfSegments", stdMeshersEngine ) hypNbSeg1.SetNumberOfSegments(7) print hypNbSeg1.GetName() print hypNbSeg1.GetId() print hypNbSeg1.GetNumberOfSegments() - smeshgui.SetName(salome.ObjectToID(hypNbSeg1), "NumberOfSegments_7") +print "OK" -print "-------------------------- MaxElementArea" +print +print "------ MaxElementArea [1] ..." hypArea1 = smesh.CreateHypothesis( "MaxElementArea", stdMeshersEngine ) hypArea1.SetMaxElementArea(2500) print hypArea1.GetName() print hypArea1.GetId() print hypArea1.GetMaxElementArea() - smeshgui.SetName(salome.ObjectToID(hypArea1), "MaxElementArea_2500") +print "OK" -print "-------------------------- MaxElementArea" +print +print "------ MaxElementArea [2] ..." hypArea2 = smesh.CreateHypothesis( "MaxElementArea", stdMeshersEngine ) hypArea2.SetMaxElementArea(500) print hypArea2.GetName() print hypArea2.GetId() print hypArea2.GetMaxElementArea() - smeshgui.SetName(salome.ObjectToID(hypArea2), "MaxElementArea_500") +print "OK" -print "-------------------------- Regular_1D" +# ---- create algorithms + +print +print "--- Create algorithms ..." + +print +print "------ Regular_1D ..." algoReg = smesh.CreateHypothesis( "Regular_1D", stdMeshersEngine ) -listHyp=algoReg.GetCompatibleHypothesis() +listHyp = algoReg.GetCompatibleHypothesis() for hyp in listHyp: print hyp print algoReg.GetName() print algoReg.GetId() - smeshgui.SetName(salome.ObjectToID(algoReg), "Regular_1D" ) +print "OK" -print "-------------------------- MEFISTO_2D" +print +print "------ MEFISTO_2D ..." algoMef = smesh.CreateHypothesis( "MEFISTO_2D", stdMeshersEngine ) listHyp=algoMef.GetCompatibleHypothesis() for hyp in listHyp: print hyp print algoMef.GetName() print algoMef.GetId() - smeshgui.SetName(salome.ObjectToID(algoMef), "MEFISTO_2D" ) +print "OK" -# ---- add hypothesis to box +# ---- create mesh on the box, apply hypotheses / algorithms -print "-------------------------- add hypothesis to box" -box=salome.IDToObject(idbox) +print +print "--- Create mesh on the box ..." mesh = smesh.CreateMesh(box) - smeshgui.SetName( salome.ObjectToID(mesh), "MeshBox" ); +ret = mesh.AddHypothesis(box, algoReg) +ret = mesh.AddHypothesis(box, algoMef) +ret = mesh.AddHypothesis(box, hypNbSeg1) +ret = mesh.AddHypothesis(box, hypArea1) +print "OK" -ret=mesh.AddHypothesis(box,algoReg) -print ret -ret=mesh.AddHypothesis(box,algoMef) -print ret - - -ret=mesh.AddHypothesis(box,hypNbSeg1) -print ret -ret=mesh.AddHypothesis(box,hypArea1) -print ret - +# ---- create submesh on the edge, add hypothesis -# ---- add hypothesis to edge - -print "-------------------------- add hypothesis to edge" -edge=salome.IDToObject(idedge) -submesh=mesh.GetSubMesh(edge, "SubMeshEdge") - -ret=mesh.AddHypothesis(edge,algoReg) -print ret -ret=mesh.AddHypothesis(edge,hypLen1) -print ret +print +print "--- Add 1D sub-mesh on the edge ..." +submesh = mesh.GetSubMesh(edge, "SubMeshEdge") +ret = mesh.AddHypothesis(edge, algoReg) +ret = mesh.AddHypothesis(edge, hypLen1) +print "OK" -print "-------------------------- add hypothesis to face" -face=salome.IDToObject(idface) -submesh = mesh.GetSubMesh(face, "SubMeshFace") +# ---- create submesh on the edge, add hypothesis -ret=mesh.AddHypothesis(face,hypArea2) -print ret +print +print "--- Add 2D sub-mesh on the face ..." +submesh = mesh.GetSubMesh(face, "SubMeshFace") +ret = mesh.AddHypothesis(face, hypArea2) +print "OK" +# ---- compute mesh +print +print "--- Compute mesh ..." smesh.Compute(mesh, box) -sg.updateObjBrowser(1); - -##################################################################### -# SUPERVISOR module is not available since SALOME 5.0 version -##################################################################### -print -print "============= Test Supervisor =============================" -print -import salome_version -version = salome_version.getVersions("GUI")[0] -if not version: version = salome_version.getVersions("KERNEL")[0] -if version < 5: - # SUPERV module is avaiable - comp = catalog.GetComponent("SUPERV") - if comp is None: - raise RuntimeError,"Component SUPERV not found in Module Catalog." - - from SuperV import * - import SALOMEDS - myStudy = salome.myStudy - myBuilder = myStudy.NewBuilder() - - SuperVision = lcc.FindOrLoadComponent("SuperVisionContainer","SUPERV") - father = myStudy.FindComponent("SUPERV") - if father is None: - father = myBuilder.NewComponent("SUPERV") - A1 = myBuilder.FindOrCreateAttribute(father, "AttributeName"); - FName = A1._narrow(SALOMEDS.AttributeName) - FName.SetValue( salome.sg.getComponentUserName("SUPERV") ) - A2 = myBuilder.FindOrCreateAttribute(father, "AttributePixMap"); - aPixmap = A2._narrow(SALOMEDS.AttributePixMap); - aPixmap.SetPixMap( "ICON_OBJBROWSER_Supervision" ); - myBuilder.DefineComponentInstance(father,SuperVision) - - def addStudy(ior): - dataflow = SuperVision.getStreamGraph(ior) - name=dataflow.Name() - itr = myStudy.NewChildIterator(father) - while itr.More(): - item=itr.Value() - res,A=item.FindAttribute("AttributeName") - if res: - aName = A._narrow(SALOMEDS.AttributeName) - if aName.Value() == name : - print myBuilder.FindOrCreateAttribute(item, "AttributeIOR") - A = myBuilder.FindOrCreateAttribute(item, "AttributeIOR") - print "A = ", A - if A is not None : - #res,A = myBuilder.FindOrCreateAttribute(item, "AttributeIOR") - anIOR = A._narrow(SALOMEDS.AttributeIOR); - print "anIOR.SetValue(dataflow.getIOR())" - anIOR.SetValue(dataflow.getIOR()) - return - itr.Next() - obj = myBuilder.NewObject(father) - A=myBuilder.FindOrCreateAttribute(obj, "AttributeName") - aName=A._narrow(SALOMEDS.AttributeName) - aName.SetValue(name) - A=myBuilder.FindOrCreateAttribute(obj, "AttributeIOR") - anIOR = A._narrow(SALOMEDS.AttributeIOR) - anIOR.SetValue(dataflow.getIOR()) - - import os - dir= os.getenv("DATA_DIR") - if dir == None: - raise RuntimeError, "DATA_DIR is not defined" - xmlfile = dir + "/Superv/Graphs/GraphGeomEssaiGates.xml" - print "Load dataflow from the file : " - print xmlfile - print - - myGraph = StreamGraph ( xmlfile ) - - # This DataFlow is "valid" : no loop, correct links between Nodes etc... - print "myGraph.IsValid() = ", myGraph.IsValid() - - # Get Nodes - myGraph.PrintNodes() - - # This DataFlow is "executable" : all pending Ports are defined with Datas - print myGraph.IsExecutable() - - # Starts only execution of that DataFlow and gets control immediatly - print myGraph.Run() - - # That DataFlow is running ==> 0 (false) - print myGraph.IsDone() - - # Events of execution : - aStatus,aNode,anEvent,aState = myGraph.Event() - while aStatus : - print aNode.Thread(),aNode.SubGraph(),aNode.Name(),anEvent,aState - aStatus,aNode,anEvent,aState = myGraph.Event() - print "myGraph.IsDone() = ",myGraph.IsDone() - - # Wait for Completion (but it is already done after event loop ...) - print "Done : ",myGraph.DoneW() - - print " " - #print "Type : print myGraph.IsDone()" - #print " If execution is finished ==> 1 (true)" - res=myGraph.IsDone() - if res != 1: - raise RuntimeError, "myGraph.Run() is not done" - - print " " - print "Type : myGraph.PrintPorts()" - print " to see input and output values of the graph" - myGraph.PrintPorts() - - # Export will create newsupervisionexample.xml and the corresponding .py file - tmpdir=os.getenv("TmpDir") - if tmpdir is None: - tmpdir="/tmp" - file = tmpdir + "/newsupervisionexample" - print "--------------\n"+file+"\n--------------\n" - myGraph.Export(file) - - ior = salome.orb.object_to_string(myGraph.G) - addStudy(ior) - - GraphName = myGraph.Name() - print "Befor save ", - #nodes = myGraph.Nodes() - nodes = myGraph.G.Nodes().FNodes - length_bs = len(nodes) - print "ListOfNodes length = ", length_bs - names=[] - for node in nodes: - names.append(node.Name()) - print names - - # Graph creation - GraphInLines = StreamGraph( 'GraphInLines' ) - GraphInLines.SetName( 'GraphInLines' ) - GraphInLines.SetAuthor( '' ) - GraphInLines.SetComment( '' ) - GraphInLines.Coords( 0 , 0 ) - - # Creation of InLine Nodes - PyAdd = [] - PyAdd.append( 'def Add(a,b) : ' ) - PyAdd.append( ' return a+b ' ) - PyAdd.append( '' ) - Add = GraphInLines.INode( 'Add' , PyAdd ) - Add.InPort( 'a' , 'long' ) - Add.InPort( 'b' , 'long' ) - Add.OutPort( 'f' , 'long' ) - Add.SetName( 'Add' ) - Add.SetAuthor( '' ) - Add.SetComment( 'Python function' ) - Add.Coords( 351 , 77 ) - PySub = [] - PySub.append( 'def Sub(a,b) : ' ) - PySub.append( ' return a-b ' ) - PySub.append( '' ) - Sub = GraphInLines.INode( 'Sub' , PySub ) - Sub.InPort( 'a' , 'long' ) - Sub.InPort( 'b' , 'long' ) - Sub.OutPort( 'f' , 'long' ) - Sub.SetName( 'Sub' ) - Sub.SetAuthor( '' ) - Sub.SetComment( 'Python function' ) - Sub.Coords( 86 , 333 ) - PyMul = [] - PyMul.append( 'def Mul(a,b) : ' ) - PyMul.append( ' return a*b ' ) - Mul = GraphInLines.INode( 'Mul' , PyMul ) - Mul.InPort( 'a' , 'long' ) - Mul.InPort( 'b' , 'long' ) - Mul.OutPort( 'Result' , 'long' ) - Mul.SetName( 'Mul' ) - Mul.SetAuthor( '' ) - Mul.SetComment( 'Python function' ) - Mul.Coords( 616 , 247 ) - - # Creation of intermediate Output variables and of Control Links - Addf = Add.Port( 'f' ) - Mula = GraphInLines.Link( Addf , Mul.Port( 'a' ) ) - Mula.AddCoord( 1 , 570 , 356 ) - Mula.AddCoord( 2 , 570 , 186 ) - Subf = Sub.Port( 'f' ) - Mulb = GraphInLines.Link( Subf , Mul.Port( 'b' ) ) - Mulb.AddCoord( 1 , 282 , 376 ) - Mulb.AddCoord( 2 , 282 , 442 ) - Addb = GraphInLines.Link( Subf , Add.Port( 'b' ) ) - Addb.AddCoord( 1 , 283 , 209 ) - Addb.AddCoord( 2 , 283 , 374 ) - Addb.AddCoord( 3 , 283 , 442 ) - - # Creation of Input datas - Adda = Add.Input( 'a' , 1) - Suba = Sub.Input( 'a' , 3) - Subb = Sub.Input( 'b' , 4) - - # Creation of Output variables - MulResult = Mul.Port( 'Result' ) - - GraphInLines.Run() - - GraphInLines.DoneW() - - GraphInLines.PrintPorts() - - sg.updateObjBrowser(1); - - pass -else: - # SUPERV module is NOT avaiable - print "WARNING! Supervisor is not avaiable in this version of SALOME!" - pass +salome.sg.updateObjBrowser(1); +print "OK" print -print "============= Test VISU and MED =============================" -print -comp = catalog.GetComponent("VISU") -if comp is None: - raise RuntimeError,"Component VISU not found in Module Catalog." +print "======================================================================" +print " %d. Test Post-Pro and Med " % step; step+=1 +print "======================================================================" import sys import SALOMEDS import SALOME import SALOME_MED import VISU - import visu_gui +med = salome.lcc.FindOrLoadComponent("FactoryServer", "MED") +visu = salome.lcc.FindOrLoadComponent("FactoryServer", "VISU") + medFileName = "pointe.med" -if sys.platform != "win32": - medFile = os.getenv('DATA_DIR') + '/MedFiles/' + medFileName -else: - medFile = os.getenv('DATA_DIR') + '\\MedFiles\\' + medFileName - pass -print "Load ", medFile - -studyCurrent = salome.myStudyName - -med_comp = salome.lcc.FindOrLoadComponent("FactoryServer", "MED") -myVisu = salome.lcc.FindOrLoadComponent("FactoryServer", "VISU") - -try: - if os.access(medFile, os.R_OK) : - if not os.access(medFile, os.W_OK) : - import random - if sys.platform != "win32": - tmpDir = "/tmp/" - else: - tmpDir = os.getenv('TEMP') + '\\' - medFileNew = tmpDir + str(random.randint(0,1000000)) + "_" + medFileName - print " -- Copy " + medFile + " to " + medFileNew - - if sys.platform != "win32": - copyCommand = "cp" - else: - copyCommand = "copy /Y" - os.system(copyCommand + " " + medFile + " " + medFileNew) - - medFile = medFileNew - if sys.platform != "win32": - os.system("chmod 755 " + medFile) - pass - - if os.access(medFile, os.W_OK) : - med_comp.readStructFileWithFieldType(medFile,studyCurrent) - med_obj = visu_gui.visu.getMedObjectFromStudy() - print "med_obj - ", med_obj - - myField1 = visu_gui.visu.getFieldObjectFromStudy(3,1) - aMeshName = "maa1" - anEntity = VISU.NODE - aTimeStampId = -1 - - myResult1 = myVisu.ImportMedField(myField1) - aMesh1 = myVisu.MeshOnEntity(myResult1, aMeshName, anEntity); +medFile = os.path.join(os.getenv('DATA_DIR'), 'MedFiles', medFileName) + +print +print "--- Read med file structure from %s ..." % medFile +med.readStructFileWithFieldType(medFile, salome.myStudyName) +print "OK" + +print +print "--- Get med object from study ..." +med_obj = visu_gui.visu.getMedObjectFromStudy() +if not med_obj: + raise RuntimeError, "Med object is not found in the study" +print "OK" + +print +print "--- Get field from study ..." +field = visu_gui.visu.getFieldObjectFromStudy(3,1) +if not field: + raise RuntimeError, "Field object is not found in the study" +print "OK" + +print +print "--- Import field to the VISU ..." +aMeshName = "maa1" +anEntity = VISU.NODE +aTimeStampId = -1 +result1 = visu.ImportMedField(field) +if not result1: + raise RuntimeError, "Can't import field" +print "OK" + +print +print "--- Create mesh presentation [1] ..." +mesh1 = visu.MeshOnEntity(result1, aMeshName, anEntity); +if not mesh1: + raise RuntimeError, "Can't create mesh presentation" +print "OK" - aScalarMap1= myVisu.ScalarMapOnField(myResult1, aMeshName, anEntity, myField1.getName(), aTimeStampId) +print +print "--- Create scalar map [1] ..." +scalarMap1 = visu.ScalarMapOnField(result1, aMeshName, anEntity, field.getName(), aTimeStampId) +if not scalarMap1: + raise RuntimeError, "Can't create scalar map" +print "OK" - myResult2 = myVisu.ImportFile(medFile); - aMesh2 = myVisu.MeshOnEntity(myResult2, aMeshName, anEntity); +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 [2] ..." +mesh2 = visu.MeshOnEntity(result2, aMeshName, anEntity); +if not mesh2: + raise RuntimeError, "Can't create mesh presentation" +print "OK" - aTimeStampId = 3 - aScalarMap2= myVisu.ScalarMapOnField(myResult2, aMeshName, anEntity, myField1.getName(), aTimeStampId) - - sg.updateObjBrowser(0) - else : print "We have no permission to rewrite medFile, so readStructFileWithFieldType can't open this file"; - else : print "We have no permission to read medFile, it will not be opened"; - -except: - if sys.exc_type == SALOME.SALOME_Exception : - print "There is no permission to read " + medFile - else : - print sys.exc_type - print sys.exc_value - print sys.exc_traceback - -sg.updateObjBrowser(1); +print +print "--- Create scalar map [2] ..." +scalarMap2 = visu.ScalarMapOnField(result2, aMeshName, anEntity, field.getName(), 3) +if not scalarMap2: + raise RuntimeError, "Can't create scalar map" +print "OK" + +salome.sg.updateObjBrowser(0) -- 2.39.2