From 9cba62d880d3a6096a4aa1554ec5ac1a42f2777b Mon Sep 17 00:00:00 2001 From: apo Date: Tue, 31 Oct 2006 05:59:02 +0000 Subject: [PATCH] To introduce generic testing over all types of VISU presentations --- src/VISU_SWIG/visu_change_input.py | 121 ++++++++++++++++++++++------- 1 file changed, 91 insertions(+), 30 deletions(-) diff --git a/src/VISU_SWIG/visu_change_input.py b/src/VISU_SWIG/visu_change_input.py index 3cda8dde..44c42850 100644 --- a/src/VISU_SWIG/visu_change_input.py +++ b/src/VISU_SWIG/visu_change_input.py @@ -4,38 +4,99 @@ import VISU import SALOMEDS from batchmode_visu import * -myViewManager = myVisu.GetViewManager(); +#--------------------------------------------------------------- +def GetPrsType2OldFactoryMethod(theVISUType): + if theVISUType == VISU.TGAUSSPOINTS: + return myVisu.GaussPointsOnField + if theVISUType == VISU.TSCALARMAP: + return myVisu.ScalarMapOnField + if theVISUType == VISU.TISOSURFACE: + return myVisu.IsoSurfacesOnField + if theVISUType == VISU.TCUTPLANES: + return myVisu.CutPlanesOnField + if theVISUType == VISU.TCUTLINES: + return myVisu.CutLinesOnField + if theVISUType == VISU.TPLOT3D: + return myVisu.Plot3DOnField + if theVISUType == VISU.TDEFORMEDSHAPE: + return myVisu.DeformedShapeOnField + if theVISUType == VISU.TVECTORS: + return myVisu.VectorsOnField + if theVISUType == VISU.TSTREAMLINES: + return myVisu.StreamLinesOnField + if theVISUType == VISU.TSCALARMAPONDEFORMEDSHAPE: + return myVisu.ScalarMapOnDeformedShapeOnField + return None -myView = myViewManager.Create3DView(); -myView.SetTitle("The window will be soon destroyed!") -medFile = "TimeStamps.med" -myFieldName = "vitesse"; +#--------------------------------------------------------------- +def WalkTroughTimeStamps(theVISUType, + theResult, theMeshName,theEntity, theFieldName, theTimeStampNumber, + theViewManager): + anOldFactoryMethod = GetPrsType2OldFactoryMethod(theVISUType) + + aPrs3d = anOldFactoryMethod(theResult, theMeshName, theEntity, theFieldName, theTimeStampNumber) + aPrs3d = myVisu.CreatePrs3d(theVISUType, myVisu.GetCurrentStudy()) + aPrs3d.SetResultObject(theResult) + aPrs3d.SetMeshName(theMeshName) + aPrs3d.SetEntity(theEntity) + aPrs3d.SetFieldName(theFieldName) + aPrs3d.SetTimeStampNumber(theTimeStampNumber) + if not aPrs3d.Apply(): + print "It is impossible to create such kind of presentation (%s) with the given parameters" % theVISUType + print "\ttheMeshName = '%s'" % theMeshName + print "\ttheEntity = %s" % theEntity + print "\ttheFieldName = '%s'" % theFieldName + print "\ttheTimeStampNumber = %s" % theTimeStampNumber + return + + aView = theViewManager.Create3DView(); + aView.SetTitle("To test presentation of %s type" % theVISUType) + aView.Display(aPrs3d); + aView.FitAll() + + aDelay = 0.0 + for aTimeStampNumber in xrange(1,3): + aPrs3d.SetTimeStampNumber(aTimeStampNumber) + aPrs3d.Apply() + aView.Update(); + time.sleep(aDelay) + pass + pass + + +#--------------------------------------------------------------- +PRS3D_TYPE_LIST = [] +PRS3D_TYPE_LIST.append(VISU.TGAUSSPOINTS) +PRS3D_TYPE_LIST.append(VISU.TSCALARMAP) +PRS3D_TYPE_LIST.append(VISU.TISOSURFACE) +PRS3D_TYPE_LIST.append(VISU.TCUTPLANES) +PRS3D_TYPE_LIST.append(VISU.TCUTLINES) +PRS3D_TYPE_LIST.append(VISU.TPLOT3D) +PRS3D_TYPE_LIST.append(VISU.TDEFORMEDSHAPE) +PRS3D_TYPE_LIST.append(VISU.TVECTORS) +PRS3D_TYPE_LIST.append(VISU.TSTREAMLINES) +PRS3D_TYPE_LIST.append(VISU.TSCALARMAPONDEFORMEDSHAPE) + + +#--------------------------------------------------------------- +aMedFile = "TimeStamps.med" +aMedFile = "ResOK_0000.med" +aMedFile = os.getenv('DATA_DIR') + '/MedFiles/' + aMedFile +aResult = myVisu.ImportFile(aMedFile) aMeshName ="dom" anEntity = VISU.NODE -aTimeStampId = 1 - -medFile = os.getenv('DATA_DIR') + '/MedFiles/' + medFile -myResult = myVisu.ImportFile(medFile) - -aPrs3d = myVisu.IsoSurfacesOnField(myResult,aMeshName,anEntity,myFieldName,aTimeStampId) - -aPrs3d = myVisu.CreatePrs3d(VISU.TISOSURFACE,myVisu.GetCurrentStudy()) -aPrs3d.SetResultObject(myResult) -aPrs3d.SetMeshName(aMeshName) -aPrs3d.SetEntity(anEntity) -aPrs3d.SetFieldName(myFieldName) -aPrs3d.SetTimeStampNumber(aTimeStampId) -print aPrs3d.Apply() - -myView.Display(aPrs3d); -print "myView.Display(aPrs3d)" -myView.FitAll() - -aDelay = 0.0 -for aTimeStampId in xrange(1,100): - aPrs3d.SetTimeStampNumber(aTimeStampId) - print aPrs3d.Apply() - myView.Update(); - time.sleep(aDelay) +aFieldName = "vitesse"; +aTimeStampNumber = 1 + +aViewManager = myVisu.GetViewManager(); + +for aVISUType in PRS3D_TYPE_LIST: + WalkTroughTimeStamps(aVISUType, aResult, aMeshName, anEntity, aFieldName, aTimeStampNumber, aViewManager) + pass + +anEntity = VISU.CELL +aFieldName = "pression"; + +WalkTroughTimeStamps(VISU.TGAUSSPOINTS, aResult, aMeshName, anEntity, aFieldName, aTimeStampNumber, aViewManager) -- 2.39.2