I want to get cell types ('Hexa','tetra',etc) and node ids tuples (or arrays) for each cell using library vtk in python in vtkUnstructuredGrid instance. I dont understand how to do this operation. Earlier I had used meshio library and it was very easy operation. now But I need use library vtk.
import os
try:
from paraview.simple import (
OpenDataFile,
servermanager,
FrequencyAnalysis)
from paraview import vtk
from paraview.vtk.util.numpy_support import numpy_to_vtk, vtk_to_numpy
except ImportError as error:
print('import paraview error')
BASE_DIR = os.getcwd()
JOIN = os.path.join
file_name = 'for_meshio_library.pvd'
reader = OpenDataFile(JOIN(BASE_DIR,file_name))
dataReader = servermanager.Fetch(reader) # VtustrictureGrid instance in PARAVIEW
pointData = dataReader.GetPointData()
#cellData = dataReader.GetCellData()
point_data = dataReader.GetPointData()
node_ids = point_data.GetArray('Node ID')
node_ids_to_numpy_array = vtk_to_numpy(node_ids)
nodes_count = len(node_ids_to_numpy_array)
points = dataReader.GetPoints()
for index in range(nodes_count):
print(points.GetPoint(index))
cells = dataReader.GetCells() # ?????????????????????????????????????????????????