Debian Codegraph @

packages/seacas/libraries/ioss/src/visualization/catalyst/phactori/Operation/PhactoriClipPlaneOperation.py

raw
1 # Copyright(C) 1999-2020 National Technology & Engineering Solutions
2 # of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
3 # NTESS, the U.S. Government retains certain rights in this software.
4 #
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are
7 # met:
8 #
9 # * Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 #
12 # * Redistributions in binary form must reproduce the above
13 # copyright notice, this list of conditions and the following
14 # disclaimer in the documentation and/or other materials provided
15 # with the distribution.
16 #
17 # * Neither the name of NTESS nor the names of its
18 # contributors may be used to endorse or promote products derived
19 # from this software without specific prior written permission.
20 #
21 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
33 from phactori import *
34 from paraview.simple import *
35
36 #phactori_combine_to_single_python_file_subpiece_begin_1
37 class PhactoriClipPlaneOperation(PhactoriPlaneOpBase):
38 """clip plane operation, adapter to the catalyst filter
39
40 PhactoriSliceWithPlaneOperation is the phactori manager for working with the
41 ParaView/Catalyst Clip() filter and its parameters, providing
42 access and pipeline/input/output managment via the json, lexx/yacc, or soon
43 yaml interface. The user may specify a named input to the filter, with the
44 unnamed default being the incoming data mesh. This class is confined to a
45 ParaView Clip operation with a clip type of plane. See
46 PhactoriBoxClipOperation and PhactoriCylinderClipOperation for clipping with
47 a type of box and cylinder, and other classes may be added for other clip
48 types.
49
50 For information on the Clip() filter from ParaView, see the ParaView
51 Documentation.
52
53 The user must define the plane with a point and normal or with three points.
54 There are defaults which will be used if the user does not supply some or
55 all of the definition. PhactoriClipPlaneOperation is a child class of
56 PhactoriPlaneOpBase, along with PhactoriSliceWithPlaneOperation and
57 PhactoriSliceOperation. Check the documentation for PhactoriPlaneOpBase
58 for the many options for defining the plane point(s), including absolute or
59 relative 3D points, dynamic data-driven point locations, or collocating with
60 mesh nodes or elements (or offset therefrom).
61
62 The user may also choose to make a "crinkle" or "smooth" cut with the
63 "cut type" key, defaulting to
64 smooth. A smooth cut makes a two dimentional plane, while a crinkle cut
65 includes all elements cut by the plane and creates no new elements which
66 were not in the original mesh. The user may also choose to keep either side
67 of the plane by using the key "side to keep" and setting to "positive" or
68 "negative".
69
70 To add a PhactoriClipPlaneOperation to the incoming script, you add
71 a sub-block to the "operation blocks" section of the data with the "type"
72 key given a value of "clip". One complete but simple example
73 script:
74
75 ::
76
77 {
78 "camera blocks":{"myclipcam1":{"type":"camera", "look direction":[1.0, 2.0, 3.0]}},
79 "representation blocks":{"rep_tmprtr":{"color by scalar":"temperature"}},
80 "imageset blocks":{
81 "temperature_clip_1":{
82 "operation":"myclipwithplane1",
83 "camera":"myclipcam1",
84 "representation":"rep_tmprtr",
85 "image basedirectory":"CatalystOutput",
86 "image basename":"clip1_temperature."
87 }
88 },
89 "operation blocks":{
90 "myclipwithplane1":{
91 "type":"clip",
92 "cut type":"crinkle",
93 "side to keep":"negative",
94 "relative point on plane":[0.1, -0.2, 0.3],
95 "plane normal":[1.0, 2.0, 3.0]
96 }
97 }
98
99 The "point on plane" is a PhactoriUserPointInfo instance, which means it can
100 be an absolute point, a relative point, a data point (at min or max of a data
101 array), at a node/point, at an element/cell, or at a data min max or cell or
102 element but displaced by a vector. See the PhactoriUserPointInfo class for more
103 detailed info.
104
105 Further, the plane may also be define with three points instead of a point and
106 a normal. To use this format, omit the "plane normal" and "... point on plane"
107 keys and instead have keys with "point on plane A", "point and plane B", and
108 "point on plane C". For example:
109
110 ::
111
112 "absolute point on plane A":[0.0, 1.0, 2.0],
113 "relative point on plane B":[0.0, 0.2, -0.3],
114 "relative point on plane C":[0.0, 0.0, -0.0],
115
116 """
117
118 def CreateParaViewFilter(self, inInputFilter):
119
120 #don't need our own init code at this point, but this is how it would be
121 #added
122 #def __init__(self):
123 # MySuperClass.__init__(self)
124
125 """create the clip plane filter for ParaView"""
126 if PhactoriDbg(100):
127 myDebugPrint3('PhactoriClipPlaneOperation.CreateParaViewFilter entered\n', 100)
128 #info in block class should already be parsed and checked
129
130 savedActiveSource = GetActiveSource()
131 newParaViewFilter = Clip(Input = inInputFilter, ClipType = "Plane")
132 self.UpdateClip(inInputFilter, newParaViewFilter)
133
134 SetActiveSource(newParaViewFilter)
135 SetActiveSource(savedActiveSource)
136
137 if PhactoriDbg(100):
138 myDebugPrint3('PhactoriClipPlaneOperation.CreateParaViewFilter returning\n', 100)
139
140 return newParaViewFilter
141
142 def DoUpdateDueToChangeInData(self, inIncomingPvFilter,
143 outOutgoingPvFilter):
144 """the PhactoriClipPlaneOperation may need to update if the point on
145 the clip plane was tied to a node, element, or variable min/max
146 location"""
147 if PhactoriDbg():
148 myDebugPrint3("PhactoriClipPlaneOperation::"
149 "DoUpdateDueToChangeInData override executing\n")
150
151 if self.MayChangeWithData() == False:
152 if PhactoriDbg():
153 myDebugPrint3("PhactoriClipPlaneOperation::"
154 "DoUpdateDueToChangeInData returning (absolute point or points)\n")
155 return
156
157 self.UpdateClip(inIncomingPvFilter, outOutgoingPvFilter)
158
159 if PhactoriDbg():
160 myDebugPrint3("PhactoriClipPlaneOperation::"
161 "DoUpdateDueToChangeInData override returning\n")
162
163 def UpdateClip(self, inIncomingPvFilter, ioOutgoingPvFilter):
164 """using the current info on the clip, get all the paraview stuff
165 set up correctly"""
166
167 if PhactoriDbg():
168 myDebugPrint3("PhactoriClipPlaneOperation::UpdateClip entered\n")
169
170 originToUse = [0,0,0]
171 normalToUse = [0,1,0]
172 self.CalculateUpdatedOriginAndNormal(
173 inIncomingPvFilter, originToUse, normalToUse)
174
175 if PhactoriDbg():
176 myDebugPrint3(' updateclip using normal: ' + \
177 str(normalToUse) + '\n')
178 ioOutgoingPvFilter.ClipType.Normal = normalToUse
179
180 if PhactoriDbg():
181 myDebugPrint3(' updateclip using origin: ' + str(originToUse) + '\n')
182 ioOutgoingPvFilter.ClipType.Origin = originToUse
183
184 #these aren't changing yet
185 ioOutgoingPvFilter.Crinkleclip = self.mCrinkleSetting
186 if gParaViewCatalystVersionFlag < 50502:
187 ioOutgoingPvFilter.InsideOut = self.mInsideOut
188 else:
189 ioOutgoingPvFilter.Invert = self.mInvert
190
191 if PhactoriDbg():
192 myDebugPrint3("PhactoriClipPlaneOperation::UpdateClip returning\n")
193 #phactori_combine_to_single_python_file_subpiece_end_1
194