[vtkusers] How to transform an unstructured grid

David Doria daviddoria at gmail.com
Wed Sep 7 16:27:53 EDT 2011


On Wed, Sep 7, 2011 at 4:24 PM, Marco Nawijn <nawijn at gmail.com> wrote:
> Dear All,
>
> I have been struggling a while now on how to transform (e.g. translate
> in X-direction) a complete unstructured grid. I have the following (in
> Python):
>
>        # Create the transformation
>        t = vtkTransform()
>        t.Translate(-dx, -dy, 0.0)
>
>        # Apply the transformation to the grid
>        tf = vtkTransformFilter()
>        tf.SetInput(grid)    # Grid is of type vtkUnstructuredGrid()
>        tf.SetTransform(t)
>        tf.Update()
>
>        grid.Modified()
>
> The code runs fine, but  when looking at output of grid.GetBounds()
> nothing has happened. Obviously I don't fully understand how
> transformations work in VTK. What I see consistently in the
> documentation is (from one of the examples):
>    tf = vtkTransformFilter()
>    tf.SetInputConnection(<some source object>.GetOutputPort())
>
> However an UnstructuredGrid object does not have the GetOutputPort() method.
>
> Thanks in advance for any help.
>
> Marco

Hi Marco,

Filters in VTK do not modify the input directly, they produce a new
object as output. You should look at tf->GetOutput()->GetBounds() to
see the new bounds. The GetOutputPort() is just to pass the output of
a filter on to the input of another filter. You tried calling it on a
data set instead of a filter, hence it did not work.

David



More information about the vtkusers mailing list