[vtkusers] PLEASE HELP: creating vtkImage programmatically

Prabhu Ramachandran prabhu at aero.iitm.ernet.in
Thu Mar 27 14:39:03 EST 2003


>>>>> "RB" == Richard Bridge <Richard.Bridge at tessella.com> writes:

    RB> Is there an example of, or can anyone tell me how to:

    RB> 1. programatically create a vtkImage (or similar data
    RB> container) to contain x y and z values from an array (x.length
    RB> == y.length ==z.length).  I can only find examples of doing
    RB> this from a file.

    RB> 2. use the vtkWarpScalar filter to create a carpet plot
    RB> distorting the X-Y surface by the Z-Values.

I thought I had replied to this a while back.  Anyway, the following
should help:

 $ cd VTK/Examples
 $ rgrep -l vtkWarpScalar *

reveals the following:

 GUI/Tcl/SphereWidget.tcl
 GUI/Python/SphereWidget.py
 Modelling/Tcl/expCos.tcl
 Modelling/Python/expCos.py
 VisualizationAlgorithms/Tcl/BandContourTerrain.tcl
 VisualizationAlgorithms/Tcl/imageWarp.tcl
 VisualizationAlgorithms/Tcl/warpComb.tcl
 VisualizationAlgorithms/Python/BandContourTerrain.py
 VisualizationAlgorithms/Python/warpComb.py
 VisualizationAlgorithms/Python/imageWarp.py

Of which imageWarp (either Tcl or Python) examples should be
illustrative for warping.

Generating an image could be as simple as

 i = vtkImageData()
 i.SetOrigin(0,0,0)
 i.SetSpacing(1,1,1)
 i.SetDimensions(10, 10, 1)

Of course this is the absoultely simplest way to do it.  If you just
want a regular array of points you can use the vtkStructuredPoints
class also in the same manner.  Then associate scalars for your points
and pass them thru the warp filter to get a carpet.  The examples demo
this.

cheers,
prabhu



More information about the vtkusers mailing list