[Insight-users] embarassingly basic question
Vladimir S. Fonov
vladimir.fonov at gmail.com
Thu Apr 26 10:49:52 EDT 2012
Hello,
I create helper functions like these:
template<class T> typename itk::Point<T, 3> ITK_POINT(const T&x,const
T&y,const T&z)
{
T dummy[3]={x,y,z};
return itk::Point<T, 3>(dummy);
}
template<class T> typename itk::Point<T, 2> ITK_POINT(const T&x,const T&y)
{
T dummy[2]={x,y};
return itk::Point<T, 2>(dummy);
}
...
itk::Point<double,3> point3d=ITK_POINT<double>(10,20,30);
itk::Point<double,2> point2d=ITK_POINT<double>(10,20);
On 12-04-25 03:44 PM, Rupert Brooks wrote:
> Its when I show ITK to other people that I end up with embarassingly
> simple questions that I ought to know the answer to.
>
> When declaring an itk::Point (or vector, etc, anything based on
> FixedArray) there is no constructor that assigns values that i know
> of. So one always ends up doing something like
> itk::Point<double, 3> p;
> p[0]=1.1;
> p[1]=2.2;
> p[2]=3.3;
>
> or
>
> const double[3] dummy={1.1,2.2,3.3};
> const itk::Point<double, 3>=dummy; // at least this way we can get a
> const itk::Point
>
> It was pointed out to me that this is quite verbose. A certain ideal
> would be, eg
>
> const itk::Point<double,3> p(1.1,2.2,3.3);
>
> Is there a better way? Was this a design choice, or an inevitable
> consequence of variadic constructors not being possible in C++?
--
Best regards,
Vladimir S. Fonov ~ vladimir.fonov <at> gmail.com
More information about the Insight-users
mailing list