Package PyFoam :: Package Paraview
[hide private]
[frames] | no frames]

Source Code for Package PyFoam.Paraview

  1  #  ICE Revision: $Id: /local/openfoam/Python/PyFoam/PyFoam/Paraview/__init__.py 5484 2009-08-31T21:05:57.083485Z bgschaid  $  
  2  """ Paraview interaction 
  3   
  4  Classes that help to interact with a Python-enabled paraFoam/paraview 
  5  """ 
  6   
  7  hasSimpleModule=True 
  8  try: 
  9      from paraview import simple 
 10  except ImportError: 
 11      hasSimpleModule=False 
 12       
 13  # this import prevents python-source-tools that ude introspection from working 
 14  # because it prevents import into a normal python 
 15  from paraview import servermanager 
 16       
 17  from PyFoam.Error import warning 
 18  from PyFoam.RunDictionary.SolutionDirectory import SolutionDirectory 
 19   
 20  from math import sqrt 
 21  from os import path 
 22   
 23  from SourceBase import SourceBase 
 24   
 25  proxyManager=servermanager.ProxyManager() 
 26   
27 -def version():
28 """Tries to determine the paraview-version""" 29 return (proxyManager.GetVersionMajor(), 30 proxyManager.GetVersionMinor(), 31 proxyManager.GetVersionPatch())
32
33 -def paraFoamReader():
34 """ Get the paraFoam reader. 35 Currently only works if there is only one reader""" 36 37 result=None 38 39 src=proxyManager.GetProxiesInGroup("sources") 40 41 for s in src: 42 if type(src[s])==servermanager.sources.PV3FoamReader: 43 if result==None: 44 result=src[s] 45 else: 46 warning("Found a second paraFoam-reader:",s) 47 48 if result==None: 49 warning("No paraFoam-reader found") 50 51 return result
52
53 -def readerObject():
54 """Gets the only reader wrapped as a SourceBase-object""" 55 return SourceBase(paraFoamReader())
56
57 -def renderView():
58 """ Get the render view. 59 Currently just takes the first view""" 60 61 result=None 62 63 src=proxyManager.GetProxiesInGroup("views") 64 65 for s in src: 66 if result==None: 67 result=src[s] 68 else: 69 warning("Found a second render view:",s) 70 71 if result==None: 72 warning("No render view found") 73 74 return result
75
76 -def getBounds():
77 """Return the size of the object covered by the paraFoam-Reader""" 78 return readerObject().getBounds()
79
80 -def getCenter():
81 """Return the center of the object covered by the paraFoam-Reader""" 82 return readerObject().getCenter()
83
84 -def characteristicLength():
85 """The characteristic length of the geometry""" 86 return readerObject().characteristicLength()
87
88 -def viewTime():
89 """Time that is currently displayed""" 90 return renderView().ViewTime.GetData()
91
92 -def caseDirectory():
93 """The directory in which the case is stored""" 94 return SolutionDirectory( 95 path.dirname(paraFoamReader().FileName.GetData()), 96 archive=None, 97 paraviewLink=False)
98
99 -def timeDirectory():
100 return caseDirectory()[viewTime()]
101
102 -def transformsModule():
103 """Workaround to get to the transformations in Paraview 3.4""" 104 return servermanager.createModule("transforms")
105