[vtkusers] How to transform an unstructured grid
Marco Nawijn
nawijn at gmail.com
Wed Sep 7 16:38:38 EDT 2011
Dear David,
Thanks. It now works like a charm!
One additional question though about performance. As I understand it
now, the GetOutput() call returns a "reference" to a new grid object
with the transformation applied. Does this mean that I now have to
copies of cells/points in memory? If so, is there a way to avoid this.
I am not too worried by performance yet, but I don't want to ignore it
either.
Marco
On Wed, Sep 7, 2011 at 10:27 PM, David Doria <daviddoria at gmail.com> wrote:
> 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