1 |
""" |
2 |
@var __author__: name of author |
3 |
@var __copyright__: copyrights |
4 |
@var __license__: licence agreement |
5 |
@var __url__: url entry point on documentation |
6 |
@var __version__: version |
7 |
@var __date__: date of the version |
8 |
""" |
9 |
|
10 |
__author__="John Ngui, john.ngui@uq.edu.au" |
11 |
__copyright__=""" Copyright (c) 2006 by ACcESS MNRF |
12 |
http://www.access.edu.au |
13 |
Primary Business: Queensland, Australia""" |
14 |
__license__="""Licensed under the Open Software License version 3.0 |
15 |
http://www.opensource.org/licenses/osl-3.0.php""" |
16 |
__url__="http://www.iservo.edu.au/esys" |
17 |
__version__="$Revision$" |
18 |
__date__="$Date$" |
19 |
|
20 |
|
21 |
import vtk |
22 |
|
23 |
class Clipper: |
24 |
""" |
25 |
Class that defines a clipper. |
26 |
""" |
27 |
|
28 |
def __init__(self): |
29 |
""" |
30 |
Initialise the clipper. |
31 |
""" |
32 |
|
33 |
self.__vtk_clipper = vtk.vtkClipDataSet() |
34 |
|
35 |
def _setupClipper(self, object, plane): |
36 |
""" |
37 |
Setup the clipper. |
38 |
|
39 |
@type object: vtkUnstructuredGrid, etc |
40 |
@param object: Input for the clipper |
41 |
@type plane: vtkPlane |
42 |
@param plane: Plane to clip the object |
43 |
""" |
44 |
|
45 |
self.__object = object |
46 |
# True only if a plane is used to perform clipping. False for |
47 |
# scalar clipping. |
48 |
if(plane != None): |
49 |
self.__plane = plane |
50 |
|
51 |
self.__setInput() |
52 |
self.setInsideOutOn() |
53 |
|
54 |
def __setInput(self): |
55 |
""" |
56 |
Set the input for the clipper. |
57 |
""" |
58 |
|
59 |
self.__vtk_clipper.SetInput(self.__object) |
60 |
|
61 |
def _setClipFunction(self): |
62 |
""" |
63 |
Set the clip function (using a plane) for the clipper. |
64 |
""" |
65 |
|
66 |
self.__vtk_clipper.SetClipFunction(self.__plane) |
67 |
|
68 |
def setInsideOutOn(self): |
69 |
""" |
70 |
Clip one side of the rendered object. |
71 |
""" |
72 |
|
73 |
self.__vtk_clipper.InsideOutOn() |
74 |
|
75 |
def setInsideOutOff(self): |
76 |
""" |
77 |
Clips the other side of the rendered object. |
78 |
""" |
79 |
|
80 |
self.__vtk_clipper.InsideOutOff() |
81 |
|
82 |
def setClipValue(self, value): |
83 |
""" |
84 |
Set the scalar clip value (intead of using a plane) for the clipper. |
85 |
|
86 |
@type value: Number |
87 |
@param value: Scalar clip value |
88 |
""" |
89 |
|
90 |
self.__vtk_clipper.SetValue(value) |
91 |
|
92 |
def _getClipperOutput(self): |
93 |
""" |
94 |
Return the output of the clipper. |
95 |
|
96 |
@rtype: vtkUnstructuredGrid |
97 |
@return: Unstructured grid |
98 |
""" |
99 |
|
100 |
return self.__vtk_clipper.GetOutput() |
101 |
|