[Insight-users] Problem with ImageDimension and typedef
Bryn
blloyd at bwh.harvard.edu
Sat Oct 1 04:58:23 EDT 2005
> I cannot reproduce your problem without seeing a minimal example of
> your code...
>
I am posting a some code as attachment, to show the problem...
> The pixeltype for the VectorImage, if you write code, should be
> obtained from the Image class.. This is the reason for generic
> programming. But if you find it convenient, I can easily add
> overloaded = operators in itk::VariableLengthVector and itk::Array,
> which is probably a good thing anyway, since they should be assignable
> from each other...
>
That would be nice.
> I still do not understand what compiles in gcc34 and not in gcc33. If
> any, I've seen things go the other way......
>
It seems that, if I define a templated class which holds a specific type
of Image or VectorImage, say VectorImage<int,3>.
I then typedef the PixelType from the VectorImage, and finally add a
function with this PixelType as argument type, gcc-3.3 compiles ok.
so say I have something like this (inside the class):
typedef VectorImage<int,3> VectorImageType;
typedef VectorImageType::PixelType PType;
PType method( PType );
gcc-3.3 compiles ok.
But if I change this VectorImage typedef to:
typedef VectorImage<int,ImageDimension> VectorImageType;
where the ImageDimension is defined by:
itkStaticConstMacro(ImageDimension, unsigned int,
TInputImage::ImageDimension);
gcc-3.3 complains. gcc-3.4 compiles both versions just fine.
Maybe something I am doing is wrong. It seems it has to do with the way
I get the ImageDimension.
It would be nice to know why the second version doesn't compile with gcc-3.3
Thanks
Bryn
> -karthik
>
>>
>>
>> Thanks
>> Bryn
>>
>>
>> _______________________________________________
>> Insight-users mailing list
>> Insight-users at itk.org
>> http://www.itk.org/mailman/listinfo/insight-users
>>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: itkVectorImageAndTypedefTest.h
Type: text/x-chdr
Size: 1819 bytes
Desc: not available
Url : http://public.kitware.com/pipermail/insight-users/attachments/20051001/46b840e6/itkVectorImageAndTypedefTest.h
-------------- next part --------------
///author: Bryn Lloyd
#ifndef _itkVectorImageAndTypedefTest_txx
#define _itkVectorImageAndTypedefTest_txx
namespace itk
{
/**
* Constructor
*/
template <class TInputImage,class TOutputImage>
VectorImageAndTypedefTest<TInputImage,TOutputImage>
::VectorImageAndTypedefTest()
{
}
/**
* Sort an int Array
*/
template <class TInputImage,class TOutputImage>
typename VectorImageAndTypedefTest<TInputImage,TOutputImage>::TestPixelType
VectorImageAndTypedefTest<TInputImage,TOutputImage>
::DoSomething(const TestPixelType& indices)
{
TestPixelType test(3);
return test;
}
/**
* Sort an int Array
*/
template <class TInputImage,class TOutputImage>
void
VectorImageAndTypedefTest<TInputImage,TOutputImage>
::GenerateData()
{
}
/**
* Print Self
*/
template <class TInputImage,class TOutputImage>
void
VectorImageAndTypedefTest<TInputImage,TOutputImage>
::PrintSelf(std::ostream& os, Indent indent) const
{
Superclass::PrintSelf(os,indent);
}
} // end namespace itk
#endif
More information about the Insight-users
mailing list