Debian Codegraph @

packages/seacas/libraries/ioss/src/visualization/catalyst/phactori/Operation/PhactoriAddUnstructuredGridOperation.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 PhactoriAddUnstructuredGridOperation(PhactoriOperationSpecifics):
38 """filter/operation which reads in a .vtu file which is an unstructured
39 grid and creates a new source from that and groups it with the
40 input source"""
41 def __init__(self):
42 self.mFilename = None
43 self.mInternalPvUnstructuredGridReader = None
44
45 def ParseParametersFromJson(self, inJson):
46 if 'filename' in inJson:
47 self.mFilename = inJson['filename']
48 else:
49 myDebugPrint3AndException(
50 "PhactoriAddUnstructuredGridOperation::ParseParametersFromJson\n"
51 "Error: must have 'filename' key\n")
52
53 def CreateParaViewFilter(self, inInputFilter):
54 """create the read unstructured grid (and group) filter for ParaView"""
55 if PhactoriDbg(100):
56 myDebugPrint3("PhactoriAddUnstructuredGridOperation.CreateParaViewFilter "
57 "entered\n", 100)
58
59 savedActiveSource = GetActiveSource()
60
61 #csv reader
62 self.mInternalPvUnstructuredGridReader = XMLUnstructuredGridReader( FileName=[self.mFilename] )
63
64 #don't know if this is necessary here
65 UpdatePipelineWithCurrentTimeArgument(self.mInternalPvUnstructuredGridReader)
66
67 #now group this new point set source with the original one
68 newParaViewFilter = GroupDatasets()
69 newParaViewFilter.Input = [self.mInternalPvUnstructuredGridReader, inInputFilter]
70
71 SetActiveSource(newParaViewFilter)
72 SetActiveSource(savedActiveSource)
73
74 UpdatePipelineWithCurrentTimeArgument(newParaViewFilter)
75
76 if PhactoriDbg(100):
77 myDebugPrint3(
78 "filename: " + str(self.mInternalPvUnstructuredGridReader.FileName) + "\n")
79 myDebugPrint3("PhactoriAddUnstructuredGridOperation.CreateParaViewFilter "
80 "returning\n", 100)
81
82 return newParaViewFilter
83 #phactori_combine_to_single_python_file_subpiece_end_1