[vtkusers] strange python numpy problem

Eugen Wintersberger eugen.wintersberger at jku.at
Tue Oct 16 03:37:45 EDT 2007


Hi there
 I've just started with VTK and want to use it together with python for
writting scripts for data visualization. In python numpy arrays are my 
most favorable structures for holding numerical data, therefore, I would
like copy data directly from a numpy array to a vtkFloatArray for
instance without using loops.
You will find two scripts attached to this mail:
test1.py which fills a vtkFloatArray from a numpy array by means of a   
         loop
test2.py which fills a vtkFloatArray using the SetVoidArray method
         of the vtkFloatArray class.
After filling in the data I print the data stored in the vtkFloatArray
and get the following output:

~/src/test/python/vtk $ python test1.py                                                                                                                      
0.10000000149                                                                                                                                                
0.20000000298                                                                                                                                                
0.300000011921                                                                                                                                               
0.40000000596                                                                                                                                                
0.5                                                                                                                                                          
0.600000023842                                                                                                                                               
0.699999988079                                                                                                                                               
0.800000011921   

and  

~/src/test/python/vtk $ python test2.py                                                                                                                      
0.10000000149                                                                                                                                                
0.20000000298                                                                                                                                                
0.300000011921                                                                                                                                               
0.40000000596                                                                                                                                                
0.5                                                                                                                                                          
0.600000023842                                                                                                                                               
0.699999988079                                                                                                                                               
0.800000011921      

So it seems that both procedures load the data correctly into the 
vtkFloatArray. However, the resulting 3D image looks much more different
as you can see from the two attached screenshots of test1.jpg and
test2.jpg (the screenshots belong to the output of the scripts test1.py
and test2.py respectively). 

I user VTK 5.0.2 on an Ubuntu AMD64 (native 64Bit) installation. 

Has anyone an idea what I am doing wrong or if there is a problem in the
VTK/python interface? If this numpy arrays are not supported it would be
an interesting feature to add to VTKs python interface.

best regrads  
  Eugen Wintersberger

 

-- 
--------------------------------------------
|                                          |
| Dipl. Ing. Eugen Wintersberger           |
| Department of semicondutor physics       |
| University of Linz                       |
| Altenbergerstrasse 69                    |
| A-4040 Linz                              |
| Austria                                  |
|                                          |
| Mobile.: +43 664 3112861                 |
| Tel.: +43 732 2468 9605                  |
| E-Mail.: eugen.wintersberger at jku.at      |
| Skype: eugen20056221                     |
| ICQ: 214418739, nickname: thot           |
|                                          |
--------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test1.py
Type: text/x-python
Size: 1945 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20071016/e585e251/attachment.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test1.jpg
Type: image/jpeg
Size: 24942 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20071016/e585e251/attachment.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test2.py
Type: text/x-python
Size: 1946 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20071016/e585e251/attachment-0001.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test2.jpg
Type: image/jpeg
Size: 25627 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20071016/e585e251/attachment-0001.jpg>


More information about the vtkusers mailing list