[vtkusers] WarpScalar with an StructuredGrid and Scalar Values - How?
Bryn Lloyd
blloyd at vision.ee.ethz.ch
Thu Aug 6 02:54:01 EDT 2009
From the example/test (here C++):
http://public.kitware.com/cgi-bin/viewcvs.cgi/*checkout*/Graphics/Testing/Cxx/expCos.cxx?root=VTK&content-type=text/plain
// warp plane
vtkWarpScalar *warp = vtkWarpScalar::New();
warp->SetInput(xyGrid);
warp->XYPlaneOn();
warp->SetScaleFactor(0.5); // depends on your data
vtkDataSetMapper *map_xyGrid = vtkDataSetMapper::New();
map_xyGrid->SetInput(warp->GetOutput());
You should not have to do anything with vtkAlgorithm. vtkWarpScalar is a
algorithm, specifically a pointset algorithm. Since vtkStructuredGrid is
a vtkPointSet you can use vtkWarpScalar on it.
You could also play with this filter in paraview (www.paraview.org), in
order to see what it should/will look like if you set up the pipeline
correctly.
/Bryn
Simon Clift wrote:
> Hi folks,
>
> I'm new to VTK (but not visualization, used mostly OpenDX, AVS in the past)
> and I'm having a terrible time with a simple case that I think vtkWarpScalar
> should solve for me. I've been through the examples, but none of them seem to
> apply exactly to my case and I was wondering if the users list might have some
> insights, please.
>
> I have a vtkStructuredGrid with dimensions (N_x, N_y, 1 ) and the points are
> set, but the data is 2D and the z-axis is 0 on all points. I would like to
> visualize one of several vtkDoubleArray() values over the same grid with the
> values specifying the z-distance from the grid. The grid and the points are
> generated internally in the program and are not loaded from a file (they will
> eventually show up in a GUI).
>
> If I visualize this (for example in my Python code):
>
> self.xyGrid = vtk.vtkStructuredGrid()
> self.xyGrid.SetDimensions( gDim )
> self.xyGrid.SetInput( pts ) # pts is an N_x*N_y vtkPoints
> ...
> self.xyGrid.GetPointData().SetScalars( self.value_1 )
> self.map_xyGrid = vtk.vtkDataSetMapper()
> self.map_xyGrid.SetInput( self.xyGrid )
> ... # render stuff
>
> I get a flat structured grid on the display with no elevation. It has colours
> that make sense for the data, so I think it is correctly set up.
>
> However, I can't figure out how to feed the xyGrid to vtkWarpScalar to warp it
> using the scalar (or active scalar?). It seems to have to go via a
> vtkAlgorithm but when I try vtkDataObjectToDataSetFilter then feed this to
> vtkWarpScalar I get an empty data set. The input xyGrid lists (on print) a
> credible list of data and points, but the output from any of the filters I have
> tried is nothing.
>
> I'm wondering if something in my basic approach is off? Should I be using a
> vtkAlgorithm sub-class to create my structured grid, rather than creating it
> directly?
>
> Best regards
> -- Simon
>
--
-------------------------------------------------
Bryn Lloyd
Computer Vision Laboratory
ETH Zürich, Sternwartstrasse 7, ETF C110
CH - 8092 Zürich, Switzerland
Tel: +41 44 63 26668
Fax: +41 44 63 21199
-------------------------------------------------
More information about the vtkusers
mailing list