User:Tohline/vtk/Examples/XMLRectilinearGrid

(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)

Example Input Files & VisTrails Pipelines

Here we present two examples of input data files that we have successfully used to generate useful interactive renderings within VisTrails. The files illustrate the (structured) RectilinearGrid file type within the context of VTK's XML File Format.

In the first "Warped Quilt" example, which uses 5 x 5 grid cells (6 x 6 grid points), we present the full ascii dataset, two resulting rendered images, and a screen shot of the VisTrails pipeline that was used to generate the image. Note that the image captioned "Point Data" was generated, by default, while the image captioned "Cell Data" was generated after activating the SetScalarModeToUseCellData method within the vtkDataSetMapper module. Note, further, that the vertical "warping" of the configuration can be excluded — with the result being the rendering of a flat plane — by either:

• Removing the vtkWarpScalar module from the VisTrails pipeline and connecting the vtkXMLRectilinearGridReader module directly to the vtkDataSetMapper module; or
• Changing the floating-point value associated with the SetScaleFactor method inside the vtkWarpScalar method from 2.0 to 0.0.

Because the second, "Mexican Hat," example uses 49 x 49 grid cells (50 x 50 grid points), it made more sense to simply provide a pointer to the website where the input data file can be accessed. In accordance, an HTTPFile module was inserted into the VisTrails pipeline, but otherwise the pipeline is identical to the one used in the "Warped Quilt" example.

A list of other example input data files is provided near the end of our accompanying "Simple Cube" tutorial.

Important Note: By trial and error, I have discovered that the numerical values specified for "WholeExtent" and "Extent" inside the RectilinearGrid and Piece XML tags, respectively, must be provided in integer format!

XML (RectilinearGrid) Warped Quilt Example

<?xml version="1.0"?>
<VTKFile type="RectilinearGrid" version="0.1" byte_order="LittleEndian">
<RectilinearGrid WholeExtent="0 5 0 5 0 0">
<Piece Extent="0 5 0 5 0 0">
<CellData Scalars="cell_scalars">
<DataArray type="Float32" Name="cell_scalars" format="ascii">
0.2 0.2 0.2 0.2 0.2
0.2 0.4 0.6 0.4 0.2
0.2 0.6 0.8 0.6 0.2
0.2 0.4 0.6 0.4 0.2
0.2 0.2 0.2 0.2 0.2
</DataArray>
</CellData>
<PointData Scalars="colorful">
<DataArray type="Float32" Name="colorful" format="ascii">
0.2 0.2 0.2 0.2 0.2 0.2
0.2 0.4 0.6 0.6 0.4 0.2
0.2 0.6 0.8 0.8 0.6 0.2
0.2 0.6 0.8 0.8 0.6 0.2
0.2 0.4 0.6 0.6 0.4 0.2
0.2 0.2 0.2 0.2 0.2 0.2
</DataArray>
</PointData>
<Coordinates>
<DataArray type="Float32" format="ascii" RangeMin="0" RangeMax="5">
0.0 1.0 2.0 3.0 4.0 5.0
</DataArray>
<DataArray type="Float32" format="ascii" RangeMin="0" RangeMax="5">
0.0 1.0 2.0 3.0 4.0 5.0
</DataArray>
<DataArray type="Float32" format="ascii">
0.0
</DataArray>
</Coordinates>
</Piece>
</RectilinearGrid>
</VTKFile>


 VisTrails Pipeline Warp (Point Data) Image Warp (Cell Data) Image

XML (RectilinearGrid) Mexican Hat Example

(A) Medium Resolution Grid and No Specified Normals

 The relevant XML-formatted "Mexican Hat" input data file can be accessed at the following URL: Note that this "mexicanHat.vtr" ascii file was generated via a sequence of "write" statements inside a Fortran90 code. This was done to demonstrate that even Fortran programmers can generate data files that are properly formatted for input into VisTrails. VisTrails Pipeline Mexican Hat Image

(B) Low Resolution Grid with Normals Specified

The input data file provided below can also be used to generate a Mexican Hat, but at a lower grid resolution — it uses 9 x 9 grid cells rather than 49 x 49 grid cells, as in the "Case A" Mexican Hat example. We present this example input file to illustrate how Normals to the grid cells (Name = "magnify") and "Normals" to the grid points (Name = "direction") can be explicitly specified. (Read the accompanying discussion if you don't understand what it means to define unit vector "Normals.")

Because the (unwarped) rectilinear grid that is defined by this example is confined to the x-y plane — that is, it has no z extent — one would assume, by default, that the unit vectors normal to the surface would point in the (plus or minus) z-direction, that is, that the normals would be specified by the vector $~(x,y,z) = (0,0,\pm 1)$. For purposes of illustration, this example input data file purposely defines a vector normal that is contrary to the default: All of the cells and points are assigned vector normals with $~(x,y,z) = (1,0,0)$, that is, all of the unit vector normals point in the plus-x direction.

<?xml version="1.0"?>
<VTKFile type="RectilinearGrid" version="0.1" byte_order="LittleEndian">
<RectilinearGrid WholeExtent="  0  9  0  9  0  0">
<Piece Extent="  0  9  0  9  0  0">
<CellData Scalars="cell_scalars" Normals="magnify">
<DataArray type="Float32" Name="cell_scalars" format="ascii">
1.00000  0.88388  0.79057  0.72887  0.70711  0.72887  0.79057  0.88388  1.00000
0.88388  0.75000  0.63738  0.55902  0.53033  0.55902  0.63738  0.75000  0.88388
0.79057  0.63738  0.50000  0.39528  0.35355  0.39528  0.50000  0.63738  0.79057
0.72887  0.55902  0.39528  0.25000  0.17678  0.25000  0.39528  0.55902  0.72887
0.70711  0.53033  0.35355  0.17678  0.00000  0.17678  0.35355  0.53033  0.70711
0.72887  0.55902  0.39528  0.25000  0.17678  0.25000  0.39528  0.55902  0.72887
0.79057  0.63738  0.50000  0.39528  0.35355  0.39528  0.50000  0.63738  0.79057
0.88388  0.75000  0.63738  0.55902  0.53033  0.55902  0.63738  0.75000  0.88388
1.00000  0.88388  0.79057  0.72887  0.70711  0.72887  0.79057  0.88388  1.00000
</DataArray>
<DataArray type="Float32" Name="magnify" NumberOfComponents="3" format="ascii">
1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0
1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0
1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0
1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0
1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0
1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0
1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0
1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0
1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0
</DataArray>
</CellData>
<PointData Scalars="colorful" Normals="direction">
<DataArray type="Float32" Name="colorful" format="ascii">
0.00674  0.04358  0.14832  0.29999  0.40890  0.40890  0.29999  0.14832  0.04358  0.00674
0.04358  0.21369  0.53872  0.82410  0.94014  0.94014  0.82410  0.53872  0.21369  0.04358
0.14832  0.53872  0.94014  0.96553  0.82075  0.82075  0.96553  0.94014  0.53872  0.14832
0.29999  0.82410  0.96553  0.57375  0.28209  0.28209  0.57375  0.96553  0.82410  0.29999
0.40890  0.94014  0.82075  0.28209  0.04857  0.04857  0.28209  0.82075  0.94014  0.40890
0.40890  0.94014  0.82075  0.28209  0.04857  0.04857  0.28209  0.82075  0.94014  0.40890
0.29999  0.82410  0.96553  0.57375  0.28209  0.28209  0.57375  0.96553  0.82410  0.29999
0.14832  0.53872  0.94014  0.96553  0.82075  0.82075  0.96553  0.94014  0.53872  0.14832
0.04358  0.21369  0.53872  0.82410  0.94014  0.94014  0.82410  0.53872  0.21369  0.04358
0.00674  0.04358  0.14832  0.29999  0.40890  0.40890  0.29999  0.14832  0.04358  0.00674
</DataArray>
<DataArray type="Float32" Name="direction" NumberOfComponents="3" format="ascii">
1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0
1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0
1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0
1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0
1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0
1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0
1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0
1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0
1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0
1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0  1 0 0
</DataArray>
</PointData>
<Coordinates>
<DataArray type="Float32" format="ascii">
-0.50000 -0.38889 -0.27778 -0.16667 -0.05556  0.05556  0.16667  0.27778  0.38889  0.50000
</DataArray>
<DataArray type="Float32" format="ascii">
-0.50000 -0.38889 -0.27778 -0.16667 -0.05556  0.05556  0.16667  0.27778  0.38889  0.50000
</DataArray>
<DataArray type="Float32" format="ascii">
0.00000
</DataArray>
</Coordinates>
</Piece>
</RectilinearGrid>
</VTKFile>


When the above-displayed VisTrails pipeline is executed using this low-resolution input data file, you can also begin to appreciate how the warping that is introduced by the vtkWarpScalar module responds to user-specified Normals. VisTrail's official, rather cryptic documentation of the vtkWarpScalar module is provided in the following table.

VisTrails Documentation of the vtkWarpScalar Module

vtkWarpScalar - deform geometry with scalar data

Superclass: vtkPointSetAlgorithm

vtkWarpScalar is a filter that modifies point coordinates by moving
points along point normals by the scalar amount times the scale
factor. Useful for creating carpet or x-y-z plots.

If normals are not present in data, the Normal instance variable will
be used as the direction along which to warp the geometry. If normals
are present but you would like to use the Normal instance variable,
set the UseNormal boolean to true.

If XYPlane boolean is set true, then the z-value is considered to be
a scalar value (still scaled by scale factor), and the displacement
is along the z-axis. If scalars are also present, these are copied
through and can be used to color the surface.

Note that the filter passes both its point data and cell data to its
output, except for normals, since these are distorted by the warping.


To clarify further, here is what results from the execution when the SetScaleFactor method inside the vtkWarpScalar module is set to a nonzero value (we suggest setting SetScaleFactor = 0.2):

• If all of the other methods retain their default settings, VisTrails will render a multi-colored plane that exhibits no vertical warping. However, the plane is colored in an asymmetric fashion, showing that the vtkWarpScalar module "stretched" the Mexican Hat in the plus-x direction. This is how the method responds to our user-specified Normals!
• If the UseNormalOn method inside the vtkWarpScalar module is activated, and the VisTrails pipeline is re-executed, the rendered image is a properly warped Mexican hat with symmetric coloring. This is presumably because, in this instance, the vtkWarpScalar module ignores the user-specified normals and warps the configuration in its default (z) direction.