consistent code

This commit is contained in:
Martin Diehl 2023-11-28 20:52:49 +01:00
parent 118247111b
commit 38c7e6a8e4
1 changed files with 10 additions and 12 deletions

View File

@ -558,20 +558,18 @@ class VTK:
"""
cell_data = self.vtk_data.GetCellData()
for a in range(cell_data.GetNumberOfArrays()):
if cell_data.GetArrayName(a) == label:
if label in [cell_data.GetArrayName(a) for a in range(cell_data.GetNumberOfArrays())]:
try:
return vtk_to_numpy(cell_data.GetArray(a))
return vtk_to_numpy(cell_data.GetArray(label))
except AttributeError:
vtk_array = cell_data.GetAbstractArray(a) # string array
vtk_array = cell_data.GetAbstractArray(label) # string array
point_data = self.vtk_data.GetPointData()
for a in range(point_data.GetNumberOfArrays()):
if point_data.GetArrayName(a) == label:
if label in [point_data.GetArrayName(a) for a in range(point_data.GetNumberOfArrays())]:
try:
return vtk_to_numpy(point_data.GetArray(a))
return vtk_to_numpy(point_data.GetArray(label))
except AttributeError:
vtk_array = point_data.GetAbstractArray(a) # string array
vtk_array = point_data.GetAbstractArray(label) # string array
try:
# string array