I'm working to convert the data of a line in a csv file (comma separated file) to a .vtp file.
What I have done is to store the points in the .csv file into a vtkPolyData type variable. The vtkPolyData can be displayed with the render window correctly.
Then I tried to use vtkPolyDataWriter to write the vtkPolyData into a vtp file. But It did not work
writer = vtk.vtkPolyDataWriter()
writer.SetInput(vtkpoint.getVtkPolyData)
## vtkpoint is an instance of a class which I wrote to store the csv data,
## and .getVtkPolyData returns the vtkPolyData typed data
writer.SetFileName('TestCenterline.vtp')
writer.SetFileTypeToBinary()
writer.Write()
This vtp file is not readable.
If you want to inspect the file by reading its content, use
writer->SetDataModeToAscii();
instead if binary.
Also vtkpoint.getVtkPolyData looks a bit suspect. Maybe it's just bad naming or bad copy/paste, but are you sure that that is the actual polydata and not just a method? Are you able to get the correct value by calling vtkpoint.getVtkPolyData.GetNumberOfPoints()?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With