1 |
gross |
792 |
""" |
2 |
jongui |
835 |
Class that deals with data for the visualization. |
3 |
gross |
792 |
""" |
4 |
|
|
|
5 |
jongui |
822 |
import vtk |
6 |
jongui |
828 |
from common import * |
7 |
gross |
792 |
|
8 |
jongui |
828 |
class DataCollector(Common): |
9 |
jongui |
835 |
""" |
10 |
|
|
@author: John Ngui |
11 |
|
|
@author: Lutz Gross |
12 |
|
|
""" |
13 |
gross |
792 |
|
14 |
jongui |
827 |
def __init__(self, open_scene, outline = True): |
15 |
jongui |
835 |
""" |
16 |
|
|
Initialize all the instance variables. |
17 |
|
|
|
18 |
|
|
@type open_scene: L{OpenScene <openscene.OpenScene>} object |
19 |
|
|
@param open_scene: Scene in which components are to be added to |
20 |
|
|
@type outline: Boolean (I{True or False}) |
21 |
|
|
@param outline: Determines the outline for the rendered object |
22 |
|
|
""" |
23 |
|
|
|
24 |
jongui |
827 |
self.open_scene = open_scene |
25 |
jongui |
822 |
self.outline = True |
26 |
|
|
self.file_name = None |
27 |
jongui |
828 |
self.vtk_outline = None |
28 |
jongui |
827 |
self.vtk_xml_reader = None |
29 |
|
|
self.vtk_xml_reader_output = None |
30 |
jongui |
822 |
|
31 |
|
|
def setSource(self, file_name): |
32 |
jongui |
835 |
""" |
33 |
|
|
Set up the file reader and set the file name. |
34 |
|
|
|
35 |
|
|
@type file_name: String |
36 |
|
|
@param file_name: Name of the file to be read. |
37 |
|
|
""" |
38 |
|
|
|
39 |
jongui |
822 |
self.file_name = file_name |
40 |
|
|
self.vtk_xml_reader = vtk.vtkXMLUnstructuredGridReader() |
41 |
|
|
self.vtk_xml_reader.SetFileName(self.file_name) |
42 |
|
|
|
43 |
jongui |
827 |
if(self.outline == True): |
44 |
jongui |
828 |
self.setOutline() |
45 |
|
|
Common.setMapper(self, "self.vtk_outline.GetOutput()") |
46 |
|
|
Common.setActor(self) |
47 |
|
|
Common.addActor(self) |
48 |
jongui |
835 |
Common.setColor(self, 0, 0, 0) # Default outline is black |
49 |
jongui |
827 |
|
50 |
jongui |
822 |
def getReader(self): |
51 |
jongui |
835 |
""" |
52 |
|
|
Return the file reader. |
53 |
|
|
|
54 |
|
|
@rtype: vtkXMLUnstructuredGridReader |
55 |
|
|
@return: VTK XML unstructured grid reader |
56 |
|
|
""" |
57 |
|
|
|
58 |
jongui |
822 |
return self.vtk_xml_reader |
59 |
|
|
|
60 |
jongui |
828 |
def setOutline(self): |
61 |
jongui |
835 |
""" |
62 |
|
|
Set the outline for the rendered object. |
63 |
|
|
""" |
64 |
|
|
|
65 |
jongui |
828 |
self.vtk_outline = vtk.vtkOutlineFilter() |
66 |
|
|
self.vtk_outline.SetInput(self.vtk_xml_reader.GetOutput()) |
67 |
jongui |
822 |
|
68 |
jongui |
827 |
|