[Insight-developers] using swig to wrap ITK - a summary of the
tcon (and a little much)
Bill Hoffman
bill.hoffman at kitware.com
Sun Nov 19 16:34:27 EST 2006
Gaëtan Lehmann wrote:
>
>
> It works with python !
>
> And better, it works for all the classes currently wrapped in WrapITK,
> not only 2 or 3 classes partially wrapped, and even better, it's
> already automatically generated !
> All the classes are wrapped in different modules, so when I use a
> median filter, it imports all the modules with the superclasses.
OK, so each class has its own module? That seems a bit excessive. By
module I assume you mean a .so file right?
> A example of a test I have just run, with :
>
> import itkImageFileReaderPython
> import itkMedianImageFilterPython
> reader = itkImageFileReaderPython.itkImageFileReaderIUS2_New()
> median = itkMedianImageFilterPython.itkMedianImageFilterIUS2IUS2.New()
> median.SetInput(reader.GetOutput())
> import itkImageFileWriterPython
> writer = itkImageFileWriterPython.itkImageFileWriterIUS2_New()
> reader.SetFileName('/Users/glehmann/Desktop/tub.tif')
> writer.SetFileName('out.png')
> import itkGrayscaleFillholeImageFilterPython
> fillhole =
> itkGrayscaleFillholeImageFilterPython.itkGrayscaleFillholeImageFilterIUS2IUS2.New()
>
> fillhole.SetInput(median.GetOutput())
> import itkRescaleIntensityImageFilterPython
> rescale =
> itkRescaleIntensityImageFilterPython.itkRescaleIntensityImageFilterIUS2IUS2.New()
>
> rescale.SetInput(fillhole.GetOutput())
> writer.SetInput(rescale.GetOutput())
> writer.Update()
>
> python is nice enough to tell us how many modules we have:
>
> 21> len([a for a in sys.modules if a.startswith("itk") or
> a.startswith("vnl")])
> 21> 79
>
> Is that enough modules for you ?
>
> But I will NOT make it work in tcl and java, until I'm sure it will be
> used, simply because I know nearly nothing in tcl, and I'm not used to
> wrap classes in java. I will NOT make it work on windows by myself,
> because I don't have windows, because I never have used a microsoft
> compiler, because that's something new to learn and my time is limited.
>
> Also, the work done here is done on my free time - I also have a
> familly life, and a work to do.
> And like you, I'm not a swig expert - I'm just a guy who try to make
> things work.
>
>> CableSwig does some tricks on the internals of swig as it runs right
>> now making all of this work.
>
> Again: which tricks ??
Well getting more than one class in a module and creating the correct
_init functions for one.
>
> I'm still waiting for a reply about my last question: why grouping the
> swig modules, like itkImageToImageFilter, itkImage, ..., in bigger
> modules, like ITKCommonA ?
>
Having one dll or .so per class wrapped adds some overhead, and compile
times. Maybe it will work, but it seems
a bit excessive.
> I can't understand why the communication is so difficult. Perhaps
> that's because all the communications are done by email ? I'm not
> sure, but that's for this reason I joined the tcon last friday - and
> believe it, that's a huge effort for me.
> It would have be nice to disscuss about that during this tcon.
>
Sorry I missed it, and email is difficult for things like this.
>> I do not know how to do those same things in a swig .i file. I
>> suspect that it will work, but until
>> I see it, I would not be willing to make any commitments to this effort.
>>
>
> You know that making WrapITK work with all those systems is difficult.
> You know that make WrapITK work with all those languages is difficult.
> I will not make that alone.
> If I'm alone, I stop the tcl and java parts, I take care of gcc on
> linux and my mac, I stop taking care of the cmake configurations, I
> stop writting mails to this mailing list (it should save me lot of
> time, and some frustration for all the mails without answer). If I'm
> alone, I move back WrapITK to its darcs repository on my server, and
> continue to develop it alone on my side, with a better versionning
> tool, without being afraid of breaking things I shouldn't.
>
I know making WrapITK work with all that stuff is hard. That is exactly
why I suggested creating a small test
system that just used hand coded .i and .h, but shows the features we
need. I would be willing to try a small
test on windows and with tcl and java. I don't have time to get cvs
pygccxml, and cvs swig going to give it a try.
BTW, making attacks on CVS is not really constructive. I really can't
see how it is slowing down your development
significantly. ITK is a large system it takes time an preparation to
move to anything new.
WrapITK is a good example of that. We moved too quick before it was
fully tested.
This is why I want to see a small example working for all the
requirements of ITK. Once we know that will work,
it is just a matter of generating more of the same. I don't want to
spend weeks getting things to work only to find
out there is some gotcha and it is simply impossible to do what we want
with this approach. We need to remove that
risk early on before we spend time on the actual wrapping part.
-Bill
More information about the Insight-developers
mailing list