Debian Codegraph @

packages/seacas/libraries/ioss/src/visualization/catalyst/phactori/Operation/PhactoriAddPointSetOperation.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 PhactoriAddPointSetOperation(PhactoriOperationSpecifics):
38 """filter/operation which reads in a .csv file which is a set of points and
39 creates a new source from that and groups it with the input source"""
40 def __init__(self):
41 self.mXColumn = 'x column'
42 self.mYColumn = 'y column'
43 self.mZColumn = 'z column'
44 self.m2dPointsFlag = False
45 self.mFieldDelimeterCharacters = ','
46 self.mFilename = None
47 self.mInternalPvCSVReader = None
48 self.mInternalPvTableToPoints = None
49
50 def ParseParametersFromJson(self, inJson):
51 if 'filename' in inJson:
52 self.mFilename = inJson['filename']
53 else:
54 myDebugPrint3AndException(
55 "PhactoriAddPointSetOperation::ParseParametersFromJson\n"
56 "Error: must have 'filename' key\n")
57 if 'x column' in inJson:
58 self.mXColumn = inJson['x column']
59 if 'y column' in inJson:
60 self.mYColumn = inJson['y column']
61 if 'z column' in inJson:
62 self.mZColumn = inJson['z column']
63 if '2d points flag' in inJson:
64 self.m2dPointsFlag = inJson['2d points flag']
65 if 'field delimeter' in inJson:
66 self.mFieldDelimeterCharacters = inJson['field delimeter']
67
68 def CreateParaViewFilter(self, inInputFilter):
69 """create the read pointset (and group) filter for ParaView"""
70 if PhactoriDbg(100):
71 myDebugPrint3("PhactoriAddPointSetOperation.CreateParaViewFilter "
72 "entered\n", 100)
73
74 savedActiveSource = GetActiveSource()
75
76 #csv reader
77 self.mInternalPvCSVReader = CSVReader( FileName=[self.mFilename] )
78 self.mInternalPvCSVReader.FieldDelimiterCharacters = self.mFieldDelimeterCharacters
79 #don't know if this is necessary here
80 UpdatePipelineWithCurrentTimeArgument(self.mInternalPvCSVReader)
81
82 #table to points
83 self.mInternalPvTableToPoints = TableToPoints(self.mInternalPvCSVReader)
84 self.mInternalPvTableToPoints.XColumn = self.mXColumn
85 self.mInternalPvTableToPoints.YColumn = self.mYColumn
86 self.mInternalPvTableToPoints.ZColumn = self.mZColumn
87 if self.m2dPointsFlag:
88 self.mInternalPvTableToPoints.a2DPoints = 1
89 else:
90 self.mInternalPvTableToPoints.a2DPoints = 0
91 #don't know if this is necessary here
92 UpdatePipelineWithCurrentTimeArgument(self.mInternalPvTableToPoints)
93
94 #now group this new point set source with the original one
95 newParaViewFilter = GroupDatasets()
96 newParaViewFilter.Input = [self.mInternalPvTableToPoints, inInputFilter]
97 #newParaViewFilter = self.mInternalPvTableToPoints
98
99 SetActiveSource(newParaViewFilter)
100 SetActiveSource(savedActiveSource)
101
102 UpdatePipelineWithCurrentTimeArgument(newParaViewFilter)
103
104 if PhactoriDbg(100):
105 myDebugPrint3(
106 "filename: " + str(self.mInternalPvCSVReader.FileName) + "\n"
107 "delimeter: -->" + str(self.mInternalPvCSVReader.FieldDelimiterCharacters) + "<--\n"
108 "x column: " + str(self.mInternalPvTableToPoints.XColumn) + "\n"
109 "y column: " + str(self.mInternalPvTableToPoints.YColumn) + "\n"
110 "z column: " + str(self.mInternalPvTableToPoints.ZColumn) + "\n"
111 "2d points flag: " + str(self.mInternalPvTableToPoints.a2DPoints) + "\n")
112 myDebugPrint3("PhactoriAddPointSetOperation.CreateParaViewFilter "
113 "returning\n", 100)
114
115 return newParaViewFilter
116
117 #phactori_combine_to_single_python_file_subpiece_end_1