[vtkusers] How to pass a vtk object between python to C++

Glen Lehmann glehmann at imaging.robarts.ca
Thu Oct 9 17:32:06 EDT 2003


Hi Yi-Yu,

It sounds like you need to wrap your c++ function (imReg).  Have a look 
at Examples/vtkMy or Examples/vtkLocal.  You can build these with cmake 
then turn the wrapping on and let the vtk wrappers take care of it for 
you.

As well, you need to include any .h files you use in your imReg.h file 
and link against their library.  i.e. if you have vtkImageData.h 
included in imReg.h you'll need to include vtkImaging in the 
CMakeLists.txt file of vtkLocal.

Good Luck,
Glen

On Thursday, October 9, 2003, at 04:56  PM, Yi-Yu Chou wrote:

> Hi,
> I would like to pass a vtk object (vtlimageData) between python to my 
> own
> C++ class using SWIG. The structure of my code would be like :
> // A.py
> from imgReg import *
> .......
> img1 = vtkImageData()
> IR = ImgReg() <----- my own C++ function
> IR.SetImg(img1)
> .......
>
> //imgReg.i
> %module imgReg
> {% #include "imgReg.h"
> %}
> #include imgReg.h
>
> //imgReg.h
> #include "vtkImageData.h"
> class imgReg {
> public :
>   imgReg();
>  ~imgReg();
>  SetImg(vtkImageData *);
> };
>
> My question is :
> 1. Is this available by using SWIG ?
> 2. Do I need to include vtkImageData.h in my imgReg.i ?
> 3. Because vtkImageData.h contains other .h files, do I   need to 
> include all of them ? And how to include ?(they are a lot)
> 4. How to build the module _imgReg.so with so many .h file ?
>   g++ -shared imgReg.o imgReg_wrap.o -o _imgReg.so ?
>
> Thanks in advance !!!!!!!
>
> _________________________________________________________________
> 現在就上 MSN 台灣網站:與親朋好友緊密聯繫,即時掌握新聞、財經、娛樂的最新訊
>http://msn.com.tw
> _______________________________________________
> This is the private VTK discussion list. Please keep messages 
> on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/enriched
Size: 1935 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20031009/e75e0e22/attachment.bin>


More information about the vtkusers mailing list