VTK internal error messages

Randall Hopper aa8vb at ipass.net
Sun Apr 30 14:21:02 EDT 2000


 |Also a warning:  when you use SetVoidArray(), whether from Python
 |or C++, you're playing with fire.  In the future the VTK graphics
 |pipeline will be probably be expanded to deal with both float and
 |double, and your code expects that vtkVectors are float.  

Ok, thanks for the tip.  Is there a better way to bulk-load floating-point
data into VTK from a scripting language (without having to loop through
every grid cell)?

In this case, I'm loading a 2D velocity grid from a file.  The velocity
components are stored in separate grids, and the grids are in column-major
order (i.e. not VTK-compatible).  So, I'm using NumPy to do the data
shuffling (column- to row-major, merge components into vectors), and then
loading the entire grid into a vtkStructuredPoints dataset:

    u = transpose( reshape( fromstring( u_data, Float32 ), 
                            (dim[1], dim[0]) ) )
    v = transpose( reshape( fromstring( v_data, Float32 ),
                            (dim[1], dim[0]) ) )
    veloc = ( u[:,:,NewAxis] * array([0,1,0], Float32) +       #FIXME
              v[:,:,NewAxis] * array([1,0,0], Float32) )       #FIXME
    data = veloc.astype( Float32 ).tostring()

    vectors = vtkVectors()
    vectors.GetData().SetVoidArray( data, dim[0] * dim[1] * 3, 1 )

    sp = vtkStructuredPoints()
    sp.GetPointData().SetVectors( vectors )

This avoids looping over thousands of cells in the scripting language.

 |If VTK detects an error, then it _does_ return a useful error message
 |in nearly all cases.  The problem you are seeing is a problem with the
 |Python wrappers, not with the core VTK libraries.
...
 |I've attached a patched vtkPythonUtil.cxx that does proper
 |type-checking.  Enjoy.

Thanks.  I'll try it out.

Randall

-- 
Randall Hopper
aa8vb at ipass.net
--------------------------------------------------------------------
This is the private VTK discussion list. Please keep messages on-topic.
Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at public.kitware.com>. For help, send message body containing
"info vtkusers" to the same address.
--------------------------------------------------------------------



More information about the vtkusers mailing list