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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 943 - (show annotations)
Mon Jan 29 07:22:43 2007 UTC (14 years, 2 months ago) by jongui
File MIME type: text/x-python
File size: 1701 byte(s)
new pyvisi files
1 """
2 @author: John NGUI
3 """
4
5 import vtk
6
7 class Clipper:
8 """
9 Class that defines a clipper.
10 """
11
12 # plane by default is assigned to None because a plane is not required
13 # when a scalar value is used to perform the clipping.
14 def __init__(self, object, plane = None):
15 """
16 Initialise the clipper.
17
18 @type object: vtkUnstructuredGrid, etc
19 @param object: Input for the clipper
20 @type plane: vtkPlane
21 @param plane: Plane to clip the object
22 """
23
24 self.__object = object
25 if(plane != None): # True only if a plane is used to perform clipping.
26 self.__plane = plane
27
28 self.__vtk_clipper = vtk.vtkClipDataSet()
29
30 self.__setInput()
31 #self.__setClipFunction()
32 # Generates the clipped away section. At this stage, the clipped
33 # away section is not used.
34 #self.__vtk_clipper.GenerateClippedOutputOn()
35 self.setInsideOutOn()
36 self.__vtk_clipper.Update()
37
38 def __setInput(self):
39 """
40 Set the input for the clipper.
41 """
42
43 self.__vtk_clipper.SetInput(self.__object)
44
45 def _setClipFunction(self):
46 """
47 Set the clip function.
48 """
49
50 self.__vtk_clipper.SetClipFunction(self.__plane)
51
52 def setInsideOutOn(self):
53 """
54 Clips the one side of the rendered object.
55 """
56
57 self.__vtk_clipper.InsideOutOn()
58
59 def setInsideOutOff(self):
60 """
61 Clips the other side of the rendered object.
62 """
63
64 self.__vtk_clipper.InsideOutOff()
65
66 def setClipValue(self, value):
67 """
68 Set the scalar clip value.
69
70 @type value: Number
71 @param value: Scalar clip value
72 """
73
74 self.__vtk_clipper.SetValue(value)
75
76 def _getOutput(self):
77 """
78 Return the output of the clipper.
79
80 @rtype: vtkUnstructuredGrid
81 @return: Unstructured grid
82 """
83
84 return self.__vtk_clipper.GetOutput()
85

  ViewVC Help
Powered by ViewVC 1.1.26