-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvtkToNumpy.py
More file actions
30 lines (27 loc) · 888 Bytes
/
Copy pathvtkToNumpy.py
File metadata and controls
30 lines (27 loc) · 888 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# -*- coding: utf-8 -*-
"""
Created on Wed Nov 28 22:55:20 2018
@author: c3216945
"""
import numpy as np
#from vtk.util import numpy_support as VN
import vtk
from vtk.util.numpy_support import vtk_to_numpy
#as_numpy = numpy_support.vtk_to_numpy(vtk_points.GetData())
reader = vtk.vtkPolyDataReader()
#reader = vtk.vtkGenericDataObjectReader()
reader.SetFileName('gp2007000.vtk')
reader.ReadAllVectorsOn()
reader.ReadAllScalarsOn()
reader.Update()
vtk_out = reader.GetOutput()
scalar_names = [reader.GetScalarsNameInFile(i) for i in range(0, reader.GetNumberOfScalarsInFile())]
#p = np.asarray(vtk_out.GetCellData().GetArray('pressure'))
points = vtk_out.GetPoints()
array = points.GetData()
numpy_nodes = vtk_to_numpy(array)
pointData = vtk_out.GetPointData()
scalarData = pointData.GetArray('pressure')
p = vtk_to_numpy(scalarData)
meanp=np.mean(p)
#p = pointData.GetArray('pressure')