[Insight-developers] instantiating itkVector

Luis Ibanez luis.ibanez at kitware.com
Fri Dec 5 12:26:17 EST 2008


Hi Richard,

Thanks for the clarification.


This is good news and bad news  :-)



The good news is that you know the number at compile time,
since that is what the itkVector instantiation will require.

The bad news is that the expression that you need to evaluate
for computing the vector size is a non-trivial one.


One potential way of generating that computation would be to
have a Traits helper class, at the image of the NumericTraits
class.

In this helper class you could define explicit instantiations
such that an internal enum (or static int) will be initialized
to the value of 3^(N-1).

This is a bit manual, but I'm assuming that you would not need
more that dimensions in the range N=1,2,3,4,5 ... (?).
So you will be done with the Traits in a couple of copy/pasting
sessions, and in less than 50 lines of code.

There are probably smarter ways of getting this to work,
but more coffee may be required for figuring them out...


      Regards,


          Luis



----------------------
Richard Beare wrote:
> Hi,
> 
> In this case I'll know it at compile time - it is dependent on the
> dimensionality of the image. Actually, to be specific, it is given by
> 3^(ImType::ImageDimension - 1).
> 
> It would probably look neater in the code if I could do it in a way
> that was not dependent on compile time knowledge, but I'm not sure
> that is possible. I'll need to do something equivalent with matrix
> types too.
> 
> On Fri, Dec 5, 2008 at 12:50 AM, Luis Ibanez <luis.ibanez at kitware.com> wrote:
> 
>>Richard,
>>
>>
>>Would you know the size of the neighborhood at compilation time ?
>>
>>or only at run-time ?
>>
>>
>>Please let us know,
>>
>>
>>  Thanks
>>
>>
>>     Luis
>>
>>
>>----------------------
>>Richard Beare wrote:
>>
>>>Hi,
>>>I need to create a vector type with length equal to the size of a
>>>neighborhood - i.e. 3^ImageDimension. I suspect that there needs to be
>>>some sort of trick with macros, because calling pow is no good. Any
>>>suggestions?
>>>
>>>Thanks
>>>_______________________________________________
>>>Insight-developers mailing list
>>>Insight-developers at itk.org
>>>http://www.itk.org/mailman/listinfo/insight-developers
>>>
>>
> 


More information about the Insight-developers mailing list