[vtkusers] VTK 3D Structured Grid Problem

REGAT-BARREL Aurélien arbvtk at yahoo.fr
Wed Jul 7 17:15:54 EDT 2004


>>idx = 0
>>for i in range(0,2*nz):
>> for j in range(0,2*ny):
>> for i in range(0,2*nx):
^^^^^^^
>> pts.SetPoint(idx, nanna[0,idx], nanna[1,idx], nanna
[2,idx])
>> idx = idx + 1 

>you realize you're using the 'i' as an index twice, right? I'm not
>a python expert but you should be sure this is what you want.

Thanks Tom, it was my mistake... the results didn't change, anyway. It is still 
slow...


I had exactly the same problem. It's slow because each call to SetPoint from Python calls SetPoint from vtk c++ code through vtk python wrapper code (which does parameters checks, etc...), so 99% of the time is spent in the wrapper code. That's why it is so slow.

So I moved my code to C++ and wrapped it with swig in order to use it from Python. I wrote this article which explains how to deals with vtk, python and swig :

http://coding.bug.free.fr/lib/vtk/vtkpythoncpp.htm

If you plan to use this solution, be aware that this code has memory leaks, I have to update the example and add calls to Delete() for each object allocated before returning.

 


Aurélien REGAT-BARREL
		
---------------------------------
Créez gratuitement votre Yahoo! Mail avec 100 Mo de stockage !
Créez votre Yahoo! Mail

Dialoguez en direct avec vos amis grâce à Yahoo! Messenger !
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040707/e2fef627/attachment.htm>


More information about the vtkusers mailing list