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

Source Code for Package PyFoam.Paraview

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