<br>Greetings,<br><br>I am having trouble finding the best way to perform this operation. The data originally resides in two float arrays, either in two fields of the same data file or in two separate files. I have attempted two different methods.
<br><br><br>Method 1: create vector data, then reslice<br><br> data = vtk.vtkImageData()<br> data.SetDimensions(dims[0],dims[1], 1) <br> data.SetExtent(0, dims[0]-1, 0, dims[1]-1, 0, 0)<br> data.SetWholeExtent
(0, dims[0]-1, 0, dims[1]-1, 0, 0)<br> data.SetOrigin(0,0,0)<br> data.GetPointData().SetVectors(array)<br> data.GetPointData().SetActiveVectors('vectors')<br><br> # Remap the data<br> x_dim = [0,1,0]<br> y_dim = [1,0,0]
<br> z_dim = [0,0,1]<br> reslice = vtk.vtkImageReslice()<br> reslice.SetResliceAxesDirectionCosines(x_dim, y_dim, z_dim)<br> reslice.SetInput(data)<br> reslice.Update()<br><br>This results in a dataset with only one scalar field, however.
<br><br>Method 2: reslice, then create vector data<br><br>As a first experiment for this method, I tried simply composing vector data from existing fields in a VTK dataset...<br><br> mf = vtk.vtkMergeFields()<br> mf.SetInput
(data)<br> mf.SetOutputField('vectors', 'POINT_DATA')<br> mf.SetNumberOfComponents(2)<br> mf.Merge(0, 'uComponent', 0)<br> mf.Merge(1, 'vComponent', 0)<br> mf.Merge(2, 'vComponent', 0) <br> mf.Update()
<br> mf.GetOutput().GetPointData().GetArray('vectors').FillComponent(2,0.0)<br> mf.GetOutput().GetPointData().SetVectors(mf.GetOutput().GetPointData().GetArray('vectors'))<br> mf.GetOutput().GetPointData().SetActiveVectors('vectors')
<br><br>Somehow, I'm unable to get the new array 'vectors' to appear in the vectors section when I print mf.GetOutput()<br><br>So, I'm wondering... is there a better way to go about this? There's always the brute force way of iterating over the components after the reslice to create the vector array, but I'm hoping for a more efficient solution.
<br><br>- Ed<br>