| 1 |
# Copyright(C) 1999-2021, 2024 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 PhactoriGlyphOperation(PhactoriOperationSpecifics): |
| 38 |
"""manages Glyph filter""" |
| 39 |
def __init__(self): |
| 40 |
PhactoriOperationSpecifics.__init__(self) |
| 41 |
self.scaleFactor = None |
| 42 |
self.glyphType = "Arrow" |
| 43 |
self.ArrowTipResolution = None |
| 44 |
self.ArrowTipRadius = None |
| 45 |
self.ArrowTipLength = None |
| 46 |
self.ArrowShaftResolution = None |
| 47 |
self.ArrowShaftRadius = None |
| 48 |
self.scaleArray = None |
| 49 |
self.orientationArray = None |
| 50 |
|
| 51 |
def ParseParametersFromJson(self, inJson): |
| 52 |
if PhactoriDbg(100): |
| 53 |
myDebugPrint3("PhactoriGlyphOperation.ParseParametersFromJson " |
| 54 |
"entered\n", 100) |
| 55 |
|
| 56 |
key1 = "scale factor" |
| 57 |
if key1 in inJson: |
| 58 |
self.scaleFactor = inJson[key1] |
| 59 |
if self.scaleFactor <= 0.0: |
| 60 |
myDebugPrint3AndException( |
| 61 |
"PhactoriGlyphOperation.ParseParametersFromJson:\nbad " + \ |
| 62 |
key1 + "\n") |
| 63 |
exit(-1) |
| 64 |
|
| 65 |
glyphSet = {} |
| 66 |
glyphSet["arrow"] = "Arrow" |
| 67 |
glyphSet["box"] = "Box" |
| 68 |
key1 = "glyph type" |
| 69 |
if key1 in inJson: |
| 70 |
glyphkey1 = inJson[key1] |
| 71 |
if glyphkey1 not in glyphSet: |
| 72 |
myDebugPrint3AndException( |
| 73 |
"PhactoriGlyphOperation.ParseParametersFromJson:\nbad " + \ |
| 74 |
key1 + "\n") |
| 75 |
exit(-1) |
| 76 |
self.glyphType = glyphSet[glyphkey1] |
| 77 |
|
| 78 |
key1 = "scale array" |
| 79 |
if key1 in inJson: |
| 80 |
self.scaleArray = inJson[key1] |
| 81 |
|
| 82 |
key1 = "orientation array" |
| 83 |
if key1 in inJson: |
| 84 |
self.orientationArray = inJson[key1] |
| 85 |
|
| 86 |
if PhactoriDbg(100): |
| 87 |
myDebugPrint3("self.scaleArray " + str(self.scaleArray) + "\n") |
| 88 |
myDebugPrint3("self.orientationArray " + str(self.orientationArray) + "\n") |
| 89 |
|
| 90 |
if self.glyphType == "Arrow": |
| 91 |
key1 = "tip resolution" |
| 92 |
if key1 in inJson: |
| 93 |
self.ArrowTipResolution = inJson[key1] |
| 94 |
if self.ArrowTipResolution <= 0: |
| 95 |
myDebugPrint3AndException( |
| 96 |
"PhactoriGlyphOperation.ParseParametersFromJson:\nbad " + \ |
| 97 |
key1 + "\n") |
| 98 |
exit(-1) |
| 99 |
key1 = "tip length" |
| 100 |
if key1 in inJson: |
| 101 |
self.ArrowTipLength = inJson[key1] |
| 102 |
if self.ArrowTipLength < 0.0: |
| 103 |
myDebugPrint3AndException( |
| 104 |
"PhactoriGlyphOperation.ParseParametersFromJson:\nbad " + \ |
| 105 |
key1 + "\n") |
| 106 |
exit(-1) |
| 107 |
key1 = "tip radius" |
| 108 |
if key1 in inJson: |
| 109 |
self.ArrowTipRadius = inJson[key1] |
| 110 |
if self.ArrowTipRadius <= 0.0: |
| 111 |
myDebugPrint3AndException( |
| 112 |
"PhactoriGlyphOperation.ParseParametersFromJson:\nbad " + \ |
| 113 |
key1 + "\n") |
| 114 |
exit(-1) |
| 115 |
key1 = "shaft resolution" |
| 116 |
if key1 in inJson: |
| 117 |
self.ArrowShaftResolution = inJson[key1] |
| 118 |
if self.ArrowShaftResolution <= 0: |
| 119 |
myDebugPrint3AndException( |
| 120 |
"PhactoriGlyphOperation.ParseParametersFromJson:\nbad " + \ |
| 121 |
key1 + "\n") |
| 122 |
exit(-1) |
| 123 |
key1 = "shaft radius" |
| 124 |
if key1 in inJson: |
| 125 |
self.ArrowShaftRadius = inJson[key1] |
| 126 |
if self.ArrowShaftRadius <= 0.0: |
| 127 |
myDebugPrint3AndException( |
| 128 |
"PhactoriGlyphOperation.ParseParametersFromJson:\nbad " + \ |
| 129 |
key1 + "\n") |
| 130 |
exit(-1) |
| 131 |
|
| 132 |
if PhactoriDbg(100): |
| 133 |
myDebugPrint3("PhactoriGlyphOperation.ParseParametersFromJson " |
| 134 |
"returning\n", 100) |
| 135 |
|
| 136 |
def CreateParaViewFilter(self, inInputFilter): |
| 137 |
"""create the Glyph filter for ParaView""" |
| 138 |
if PhactoriDbg(100): |
| 139 |
myDebugPrint3("PhactoriGlyphOperation.CreateParaViewFilter " |
| 140 |
"entered\n", 100) |
| 141 |
|
| 142 |
savedActiveSource = GetActiveSource() |
| 143 |
|
| 144 |
UpdatePipelineWithCurrentTimeArgument(inInputFilter) |
| 145 |
|
| 146 |
if PhactoriDbg(100): |
| 147 |
myDebugPrint3("self.glyphType: " + str(self.glyphType) + "\n") |
| 148 |
|
| 149 |
newParaViewFilter = Glyph(Input=inInputFilter, GlyphType=self.glyphType) |
| 150 |
#newParaViewFilter.OrientationArray = ['POINTS', 'No orientation array'] |
| 151 |
#newParaViewFilter.ScaleArray = ['POINTS', 'No scale array'] |
| 152 |
#newParaViewFilter.ScaleFactor = 0.1753620492294431 |
| 153 |
newParaViewFilter.GlyphTransform = 'Transform2' |
| 154 |
if self.scaleArray != None: |
| 155 |
newParaViewFilter.ScaleArray = self.scaleArray |
| 156 |
else: |
| 157 |
newParaViewFilter.ScaleArray = ['POINTS', 'velocity_xyz'] |
| 158 |
if self.orientationArray != None: |
| 159 |
newParaViewFilter.OrientationArray = self.orientationArray |
| 160 |
else: |
| 161 |
newParaViewFilter.OrientationArray = ['POINTS', 'velocity_xyz'] |
| 162 |
if PhactoriDbg(100): |
| 163 |
myDebugPrint3("newParaViewFilter.ScaleArray " + str(newParaViewFilter.ScaleArray) + "\n") |
| 164 |
myDebugPrint3("newParaViewFilter.OrientationArray " + str(newParaViewFilter.OrientationArray) + "\n") |
| 165 |
#newParaViewFilter.ScaleFactor = 1e-05 |
| 166 |
newParaViewFilter.GlyphMode = 'All Points' |
| 167 |
if self.scaleFactor != None: |
| 168 |
newParaViewFilter.ScaleFactor = self.scaleFactor |
| 169 |
if self.ArrowTipResolution != None: |
| 170 |
newParaViewFilter.GlyphType.TipResolution = self.ArrowTipResolution |
| 171 |
if self.ArrowShaftResolution != None: |
| 172 |
newParaViewFilter.GlyphType.ShaftResolution = self.ArrowShaftResolution |
| 173 |
if self.ArrowTipRadius != None: |
| 174 |
newParaViewFilter.GlyphType.TipRadius = self.ArrowTipRadius |
| 175 |
if self.ArrowShaftRadius != None: |
| 176 |
newParaViewFilter.GlyphType.ShaftRadius = self.ArrowShaftRadius |
| 177 |
if self.ArrowTipLength != None: |
| 178 |
newParaViewFilter.GlyphType.TipLength = self.ArrowTipLength |
| 179 |
|
| 180 |
# init the 'Arrow' selected for 'GlyphType' |
| 181 |
#newParaViewFilter.GlyphType.TipResolution = 6 |
| 182 |
#newParaViewFilter.GlyphType.TipRadius = 0.05 |
| 183 |
#newParaViewFilter.GlyphType.TipLength = 0.3 |
| 184 |
#newParaViewFilter.GlyphType.ShaftResolution = 6 |
| 185 |
#newParaViewFilter.GlyphType.ShaftRadius = 0.05 |
| 186 |
|
| 187 |
UpdatePipelineWithCurrentTimeArgument(newParaViewFilter) |
| 188 |
SetActiveSource(newParaViewFilter) |
| 189 |
SetActiveSource(savedActiveSource) |
| 190 |
|
| 191 |
if PhactoriDbg(100): |
| 192 |
myDebugPrint3("PhactoriGlyphOperation.CreateParaViewFilter " |
| 193 |
"returning\n", 100) |
| 194 |
|
| 195 |
return newParaViewFilter |
| 196 |
|
| 197 |
#phactori_combine_to_single_python_file_subpiece_end_1 |