[Insight-users] [Fwd: factories for FFTW filters - update]

Luis Ibanez luis.ibanez at kitware.com
Thu Oct 26 09:46:20 EDT 2006



Hi Jakub,


If you are interested in overriding a factory with another one,
you may want to look at the following course material:


http://www.na-mic.org/Wiki/index.php/Dissemination:EPFL_Workshop_2005


In particular to the presentation:

http://www.na-mic.org/Wiki/images/2/24/Insight-DesignPatterns.ppt


The discussion on Factories starts on slide 53.

The source code of examples for Factories can be found at

http://www.na-mic.org:8000/svn/NAMICSandBox/trunk/ITKAdvancedCourse/


In Exercise 29:
http://www.na-mic.org:8000/svn/NAMICSandBox/trunk/ITKAdvancedCourse/src/Exercises/exercise29/


    Regards,


       Luis


=---------------------------
Jakub Bican wrote:
> 
> Hi Gaetan,
> 
> as i more and more understand the problem of factories, it is clear to 
> me, that this is the most elegant solution.
> 
> Your suggestion have to be complicated only a little bit more by 
> determining, if the actual PixelType matches the type of FFTW library 
> linked: i.e. use FFTW only if FFTWF is defined and PixelType is float or 
> FFTWD is defined and pixeltype is double.
> 
> There should be also check if there is some factory for the class, as it 
> is in itkNewMacro (in case someone will use dynamic library with new FFT 
> implementation)
> 
> Is it possible to make such change to ITK cvs version?
> 
> I hope this will help to many people that are writing filters using FFT.
> 
> Thanks,
> 
>       Jakub
> 
> 
> 
> 
> Gaetan Lehmann napsal(a):
> 
>>
>> Hi Jakub,
>>
>> That's only my point of view, but don't you think that the factory is 
>> quite complicated for that case ?
>> IMHO opinion, a customized New() method in 
>> RealToComplexConjugateImageFilter would do the job without problem. 
>> Something like:
>>
>> static Pointer New()
>>   {
>> #if defined(USE_FFTWF)
>>   return FFTWRealToComplexConjugateImageFilter<PixelType, 
>> ImageDimension>::New().GetPointer();
>> #else
>>   return VnlFFTRealToComplexConjugateImageFilter<PixelType, 
>> ImageDimension>::New().GetPointer();
>> #endif
>>   }
>>
>> Regards,
>>
>> Gaetan
>>
>>
>>
>> On Thu, 26 Oct 2006 11:51:13 +0200, Jakub Bican 
>> <jakub.bican at matfyz.cz> wrote:
>>
>>>
>>> Hi,
>>>
>>> things seem more clear now: I have to make just one class 
>>> (FFTFactory:ObjectFactoryBase) that calls RegisterOverride() in its 
>>> constructor to override creation of RealToComplexConjugateImageFilter 
>>> and ComplexConjugateToRealImageFilter by available implementation 
>>> from VNL or FFTW.
>>>
>>> But the questions remains the same:
>>> 1) how to register this factory as "implicit default factory" - 
>>> without need to register it manually in every filter or every program 
>>> that uses FFT
>>>
>>> 2) what happens if there will be new FFT implementation in dynamic 
>>> library, that will override in the same way - which factory will have 
>>> priority? (if the dynamic one overrides the default one, then it is 
>>> ok - that is the intention, but does it really happen?)
>>>
>>>
>>> Regards,
>>>
>>>         Jakub
>>>
>>>
>>>
>>>
>>> -------- Původní zpráva --------
>>>
>>> Hello,
>>>
>>> i would like to implement a factory mechanism for FFT filters. The 
>>> point is that if the user selects "USE_FFTW" once during 
>>> configuration, then the factory mechanism will provide him FFTW-based 
>>> classes instead of standard VNL implementation. And user can also 
>>> create his own dll with some fft implementation and attach it 
>>> dynamically to his project.
>>>
>>> I studied the tutorial 
>>> (http://www.na-mic.org/Wiki/images/2/24/Insight-DesignPatterns.ppt) 
>>> including examples.
>>>
>>> I would like to ask someone if i understand well what i have to do:
>>>
>>> step A) create factories FFTWFFTFactory and VNLFFTFactory (derived 
>>> from following class), that will override creation of 
>>> RealToComplexConjugateImageFilter and 
>>> ComplexConjugateToRealImageFilter types so that an instance from 
>>> appropriate implementation is created.
>>>
>>> step B) create class FFTFactoryBase (derived from ObjectFactoryBase) 
>>> that will be implemented similary to TransformFactoryBase and that 
>>> will register one of the above factories, depending on if the FFTW is 
>>> used or not
>>> (this is difference to TransformFactoryBase, which registers all 
>>> known factories, while the new class will register only one depending 
>>> on configuration)
>>>
>>>
>>> And i have some questions:
>>>
>>> 1) what is the correct way of registering FFTFactoryBase 
>>> automatically, so that it registers appropriate factory "at the 
>>> beginning"?
>>> I don't want to register it explicitly at the beginning of every 
>>> program that will use FFT - i just want to call 
>>> RealToComplexConjugateImageFilter::New() and get FFTW implementation 
>>> if i attached FFTW library to ITK or VNL implementation otherwise.
>>>
>>> 2) what happens if someone loads dll into ITK_AUTOLOAD_PATH with a 
>>> new FFT implementation and corresponding factory? What will be 
>>> overriden by what?
>>>
>>> Thanks in advance for guidance and answers,
>>>
>>>    Jakub
>>>
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> Insight-users mailing list
>>> Insight-users at itk.org
>>> http://www.itk.org/mailman/listinfo/insight-users
>>
>>
>>
>>
>> --Gaëtan Lehmann
>> Biologie du Développement et de la Reproduction
>> INRA de Jouy-en-Josas (France)
>> tel: +33 1 34 65 29 66    fax: 01 34 65 29 09
>> http://voxel.jouy.inra.fr
>>
>>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
> 


More information about the Insight-users mailing list