Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions src/e3sm_quickview/plugins/eam_projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,16 @@ def timed(label):
yield


def _cell_types_array(grid):
"""Per-cell type array, across VTK versions.

VTK 9.7 dropped `GetCellTypesArray()`; `GetCellTypes()` now returns that
array, where it used to fill a vtkCellTypes passed in by the caller.
"""
getter = getattr(grid, "GetCellTypesArray", None)
return getter() if getter is not None else grid.GetCellTypes()


def ProcessPoint(point, radius):
# theta = math.radians(point[0] - 180.)
# phi = math.radians(point[1])
Expand Down Expand Up @@ -256,10 +266,16 @@ def RequestData(self, request, inInfo, outInfo):
else:
outData.DeepCopy(inData)

inPoints = inData.points
inPoints = numpy_support.vtk_to_numpy(inData.GetPoints().GetData())
pRadius = (self.radius + 1) if self.isData else self.radius
outPoints = np.array(list(map(lambda x: ProcessPoint(x, pRadius), inPoints)))
outData.points = outPoints
vtk_coords = vtkPoints()
vtk_coords.SetData(
numpy_support.numpy_to_vtk(
outPoints, deep=True, array_type=vtkConstants.VTK_FLOAT
)
)
outData.SetPoints(vtk_coords)

return 1

Expand Down Expand Up @@ -443,7 +459,9 @@ def RequestData(self, request, inInfo, outInfo):
out_points_vtk = vtkPoints()
out_points_vtk.DeepCopy(outData.GetPoints())
outData.SetPoints(out_points_vtk)
out_points_np = outData.points
out_points_np = numpy_support.vtk_to_numpy(
outData.GetPoints().GetData()
)

flat = out_points_np.flatten()
x = flat[0::3] - 180.0 if self.translate else flat[0::3]
Expand Down Expand Up @@ -696,7 +714,7 @@ def RequestData(self, request, inInfo, outInfo):
cells = vtkCellArray()
cell_types = vtkUnsignedCharArray()
cells.DeepCopy(outData.GetCells())
cell_types.DeepCopy(outData.GetCellTypesArray())
cell_types.DeepCopy(_cell_types_array(outData))
outData.SetCells(cell_types, cells)

# Crop against absolute lon/lat ranges, in the same
Expand Down
4 changes: 2 additions & 2 deletions src/e3sm_quickview/view_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

from paraview.modules.vtkPVVTKExtensionsInteractionStyle import (
vtkPVInteractorStyle,
vtkPVTrackballPan,
vtkPVTrackballZoom,
vtkTrackballPan,
)
from trame.app import TrameComponent
from trame.decorators import controller
Expand Down Expand Up @@ -84,7 +84,7 @@ def __init__(self, server, source):
)
)
self._style.AddManipulator(
vtkTrackballPan(
vtkPVTrackballPan(
button=1,
shift=0,
control=0,
Expand Down