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