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