[Insight-developers] Better Point Casting

Luis Ibanez luis.ibanez@kitware.com
Wed, 20 Feb 2002 07:48:43 -0500


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