MCPcopy Create free account
hub / github.com/Kitware/VTK / volume

Function volume

Web/Python/vtkmodules/web/utils.py:183–211  ·  view source on GitHub ↗

Expect a vtkImageData and extract its setting for the dash_vtk.Volume state

(dataset)

Source from the content-addressed store, hash-verified

181
182
183def volume(dataset):
184 """Expect a vtkImageData and extract its setting for the dash_vtk.Volume state"""
185 if dataset is None or not dataset.IsA("vtkImageData"):
186 return None
187
188 state = {
189 "image": {
190 "dimensions": dataset.GetDimensions(),
191 "spacing": dataset.GetSpacing(),
192 "origin": dataset.GetOrigin(),
193 },
194 }
195
196 # Capture image orientation if any
197 if hasattr(dataset, "GetDirectionMatrix"):
198 matrix = dataset.GetDirectionMatrix()
199 js_mat = []
200 for j in range(3):
201 for i in range(3):
202 js_mat.append(matrix.GetElement(i, j))
203
204 state["image"]["direction"] = js_mat
205
206 scalars = dataset.GetPointData().GetScalars()
207 field = data_array(scalars, location="PointData")
208 if field:
209 state["field"] = field
210
211 return state

Callers

nothing calls this directly

Calls 9

data_arrayFunction · 0.85
IsAMethod · 0.80
rangeClass · 0.50
GetDimensionsMethod · 0.45
GetSpacingMethod · 0.45
GetOriginMethod · 0.45
appendMethod · 0.45
GetScalarsMethod · 0.45
GetPointDataMethod · 0.45

Tested by

no test coverage detected