Debian Codegraph @

packages/seacas/libraries/ioss/src/visualization/catalyst/phactori/Operation/PhactoriPlaneSource.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 from .PhactoriMpiUtilities import *
36
37 #phactori_combine_to_single_python_file_subpiece_begin_1
38
39 class PhactoriPlaneSource(PhactoriOperationSpecifics):
40 """Phactori interface to the ParaView Plane Geometric Source. Allows user to
41 specify a plane (rectangle) by 3 points in space and a tesselation
42 resolution in each dimension of the rectangle"""
43
44 def __init__(self):
45 self.PlaneOrigin = [-0.5, -0.5, 0.0]
46 self.PlanePoint1 = [ 0.5, -0.5, 0.0]
47 self.PlanePoint2 = [-0.5, 0.5, 0.0]
48 self.PlaneXResolution = 1
49 self.PlaneYResolution = 1
50
51 def ParseParametersFromJson(self, inJson):
52 key1 = "origin"
53 if key1 in inJson:
54 self.PlaneOrigin = inJson[key1]
55 try:
56 if len(self.PlaneOrigin) != 3:
57 myDebugPrint3AndException(
58 "PhactoriPlaneSource:ParseParametersFromJson\n"
59 "bad 'origin', must be 3 number list list [1.1,2.3,-4.5]\n")
60 except:
61 myDebugPrint3AndException(
62 "PhactoriPlaneSource:ParseParametersFromJson\n"
63 "bad 'origin', must be 3 number list list [1.1,2.3,-4.5]\n")
64
65 key1 = "point1"
66 if key1 in inJson:
67 self.PlanePoint1 = inJson[key1]
68 try:
69 if len(self.PlanePoint1) != 3:
70 myDebugPrint3AndException(
71 "PhactoriPlaneSource:ParseParametersFromJson\n"
72 "bad 'point1', must be 3 number list list [1.1,2.3,-4.5]\n")
73 except:
74 myDebugPrint3AndException(
75 "PhactoriPlaneSource:ParseParametersFromJson\n"
76 "bad 'point1', must be 3 number list list [1.1,2.3,-4.5]\n")
77
78 key1 = "point2"
79 if key1 in inJson:
80 self.PlanePoint2 = inJson[key1]
81 try:
82 if len(self.PlanePoint2) != 3:
83 myDebugPrint3AndException(
84 "PhactoriPlaneSource:ParseParametersFromJson\n"
85 "bad 'point2', must be 3 number list list [1.1,2.3,-4.5]\n")
86 except:
87 myDebugPrint3AndException(
88 "PhactoriPlaneSource:ParseParametersFromJson\n"
89 "bad 'point2', must be 3 number list list [1.1,2.3,-4.5]\n")
90
91 key1 = "xresolution"
92 if key1 in inJson:
93 self.PlaneXResolution = inJson[key1]
94 if isinstance(self.PlaneXResolution, int):
95 if self.PlaneXResolution < 1:
96 myDebugPrint3AndException(
97 "PhactoriPlaneSource:ParseParametersFromJson\n"
98 "'xresolution' must be integer >= 1\n")
99 else:
100 myDebugPrint3AndException(
101 "PhactoriPlaneSource:ParseParametersFromJson\n"
102 "'xresolution' must be integer >= 1\n")
103
104 key1 = "yresolution"
105 if key1 in inJson:
106 self.PlaneYResolution = inJson[key1]
107 if isinstance(self.PlaneYResolution, int):
108 if self.PlaneYResolution < 1:
109 myDebugPrint3AndException(
110 "PhactoriPlaneSource:ParseParametersFromJson\n"
111 "'yresolution' must be integer >= 1\n")
112 else:
113 myDebugPrint3AndException(
114 "PhactoriPlaneSource:ParseParametersFromJson\n"
115 "'yresolution' must be integer >= 1\n")
116
117 def CreateParaViewFilter(self, inInputFilter):
118 if PhactoriDbg(100):
119 myDebugPrint3("PhactoriPlaneSource.CreateParaViewFilter entered\n", 100)
120
121 savedActiveSource = GetActiveSource()
122
123 newParaViewFilter = Plane()
124
125 newParaViewFilter.Origin = self.PlaneOrigin
126 newParaViewFilter.Point1 = self.PlanePoint1
127 newParaViewFilter.Point2 = self.PlanePoint2
128 newParaViewFilter.XResolution = self.PlaneXResolution
129 newParaViewFilter.YResolution = self.PlaneYResolution
130
131 UpdatePipelineWithCurrentTimeArgument(newParaViewFilter)
132
133 SetActiveSource(newParaViewFilter)
134 SetActiveSource(savedActiveSource)
135
136 if PhactoriDbg(100):
137 myDebugPrint3(
138 "Origin: " + str(newParaViewFilter.Origin) + "\n" + \
139 "Point1: " + str(newParaViewFilter.Point1) + "\n" + \
140 "Point2: " + str(newParaViewFilter.Point2) + "\n" + \
141 "XResolution: " + str(newParaViewFilter.XResolution) + "\n" + \
142 "YResolution: " + str(newParaViewFilter.YResolution) + "\n")
143
144 if PhactoriDbg(100):
145 myDebugPrint3("PhactoriPlaneSource.CreateParaViewFilter returning\n", 100)
146
147 return newParaViewFilter
148
149 #phactori_combine_to_single_python_file_subpiece_end_1
150