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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1147 - (hide annotations)
Wed May 16 06:39:11 2007 UTC (13 years, 11 months ago) by ksteube
File MIME type: text/x-python
File size: 1582 byte(s)
Added back in some files that were accidentally deleted.

1 ksteube 1147 """
2     @author: John NGUI
3     """
4    
5     import vtk
6    
7     class Clipper:
8     """
9     Class that defines a clipper.
10     """
11    
12     def __init__(self, object, plane):
13     """
14     Initialise the clipper.
15    
16     @type object: vtkUnstructuredGrid, etc
17     @param object: Input for the clipper
18     @type plane: vtkPlane
19     @param plane: Plane to clip the object
20     """
21    
22     self.__object = object
23     # True only if a plane is used to perform clipping. False for
24     # scalar clipping.
25     if(plane != None):
26     self.__plane = plane
27    
28     self.__vtk_clipper = vtk.vtkClipDataSet()
29     self.__setupClipper()
30    
31     def __setupClipper(self):
32     """
33     Setup the clipper.
34     """
35    
36     self.__setInput()
37     self.setInsideOutOn()
38     self.__vtk_clipper.Update()
39    
40     def __setInput(self):
41     """
42     Set the input for the clipper.
43     """
44    
45     self.__vtk_clipper.SetInput(self.__object)
46    
47     def _setClipFunction(self):
48     """
49     Set the clip function (using a plane) for the clipper.
50     """
51    
52     self.__vtk_clipper.SetClipFunction(self.__plane)
53    
54     def setInsideOutOn(self):
55     """
56     Clip one side of the rendered object.
57     """
58    
59     self.__vtk_clipper.InsideOutOn()
60    
61     def setInsideOutOff(self):
62     """
63     Clips the other side of the rendered object.
64     """
65    
66     self.__vtk_clipper.InsideOutOff()
67    
68     def setClipValue(self, value):
69     """
70     Set the scalar clip value (intead of using a plane) for the clipper.
71    
72     @type value: Number
73     @param value: Scalar clip value
74     """
75    
76     self.__vtk_clipper.SetValue(value)
77    
78     def _getOutput(self):
79     """
80     Return the output of the clipper.
81    
82     @rtype: vtkUnstructuredGrid
83     @return: Unstructured grid
84     """
85    
86     return self.__vtk_clipper.GetOutput()
87    

  ViewVC Help
Powered by ViewVC 1.1.26