[Insight-users] Python Wrapping: A lonely journey
Carlos Phillips
carlos.phillips at mail.mcgill.ca
Tue, 10 Feb 2004 00:07:56 -0500
Hi,
Here is the link to the message which lead me to the conclusion that
the wrapping would not be too hard. Note that the author of this
message did in fact not say that it would be easy, but only stated that
it could be done. I assumed from the email that the example mentioned
could be modified without too much fuss to do what I wanted.
http://www.itk.org/pipermail/insight-users/2003-December/005994.html
Carlos
On Feb 9, 2004, at 5:07 PM, Brad King wrote:
> Carlos Phillips wrote:
>> Hi,
>> Over a month ago I set out to use ITK through python by wrapping
>> custom subclasses of ITK. I wrote most of the relevant ITK c++ code
>> and constructed vtk-python based visualization classes. During this
>> time, I posted several messages on this list asking for help in
>> creating python wrappers for custom subclasses of ITK. I was assured
>> that this would not be too hard, but I have yet to manage to do this.
>> Also, no one seems to have any working examples of wrapping custom
>> classes.
>
> Support for wrapping classes outside the tree is still under
> development. Pleast send me links to the mailing list archive for the
> messages that told you it wouldn't be too hard. I will try to clarify
> or correct what was said.
>
> > I have managed to
>> create wrappers for templated functions which access ITK data
>> structures as is done in ConnectVTKITK. I have also managed to create
>> wrappers for classes which do not subclass ITK classes. I have not
>> managed to create a wrapper for even the simplest ITK subclass:
>> template<typename TPixel>
>> class Image2D : public itk::Image< TPixel, 2 >
>> {
>> public:
>> typedef Image2D Self;
>> typedef itk::Image Superclass;
>> typedef itk::SmartPointer<Self> Pointer;
>> typedef itk::SmartPointer<const Self> ConstPointer;
>> itkNewMacro( Self );
>> itkTypeMacro( Image2D, Image );
>> }
>> I tried using the following cable config file:
>> %module TestPython
>> %{
>> #include "itkImage.h"
>> #include "Test.h"
>> %}
>> %include "Test.h"
>> %template(classNameUS2) className<itk::Image<short unsigned int, 2> >;
>
> This is a SWIG configuration file, not a CableSwig configuration file.
> It will not work for ITK classes because the level of C++ templates
> involved it too hard for SWIG.
>
>> I can't seem to get this to be processed. Is there anyone out there
>> who could help me. I have invested considerable time in understanding
>> ITK and would hate to have to start looking for a new framework.
>> Any help would be greatly appreciated.
>
> Hopefully we will have support within a couple of months (it actually
> should work now, but the amount of code required is pretty large).
> For now, you can try putting your class inside Insight/Code/Algorithms
> and looking at the CMakeLists.txt file there and in
> Insight/Wrapping/CSwig/Algorithms to see how the classes are
> registered for the build and for wrapping.
>
> -Brad
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
>