1 |
""" |
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 rendered object |
20 |
""" |
21 |
|
22 |
self.__object = object |
23 |
# True only if a plane is used to perform clipping. Will be false |
24 |
# for 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). |
50 |
""" |
51 |
|
52 |
self.__vtk_clipper.SetClipFunction(self.__plane) |
53 |
|
54 |
def setInsideOutOn(self): |
55 |
""" |
56 |
Clips the 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. |
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 |
|