[Insight-users] static_cast<DiffusionTensor3D>

Luke Bloy luke.bloy at gmail.com
Fri Nov 7 19:03:04 EST 2008


Hi all,

I'm not sure what the correct forum for this question is but hopefully i 
can get some input here.

I'm trying to work with itkNaryFunctorImageFilter, I'm starting with the 
itkNaryAddImageFilter since it is fairly straight forward.

The problem is that i'd like to use it over DTI images, and there isn't 
a itkNumericTraits definition file for itkDiffusionTensor3D. So I 
created one based off of NumericTraitsVectorPixel.h and 
NumericTraitsVectorPixel.cxx. I also fixed the file 
itkNumericTraitsTensorPixel. I added my cxx classes to the CmakeLists in 
Code/Common and everything is working... except casting.

It seems that the AccumulateType is often defined to be above the pixelType
ie the accumulateType for a itk::vector<int,2> is itk::vector<long::2>, 
this makes sense and I maintained that in my DiffusionTensor3D 
NumericTraits file.

How ever static_casts fail which causes problems with code like this.

  typedef typename NumericTraits< TInput >::AccumulateType AccumulatorType;
  AccumulatorType sum = NumericTraits< TOutput >::Zero;
  for( unsigned int i=0; i< B.size(); i++ )
      {
      sum += static_cast< TOutput >(B[i]);
      }      
    return static_cast<TOutput>( sum );
  }

So what am I missing? Is there somewhere else the I have to explicitly 
define the casting. There doesn't seem to be anything in the class 
definitions for itkVector, so I assume that it goes someplace other then 
in the class definitions.

Thanks in advance.
-Luke


More information about the Insight-users mailing list