The following code loads a .vtk
file, does some processing, and exports the output as a .vtp
file:
# Read VTK
reader = vtkStructuredGridReader()
reader.SetFileName(filename + ".vtk")
# Extract surface
surface_filter = vtkDataSetSurfaceFilter()
surface_filter.SetInputConnection(reader.GetOutputPort())
clean_filter = vtkCleanPolyData()
clean_filter.SetInputConnection(surface_filter.GetOutputPort())
# Save output to a VTP file
writer = vtkXMLPolyDataWriter()
writer.SetFileName(filename + ".vtp")
writer.SetInputConnection(clean_filter.GetOutputPort())
writer.Write()
While this code works perfectly, I have to run this for about 50 VTK files, so the conversion can take a while. Is there a way to somehow accelerate this by running this for multiple files in parallel? Any other ideas?