/[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 852 - (show annotations)
Wed Sep 20 03:23:16 2006 UTC (16 years, 6 months ago) by jongui
File MIME type: text/x-python
File size: 2667 byte(s)
added carpet and isosurface


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
39 def generateValues(self, number_contours, min_range, max_range):
40 """
41 Generate the specified number of contours within the specified range.
42
43 @type number_contours: Number
44 @param number_contours: Number of contours to generate
45 @type min_range: Number
46 @param min_range: Minimum contour value
47 @type max_range: Number
48 @param max_range: Maximum contour value
49 """
50
51 self.vtk_contour.GenerateValues(number_contours, min_range, max_range)
52
53
54 from contour import Contour
55 from plane import Plane
56
57 class ContourOnPlane(Contour, Plane):
58 """
59 Class that shows a scalar field by contour surfaces on a given plane.
60 """
61
62 def __init__(self, scene, data_collector, lut = None):
63 """
64 @type scene: L{Scene <scene.Scene>} object
65 @param scene: Scene in which components rae to be added to
66 @type data_collector: L{DataCollector <datacollector.DataCollector>}
67 object
68 @param data_collector: Source of data for visualization
69 """
70
71 self.data_collector = data_collector
72 self.vtk_contour = vtk.vtkContourFilter()
73 Contour.setContour(self)
74
75 Plane.__init__(self, scene, data_collector,
76 self.vtk_contour.GetOutput(), lut)
77
78
79 from contour import Contour
80
81 class IsoSurface(Contour):
82
83 def __init__(self, scene, data_collector, lut = None):
84 Contour.__init__(self, scene, data_collector, lut)
85
86 def setValue(self, contour_number, value):
87 """
88 Set the contour number and its value.
89
90 @type contour_number: Number
91 @param contour_number: Contour number
92 @type value: Number
93 @param value: Contour value
94 """
95
96 self.vtk_contour.SetValue(contour_number, value)
97
98 from contour import IsoSurface, ContourOnPlane
99
100 class IsoSurfaceOnPlane(IsoSurface, ContourOnPlane):
101
102 def __init__(self, scene, data_collector, lut = None):
103 ContourOnPlane.__init__(self, scene, data_collector, lut)
104

  ViewVC Help
Powered by ViewVC 1.1.26