I seem to have an issue with vtkStructuredGridAppend. I am not sure if I am doing something wrong. I have two small structured grids. Each contains scalar data and the scalar data has the same names in both files. I want to append these two grids. When I run the code below, there are no warnings or errors, but the result only includes the last grid added, rather than the appended grid.
I am using Python 3.7.5 with version 8.2.0 of the vtk module.
If I use vtkAppendFilter, the append works, but it results in an unstructured grid.
import vtk file1='region_1/region_1.vtk' file2='region_2/region_2.vtk' # create an append filter to hold data append = vtk.vtkStructuredGridAppend() rdr = vtk.vtkStructuredGridReader() rdr.ReadAllScalarsOn() rdr.SetFileName(file1) rdr.Update() rdr2 = vtk.vtkStructuredGridReader() rdr2.ReadAllScalarsOn() rdr2.SetFileName(file2) rdr2.Update() append.AddInputData(rdr.GetOutput()) append.AddInputData(rdr2.GetOutput()) append.Update() # write out appended data writer = vtk.vtkStructuredGridWriter() writer.SetFileName("merged_data.vtk") writer.SetInputData(append.GetOutput()) writer.Update() writer.Write()