Hi all,
I would like to write the points and connectivity information from an unstructuredgrid to a file using a python plugin. I’m wondering if I’m doing the right thing. My data comes from a multiblock and I first get the block containing the unstructuredgrid and put it in ugrid.
To access the points and connectivity I basically do this below, and I’m wondering if this is really the best way to do it.
# this gets the connectivity
print("### get the connectivity ###")
celldata = ugrid.GetCells()
pts = vtk.vtkIdList()
for i in range(celldata.GetNumberOfCells()):
celldata.GetCellAtId(i,pts)
print("number of ids = ",pts.GetNumberOfIds())
for j in range(pts.GetNumberOfIds()):
print(pts.GetId(j))
print("### get the points ###")
pntdata = ugrid.GetPoints()
for p in range(pntdata.GetNumberOfPoints()):
print(pntdata.GetPoint(p))
My goal is to write data to a file in the format (celltype, listofconnectivities, id):
NELEM= 293
9 0 6 66 22 0
5 217 231 252 1
etc.
NPOIN= 257
0.0 0.0 0.0
0.5 0.0 0.0
etc.