1
2 """ Paraview interaction
3
4 Classes that help to interact with a Python-enabled paraFoam/paraview
5 """
6
7
8
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
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
44
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
65 """Return the size of the object covered by the paraFoam-Reader"""
66 return readerObject().getBounds()
67
69 """Return the center of the object covered by the paraFoam-Reader"""
70 return readerObject().getCenter()
71
75
77 """Time that is currently displayed"""
78 return renderView().ViewTime.GetData()
79
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
89
93