[Insight-users] make compiler expand all ITK-enum cases for a template call
Dr. Roman Grothausmann
grothausmann.roman at mh-hannover.de
Fri Aug 23 08:08:55 EDT 2013
Many thanks Brad for Your reply. I got it working with Your hints. I'll also try
out SimpleITK, which seems to allow saving a lot of typing and time.
I still wonder though why it is not possible to let the compiler resolve any
possible case if enum types are used in templates.
Is it not possible due to the theoretical compiler-logic or not (yet) included
in the C++ standards or just not implement in e.g. gcc?
Thanks again for Your help
Roman
On 22/08/13 15:13, Bradley Lowekamp wrote:
> Hello,
>
> On Aug 22, 2013, at 6:27 AM, Dr. Roman Grothausmann
> <grothausmann.roman at mh-hannover.de> wrote:
>
>> Dear mailing list members,
>>
>>
>> Can I somehow avoid extending the two nested switch-statements (currently
>> commented out) by a third? Since I use enumeration types (which are
>> definitely finite) for the template argument I'd expect that the compiler
>> should be able to resolve any possible case.
>>
>
> Yes, you should avoid using nested switch statements. I'd suggest parsing
> your argument in the main function, then calling a Dispatch() method with no
> template arguments. This first method would determine the type and dimensions
> of the first image and pass those as template parameters to Dispatch_T1<>,
> add more template parameters for Dispatch_T2 and repeat until you achieve
> your goal, your compiler runs out of memory or time. This way each dispatch
> method just has one straight forward switch statement.
>
> Alternatively, you could also use the typeless C++ layer that SimpleITK
> provides. You can do most of what you did below with just a few lines of
> SimpleITK API. Here is a basic example[1]. You can also get more advance and
> use SimpleITK's dispatch system to create a new SimpleITK level filter
> composed of ITK filters, the generated SimpleITK filter code should provide
> an idea of what would be involve.
>
> Good luck, Brad
>
> [1]
> http://www.itk.org/SimpleITKDoxygen/html/SimpleGaussian_8cxx-example.html
>
--
Dr. Roman Grothausmann
Tomographie und Digitale Bildverarbeitung
Tomography and Digital Image Analysis
Institut für Funktionelle und Angewandte Anatomie, OE 4120
Medizinische Hochschule Hannover
Carl-Neuberg-Str. 1
D-30625 Hannover
Tel. +49 511 532-9574
More information about the Insight-users
mailing list