/[escript]/trunk/pyvisi/py_src/contour.py
ViewVC logotype

Contents of /trunk/pyvisi/py_src/contour.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 849 - (show annotations)
Fri Sep 15 07:11:55 2006 UTC (14 years ago) by jongui
File MIME type: text/x-python
File size: 2274 byte(s)
Optimized codes and modularized functions to make it more scalable. Partially 
integrated carpet into the existing modules.  

1 """
2 @author: John Ngui
3 @author: Lutz Gross
4 """
5
6 import vtk
7 from common import *
8
9 class Contour(Common):
10 """
11 Class that shows a scalar field by contour surfaces.
12 """
13
14 def __init__(self, scene, data_collector, lut = None):
15 """
16 @type scene: L{Scene <scene.Scene>} object
17 @param scene: Scene in which components are to be added to
18 @type data_collector: L{DataCollector <datacollector.DataCollector>}
19 object
20 @param data_collector: Source of data for visualization
21 """
22
23 Common.__init__(self, scene, data_collector)
24 self.vtk_contour = vtk.vtkContourFilter()
25 self.setContour()
26
27 Common.setMapperInput(self, self.vtk_contour.GetOutput(), lut)
28 Common.setActorInput(self)
29 Common.addActor(self)
30
31 def setContour(self):
32 """
33 Set up the contour and its input.
34 """
35
36 self.vtk_contour.SetInput(self.data_collector.getReader().GetOutput())
37
38 def setValue(self, contour_number, value):
39 """
40 Set the contour number and its value.
41
42 @type contour_number: Number
43 @param contour_number: Contour number
44 @type value: Number
45 @param value: Contour value
46 """
47
48 self.vtk_contour.SetValue(contour_number, value)
49
50 def generateValues(self, number_contours, min_range, max_range):
51 """
52 Generate the specified number of contours within the specified range.
53
54 @type number_contours: Number
55 @param number_contours: Number of contours to generate
56 @type min_range: Number
57 @param min_range: Minimum contour value
58 @type max_range: Number
59 @param max_range: Maximum contour value
60 """
61
62 self.vtk_contour.GenerateValues(number_contours, min_range, max_range)
63
64 from contour import Contour
65 from plane import Plane
66
67 class ContourOnPlane(Contour, Plane):
68 """
69 Class that shows a scalar field by contour surfaces on a given plane.
70 """
71
72 def __init__(self, scene, data_collector, lut = None):
73 """
74 @type scene: L{Scene <scene.Scene>} object
75 @param scene: Scene in which components rae to be added to
76 @type data_collector: L{DataCollector <datacollector.DataCollector>}
77 object
78 @param data_collector: Source of data for visualization
79 """
80
81 self.data_collector = data_collector
82 self.vtk_contour = vtk.vtkContourFilter()
83 Contour.setContour(self)
84
85 Plane.__init__(self, scene, data_collector,
86 self.vtk_contour.GetOutput(), lut)

  ViewVC Help
Powered by ViewVC 1.1.26