Debian Codegraph @

packages/seacas/libraries/ioss/src/visualization/catalyst/phactori/Operation/PhactoriCylinderClipOperation.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 PhactoriCylinderClipOperation(PhactoriOperationSpecifics):
38 def __init__(self):
39 PhactoriOperationSpecifics.__init__(self)
40 self.mCenterPtInfo = PhactoriUserPointInfo()
41 self.mAxis = [0.0, 1.0, 0.0]
42 self.mRadius = 0.5
43 self.mRadiusRelAbsFlag = True
44 self.mKeepInside = True
45 self.mCrinkleSetting = None
46
47 def ParseParametersFromJson(self, inJson):
48 if PhactoriDbg(100):
49 myDebugPrint3(
50 'PhactoriCylinderClipOperation.ParseParametersFromJson entered\n', 100)
51 self.mCenterPtInfo.UserPointInfoParseParametersFromJson(
52 inJson, "center at ", "")
53
54 absRadiusKey = 'absolute radius'
55 relRadiusKey = 'relative radius'
56 if absRadiusKey in inJson:
57 self.mRadius = inJson[absRadiusKey]
58 self.mRadiusRelAbsFlag = False
59 elif relRadiusKey in inJson:
60 self.mRadius = inJson[relRadiusKey]
61 self.mRadiusRelAbsFlag = True
62 else:
63 self.mRadius = 0.5
64 self.mRadiusRelAbsFlag = True
65
66 axisKey = 'axis'
67 if axisKey in inJson:
68 self.mAxis = inJson[axisKey]
69
70 if 'keep inside cylinder' in inJson:
71 self.mKeepInside = inJson['keep inside cylinder']
72 else:
73 self.mKeepInside = True
74
75 if 'cut type' in inJson:
76 cutType = inJson['cut type']
77 self.mCrinkleSetting = 0
78 if cutType == 'smooth':
79 self.mCrinkleSetting = 0
80 elif cutType == 'crinkle':
81 self.mCrinkleSetting = 1
82 else:
83 if PhactoriDbg():
84 myDebugPrint3('ParseParametersFromJson warning: cut type \
85 should be smooth or crinkle, but is not, using smooth\n')
86 self.mCrinkleSetting = 0
87 else:
88 self.mCrinkleSetting = 0 #debatable default
89
90 #self.PrintSelf()
91 if PhactoriDbg(100):
92 myDebugPrint3(
93 'PhactoriCylinderClipOperation.ParseParametersFromJson returning\n',
94 100)
95
96 def PrintSelf(self):
97 if PhactoriDbg(100):
98 myDebugPrint3('PhactoriCylinderClipOperation.PrintSelf entered\n" + \
99 "Center Point:', 100)
100 self.mCenterPtInfo.PrintSelf()
101 if PhactoriDbg():
102 myDebugPrint3('mRadiusRelAbsFlag: ' + str(self.mRadiusRelAbsFlag) + '\n')
103 if PhactoriDbg():
104 myDebugPrint3('mRadius: ' + str(self.mRadius) + '\n')
105 if PhactoriDbg():
106 myDebugPrint3('mAxis: ' + str(self.mAxis) + '\n')
107 if PhactoriDbg():
108 myDebugPrint3('mKeepInside: ' + str(self.mKeepInside) + '\n')
109 if PhactoriDbg():
110 myDebugPrint3('mCrinkleSetting: ' + str(self.mCrinkleSetting) + '\n')
111
112 def CreateParaViewFilter(self, inInputFilter):
113 """create the cylinder clip filter for ParaView"""
114 if PhactoriDbg(100):
115 myDebugPrint3('PhactoriCylinderClipOperation.CreateParaViewFilter ' +\
116 'entered\n', 100)
117 #info in block class should already be parsed and checked
118
119 savedActiveSource = GetActiveSource()
120
121 newParaViewFilter = Clip(Input = inInputFilter, ClipType = "Cylinder")
122 ## Properties modified on clip4.ClipType
123 #clip4.ClipType.Center = [10.93421983718872, -0.8890213072299957, 0.0]
124 #clip4.ClipType.Axis = [1.0, 0.0, 0.0]
125 #clip4.ClipType.Radius = 0.75
126
127 newParaViewFilter.ClipType.Axis = self.mAxis
128
129 viewBoundsArray = [None]
130 centerToUse = self.mCenterPtInfo.GetCurrentGeometricPointWithDisplacement(
131 inInputFilter, viewBoundsArray, True)
132
133 newParaViewFilter.ClipType.Center = [centerToUse[0],
134 centerToUse[1],
135 centerToUse[2]]
136
137 if PhactoriDbg():
138 myDebugPrint3(" about to find radius--absolute or calced from relative\n")
139 myViewBounds = viewBoundsArray[0]
140 if self.mRadiusRelAbsFlag:
141 if myViewBounds == None:
142 myViewBounds = GetGlobalDataBoundsParallel(inInputFilter)
143 dxx = myViewBounds[1] - myViewBounds[0]
144 dyy = myViewBounds[3] - myViewBounds[2]
145 dzz = myViewBounds[5] - myViewBounds[4]
146 bounds_diagonal = math.sqrt(dxx*dxx + dyy*dyy + dzz*dzz)
147 newParaViewFilter.ClipType.Radius = self.mRadius * bounds_diagonal
148 else:
149 newParaViewFilter.ClipType.Radius = self.mRadius
150
151 newParaViewFilter.Crinkleclip = self.mCrinkleSetting
152 if self.mKeepInside:
153 newParaViewFilter.InsideOut = 1
154 else:
155 newParaViewFilter.InsideOut = 0
156
157 SetActiveSource(newParaViewFilter)
158 SetActiveSource(savedActiveSource)
159
160 if PhactoriDbg(100):
161 myDebugPrint3(
162 'PhactoriCylinderClipOperation.CreateParaViewFilter returning\n', 100)
163
164 return newParaViewFilter
165
166 def MayChangeWithData(self):
167 if self.mCenterPtInfo.mMayChangeWithData == True:
168 return True
169 if self.mRadiusRelAbsFlag == True:
170 return True
171 return False
172 #phactori_combine_to_single_python_file_subpiece_end_1