[vtkusers] Reslicing vector data

Ed B gameredb at gmail.com
Mon Feb 13 10:19:37 EST 2006


Greetings,

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.


Method 1: create vector data, then reslice

    data = vtk.vtkImageData()
    data.SetDimensions(dims[0],dims[1], 1)
    data.SetExtent(0, dims[0]-1, 0, dims[1]-1, 0, 0)
    data.SetWholeExtent(0, dims[0]-1, 0, dims[1]-1, 0, 0)
    data.SetOrigin(0,0,0)
    data.GetPointData().SetVectors(array)
    data.GetPointData().SetActiveVectors('vectors')

    # Remap the data
    x_dim = [0,1,0]
    y_dim = [1,0,0]
    z_dim = [0,0,1]
    reslice = vtk.vtkImageReslice()
    reslice.SetResliceAxesDirectionCosines(x_dim, y_dim, z_dim)
    reslice.SetInput(data)
    reslice.Update()

This results in a dataset with only one scalar field, however.

Method 2: reslice, then create vector data

As a first experiment for this method, I tried simply composing vector data
from existing fields in a VTK dataset...

    mf = vtk.vtkMergeFields()
    mf.SetInput(data)
    mf.SetOutputField('vectors', 'POINT_DATA')
    mf.SetNumberOfComponents(2)
    mf.Merge(0, 'uComponent', 0)
    mf.Merge(1, 'vComponent', 0)
    mf.Merge(2, 'vComponent', 0)
    mf.Update()
    mf.GetOutput().GetPointData().GetArray('vectors').FillComponent(2,0.0)
    mf.GetOutput().GetPointData().SetVectors(mf.GetOutput
().GetPointData().GetArray('vectors'))
    mf.GetOutput().GetPointData().SetActiveVectors('vectors')

Somehow, I'm unable to get the new array 'vectors' to appear in the vectors
section when I print mf.GetOutput()

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.

- Ed
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060213/e1da7d57/attachment.htm>


More information about the vtkusers mailing list