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

Source Code for Module PyFoam.Paraview.SourceBase

 1  #  ICE Revision: $Id: /local/openfoam/Python/PyFoam/PyFoam/Paraview/SourceBase.py 4714 2009-03-11T22:10:59.062514Z bgschaid  $  
 2  """ Base class for the wrapping of graphical objects 
 3   
 4  The actual object is accessed via the member variable src. 
 5  Just adds some simple things like bounding boxes etc""" 
 6   
 7  from math import sqrt 
 8   
 9  from PyFoam.Basics.DataStructures import Vector 
10   
11 -class SourceBase(object):
12 """Base class for the sources 13 14 The member src is the actual source object""" 15
16 - def __init__(self,src):
17 """@param src: the actual source proxy""" 18 self.src = src
19
20 - def getBounds(self):
21 """Get the bounding box of the object""" 22 bnds=self.src.GetDataInformation().GetBounds() 23 24 return (bnds[0:2],bnds[2:4],bnds[4:6])
25
26 - def getMin(self):
27 """Get the minimum-vector of the bounds""" 28 bnd=self.getBounds() 29 return Vector(bnd[0][0],bnd[1][0],bnd[2][0])
30
31 - def getMax(self):
32 """Get the minimum-vector of the bounds""" 33 bnd=self.getBounds() 34 return Vector(bnd[0][1],bnd[1][1],bnd[2][1])
35
36 - def getCenter(self):
37 """Return the center of the object""" 38 return 0.5*(self.getMax()+self.getMin())
39
40 - def getExtent(self):
41 """Return the center of the object""" 42 return self.getMax()-self.getMin()
43
44 - def characteristicLength(self):
45 """The characteristic length of the object""" 46 47 return abs(self.getExtent())
48
49 - def makeVector(self,orig):
50 """Convert a list or a tuple of length 3 to a vector for easier calculations""" 51 52 return Vector(orig[0],orig[1],orig[2])
53