[Insight-users] static_cast<DiffusionTensor3D>

Karthik Krishnan karthik.krishnan at kitware.com
Sun Nov 9 17:58:50 EST 2008


Thanks Luke:

We'll look forward to your patch.

On Sat, Nov 8, 2008 at 3:29 PM, Luke Bloy <luke.bloy at gmail.com> wrote:

> Hi Karthik,
>
> Thanks for the reply, I saw those methods this morning an I've added them
> to the symmeticsecondranktensor and to the diffusionTesnor3D and everything
> is working. pretty well.
>
> I've also added some methods for computing the matrix log and the matrix
> exponential,I'll send a patch once I'm done.
>
> Thanks again.
> Luke
>
>
>
> Karthik Krishnan wrote:
>
>> That is because the class itk::Vector defines copy constructors and
>> assignment operators that support implicit casting ... for instance..
>>
>>  Vector< float , N > can be assigned to Vector< double, N >
>>
>> ----
>> See
>>
>> http://public.kitware.com/cgi-bin/viewcvs.cgi/Code/Common/itkVector.h?annotate=1.82&root=Insight
>>
>>  /** Pass-through constructor for the Array base class. */
>>  template< class TVectorValueType >
>>  Vector(const Vector< TVectorValueType, NVectorDimension>& r):
>> BaseArray(r) {}
>>  Vector(const ValueType r[Dimension]): BaseArray(r) {}    /** Pass-through
>> assignment operator for the Array base class. */
>>  template< class TVectorValueType >
>>  Vector& operator= (const Vector< TVectorValueType, NVectorDimension> & r)
>>   {
>>   BaseArray::operator=(r);
>>   return *this;
>>   }
>> ----
>>
>> Thus the copy constructor and the assignment operator are templated member
>> functions.
>> I did not add these to the DiffusionTensor3D or the
>> SymmetricSecondRankTensor classes.
>> If you can add it to the SymmetricSecondRankTensor and DiffusionTensor3D
>> class as
>> well... (should be just 5 lines), and send us the patch, we'd be happy to
>> commit it.
>>
>>
>> Thanks
>>
>>
>> Luke Bloy wrote:
>>
>>> 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
>>> _______________________________________________
>>> Insight-users mailing list
>>> Insight-users at itk.org
>>> http://www.itk.org/mailman/listinfo/insight-users
>>>
>>
>>


-- 
Karthik Krishnan
R&D Engineer,
Kitware Inc.
Ph: 518 371 3971 x119
Fax: 518 371 3971
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20081109/c6e00829/attachment.htm>


More information about the Insight-users mailing list