[Insight-developers] Better Point Casting

Robert J Tamburo rjtst21@pitt.edu
Wed, 20 Feb 2002 08:31:16 -0500


On the subject of itkPoint ......... when should someone use itkVector vs.
vnl_vector or itkMatrix vs. vnl_matrix. I kind of just "wing" it based on
what functionality I need (i.e. I'll use vnl_vector if I need dot products),
but I'm sure there's some logic in choosing the more appropriate class.

Rob

----- Original Message -----
From: Luis Ibanez <luis.ibanez@kitware.com>
To: Lydia Ng <lng@insightful.com>
Cc: <insight-developers@public.kitware.com>
Sent: Wednesday, February 20, 2002 7:48 AM
Subject: [Insight-developers] Better Point Casting


> Hi,
>
> A better Casting function has been added to the itk::Point class.
>
> This one is a templated member of the Point class. It is templated
> over the representation type of the source Point (to be cast).
>
> It looks like
>
>
> template < typename TB>
> void CastFrom( const Point< TB, PointDimension > & pa ) {
> for(unsigned int i=0; i<PointDimension; i++)
>   {
>   (*this)[i] = static_cast< TCoordRep >( pa[i] );
>   }
> }
>
>
> It has the advantage of enforcing Dimension matching on the source point
> and restricting the cast only to Point types.
>
> The use is like:
>
> itk::Point< double, 3 >   pd;
> itk::Point< float, 3 >   pf;
>
> pf.CastFrom( pd );
>
>
>          Luis
>
>
>
>
> _______________________________________________
> Insight-developers mailing list
> Insight-developers@public.kitware.com
> http://public.kitware.com/mailman/listinfo/insight-developers
>