from vtk import *

testGrid = 'testGrid.vtk'
testPoly = vtkPolyData()
testPoly = vtkPolyData()
testPoly.Allocate( 100, 100 )

polyReader = vtkPolyDataReader()
polyReader.SetFileName(testGrid)
testPoly = polyReader.GetOutput()
testPoly.Update()
testPoly.SetSource(None)

polys = vtkCellArray()
polys = testPoly.GetPolys()
print polys.GetNumberOfCells()
# here we receive a wrong InsertLocation at the beginning of the vtkCellArray and not at the end where it should be
print 'InsertLocationPolys: ', polys.GetInsertLocation(4)
# The problem can be identified in the vtkPolyDataReader() where the method WritePointer is used

# the dummy below will demonstrate how the InsertLocation should be set.
array = polys.GetData()
dummy = vtkCellArray()
dummy.SetCells(polys.GetNumberOfCells(), array)
print 'InsertLocationDummy: ', dummy.GetInsertLocation(4)


