Transform Filter Applied to Unstructured Grid

Hello, I am dealing with some issues related to applying a vtkTransformFilter() to a vtkUnstructuredGrid(). Namely, the unstructured grid does not have the same items before and after the application of the filter.

Here is an example. A transform filter with a translation of (1,0,0) is applied to an unstructured grid. We print, using python’s print() before and after the transformation. We can then compare which items were modified. Note, unstructured_grid is of type <class ‘vtkmodules.vtkCommonDataModel.vtkUnstructuredGrid’>.

    transform = vtk.vtkTransform()
    transform.Translate(1,0,0)
    transform_filter = vtk.vtkTransformFilter()
    transform_filter.SetTransformAllInputVectors(True)
    transform_filter.SetInputData(unstructured_grid)
    transform_filter.SetTransform(transform)
    transform_filter.Update()
    print(unstructured_grid)
    print(transform_filter.GetOutput())

The output of print(unstructured_grid) is:

vtkUnstructuredGrid (0x2637fb0)
Debug: Off
Modified Time: 7023
Reference Count: 4
Registered Events: (none)
Information: 0x2638270
Data Released: False
Global Release Data: Off
UpdateTime: 8685
Field Data:
Debug: Off
Modified Time: 297
Reference Count: 1
Registered Events: (none)
Number Of Arrays: 0
Number Of Components: 0
Number Of Tuples: 0
Number Of Points: 32029279
Number Of Cells: 29723293
Cell Data:
Debug: Off
Modified Time: 7023
Reference Count: 1
Registered Events:
Registered Observers:
vtkObserver (0x2638710)
Event: 33
EventName: ModifiedEvent
Command: 0x2638430
Priority: 0
Tag: 1
Number Of Arrays: 31
Array 0 name = aeroForce
Array 1 name = aeroForceMean
Array 2 name = Cg
Array 3 name = CgMean
Array 4 name = Co
Array 5 name = CoMean
Array 6 name = Cp
Array 7 name = CpMean
Array 8 name = dampedUMag
Array 9 name = desZones
Array 10 name = helicityMean
Array 11 name = nuSgs
Array 12 name = nut
Array 13 name = nuTilda
Array 14 name = nuTilda_des
Array 15 name = nuTilda_rans
Array 16 name = nuTildaMean
Array 17 name = p
Array 18 name = pMean
Array 19 name = pPrime2Mean
Array 20 name = tauw
Array 21 name = tauwMean
Array 22 name = U
Array 23 name = UMean
Array 24 name = Unwv
Array 25 name = UnwvMean
Array 26 name = UPrime2Mean
Array 27 name = vorticity
Array 28 name = vorticityMean
Array 29 name = yPlus
Array 30 name = yPlusMean
Number Of Components: 56
Number Of Tuples: 29723293
Copy Tuple Flags: ( 1 1 1 1 1 0 1 1 1 1 1 )
Interpolate Flags: ( 1 1 1 1 1 0 0 1 1 1 1 )
Pass Through Flags: ( 1 1 1 1 1 1 1 1 1 1 1 )
Scalars:
Debug: Off
Modified Time: 2821
Reference Count: 2
Registered Events: (none)
Name: Cg
Data type: float
Size: 29723293
MaxId: 29723292
NumberOfComponents: 1
Information: 0
Name: Cg
Number Of Components: 1
Number Of Tuples: 29723293
Size: 29723293
MaxId: 29723292
LookupTable: (none)
Vectors:
Debug: Off
Modified Time: 2458
Reference Count: 1
Registered Events: (none)
Name: aeroForce
Data type: float
Size: 89169879
MaxId: 89169878
NumberOfComponents: 3
Information: 0
Name: aeroForce
Number Of Components: 3
Number Of Tuples: 29723293
Size: 89169879
MaxId: 89169878
LookupTable: (none)
Normals: (none)
TCoords: (none)
Tensors: (none)
GlobalIds: (none)
PedigreeIds: (none)
EdgeFlag: (none)
Tangents: (none)
RationalWeights: (none)
HigherOrderDegrees: (none)
Point Data:
Debug: Off
Modified Time: 299
Reference Count: 1
Registered Events:
Registered Observers:
vtkObserver (0x26b7300)
Event: 33
EventName: ModifiedEvent
Command: 0x2638430
Priority: 0
Tag: 1
Number Of Arrays: 0
Number Of Components: 0
Number Of Tuples: 0
Copy Tuple Flags: ( 1 1 1 1 1 0 1 1 1 1 1 )
Interpolate Flags: ( 1 1 1 1 1 0 0 1 1 1 1 )
Pass Through Flags: ( 1 1 1 1 1 1 1 1 1 1 1 )
Scalars: (none)
Vectors: (none)
Normals: (none)
TCoords: (none)
Tensors: (none)
GlobalIds: (none)
PedigreeIds: (none)
EdgeFlag: (none)
Tangents: (none)
RationalWeights: (none)
HigherOrderDegrees: (none)
Bounds:
Xmin,Xmax: (-30.0053, 29.9947)
Ymin,Ymax: (-25, 25)
Zmin,Zmax: (-8.92128e-05, 30)
Compute Time: 7339
Editable: false
Number Of Points: 32029279
Point Coordinates: 0x26b7fd0
PointLocator: 0
CellLocator: 0
Number Of Pieces: 1
Piece: 0
Ghost Level: 0

Output of transform_filter.GetOutput()
vtkUnstructuredGrid (0x26b7830)
Debug: Off
Modified Time: 8840
Reference Count: 2
Registered Events: (none)
Information: 0x26117f0
Data Released: False
Global Release Data: Off
UpdateTime: 8842
Field Data:
Debug: Off
Modified Time: 8699
Reference Count: 1
Registered Events: (none)
Number Of Arrays: 0
Number Of Components: 0
Number Of Tuples: 0
Number Of Points: 32029279
Number Of Cells: 29723293
Cell Data:
Debug: Off
Modified Time: 8840
Reference Count: 1
Registered Events:
Registered Observers:
vtkObserver (0x39b1df0)
Event: 33
EventName: ModifiedEvent
Command: 0x26b7330
Priority: 0
Tag: 1
Number Of Arrays: 31
Array 0 name = aeroForceMean
Array 1 name = tauw
Array 2 name = tauwMean
Array 3 name = U
Array 4 name = UMean
Array 5 name = Unwv
Array 6 name = UnwvMean
Array 7 name = vorticity
Array 8 name = vorticityMean
Array 9 name = aeroForce
Array 10 name = Cg
Array 11 name = CgMean
Array 12 name = Co
Array 13 name = CoMean
Array 14 name = Cp
Array 15 name = CpMean
Array 16 name = dampedUMag
Array 17 name = desZones
Array 18 name = helicityMean
Array 19 name = nuSgs
Array 20 name = nut
Array 21 name = nuTilda
Array 22 name = nuTilda_des
Array 23 name = nuTilda_rans
Array 24 name = nuTildaMean
Array 25 name = p
Array 26 name = pMean
Array 27 name = pPrime2Mean
Array 28 name = UPrime2Mean
Array 29 name = yPlus
Array 30 name = yPlusMean
Number Of Components: 56
Number Of Tuples: 29723293
Copy Tuple Flags: ( 1 0 1 1 1 0 1 1 1 1 1 )
Interpolate Flags: ( 1 0 1 1 1 0 0 1 1 1 1 )
Pass Through Flags: ( 1 0 1 1 1 1 1 1 1 1 1 )
Scalars: (none)
Vectors:
Debug: Off
Modified Time: 8727
Reference Count: 1
Registered Events: (none)
Name: aeroForce
Data type: float
Size: 89169879
MaxId: 89169878
NumberOfComponents: 3
Information: 0
Name: aeroForce
Number Of Components: 3
Number Of Tuples: 29723293
Size: 89169879
MaxId: 89169878
LookupTable: (none)
Normals: (none)
TCoords: (none)
Tensors: (none)
GlobalIds: (none)
PedigreeIds: (none)
EdgeFlag: (none)
Tangents: (none)
RationalWeights: (none)
HigherOrderDegrees: (none)
Point Data:
Debug: Off
Modified Time: 8709
Reference Count: 1
Registered Events:
Registered Observers:
vtkObserver (0x39b1c60)
Event: 33
EventName: ModifiedEvent
Command: 0x26b7330
Priority: 0
Tag: 1
Number Of Arrays: 0
Number Of Components: 0
Number Of Tuples: 0
Copy Tuple Flags: ( 1 1 1 1 1 0 1 1 1 1 1 )
Interpolate Flags: ( 1 1 1 1 1 0 0 1 1 1 1 )
Pass Through Flags: ( 1 1 1 1 1 1 1 1 1 1 1 )
Scalars: (none)
Vectors: (none)
Normals: (none)
TCoords: (none)
Tensors: (none)
GlobalIds: (none)
PedigreeIds: (none)
EdgeFlag: (none)
Tangents: (none)
RationalWeights: (none)
HigherOrderDegrees: (none)
Bounds:
Xmin,Xmax: (-29.0053, 30.9947)
Ymin,Ymax: (-25, 25)
Zmin,Zmax: (-8.92128e-05, 30)
Compute Time: 8855
Editable: false
Number Of Points: 32029279
Point Coordinates: 0x7d87ff0
PointLocator: 0
CellLocator: 0
Number Of Pieces: 1
Piece: 0
Ghost Level: 0

Let me summarise the differences:

  • Reference Count: 2 or 4 (before or after)
  • The array X name fields have changed order into alphabetical afterwards
  • Copy Tuple/ Interpolate/ Pass Through Flags have changed
  • Scalars has become (none) (I assume from the SetTransformAllInputVectors(True) flag)
  • Xmin,Xmax has correctly been translated by 1.

Downstream tasks which take the unstructured_grid then perform incorrectly. The conclusion I am reaching is that vtkTransformFilter() does not take any arbitrary vtkUnstructuredGrid() and transforms all non scalar values correctly while leaving everything else the same. Note, the same behavior is seen when using vtkTransform().RotateWXYZ() (which I also need to use). Using vtkRotationFilter() gives even worse results.

Any help would be greatly appreciated. Thank you.

1 Like

Input and output of a filter are expected to be different. If you think any of the differences are not reasonable then tell a bit more about your use case (what data you work with, why do you transform it, and how do you use the transformed data) and why the current behavior is not optimal for you.

Hey thanks for the response. It is a little complicated to answer your question as there are many different things that are happening before the final output.

I have an alternative question that I think you might be able to answer: how does one inspect all of the elements that compose an unstructured grid object in vtk?

Also what are Copy/Interpolate/Pass Through Flags? … why are they of length 11? I am having a hard time finding documentation that explains what they are.

Then, since we cannot guess what you might be interested in doing and why that does not match what most other VTK users usually do, you will need to figure out solutions on your own.

PrintSelf method (that’s the one that is used when you call print(obj)) is the method that displays a good overview. You can dig deeper with Get... functions (get points, get point data, get arrays from point data, etc.) and access any data you are interested in.

If you are interested in any undocumented details then you can have a look at the source code. In this case, if you search for Copy Tuple Flags in VTK source code then you will find the answer here:

1 Like