1
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
14
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
32
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
56
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
77 """Return the size of the object covered by the paraFoam-Reader"""
78 return readerObject().getBounds()
79
81 """Return the center of the object covered by the paraFoam-Reader"""
82 return readerObject().getCenter()
83
87
89 """Time that is currently displayed"""
90 return renderView().ViewTime.GetData()
91
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
101
105