MCPcopy Create free account
hub / github.com/Kitware/ParaView / writeArray

Method writeArray

Web/Python/paraview/web/data_writer.py:120–199  ·  view source on GitHub ↗
(self, path, source, name, component=0)

Source from the content-addressed store, hash-verified

118 simple.Hide(source, self.view)
119
120 def writeArray(self, path, source, name, component=0):
121 rep = simple.Show(source, self.view)
122 rep.Representation = "Surface"
123 rep.DiffuseColor = [1, 1, 1]
124
125 dataRange = [0.0, 1.0]
126 fieldToColorBy = ["POINTS", name]
127
128 self.view.ArrayNameToDraw = name
129 self.view.ArrayComponentToDraw = component
130
131 pdi = source.GetPointDataInformation()
132 cdi = source.GetCellDataInformation()
133
134 if pdi.GetArray(name):
135 self.view.DrawCells = 0
136 dataRange = pdi.GetArray(name).GetRange(component)
137 fieldToColorBy[0] = "POINTS"
138 elif cdi.GetArray(name):
139 self.view.DrawCells = 1
140 dataRange = cdi.GetArray(name).GetRange(component)
141 fieldToColorBy[0] = "CELLS"
142 else:
143 print("No array with that name", name)
144 return
145
146 realRange = dataRange
147 if dataRange[0] == dataRange[1]:
148 dataRange = [dataRange[0] - 0.1, dataRange[1] + 0.1]
149
150 simple.ColorBy(rep, fieldToColorBy)
151
152 # Grab data
153 tmpFileName = path + "__.png"
154 self.view.ScalarRange = dataRange
155 self.view.LockBounds = 1
156 self.view.StartCaptureValues()
157 simple.SaveScreenshot(tmpFileName, self.view)
158 self.view.StopCaptureValues()
159 self.view.LockBounds = 0
160
161 if self.canWrite:
162 # Convert data
163 self.reader.SetFileName(tmpFileName)
164 self.reader.Update()
165
166 rgbArray = self.reader.GetOutput().GetPointData().GetArray(0)
167 arraySize = rgbArray.GetNumberOfTuples()
168
169 rawArray = vtkFloatArray()
170 rawArray.SetNumberOfTuples(arraySize)
171
172 minValue = 10000.0
173 maxValue = -100000.0
174 delta = (dataRange[1] - dataRange[0]) / 16777215.0 # 2^24 - 1 => 16,777,215
175 for idx in range(arraySize):
176 rgb = rgbArray.GetTuple3(idx)
177 if rgb[0] != 0 or rgb[1] != 0 or rgb[2] != 0:

Callers 1

writeLayerDataMethod · 0.80

Calls 15

minFunction · 0.85
maxFunction · 0.85
openFunction · 0.85
ColorByMethod · 0.80
SaveScreenshotMethod · 0.80
GetOutputMethod · 0.80
writeMethod · 0.80
vtkFloatArrayClass · 0.50
ShowMethod · 0.45
GetArrayMethod · 0.45

Tested by

no test coverage detected