[Insight-developers] ZeroIndex

Miller, James V (Research) millerjv at crd . ge . com
Tue, 27 Aug 2002 11:21:10 -0400


Can we do without ZeroIndex?  

Index now has a Fill() method so it is fairly easy to create an 
index and set it to zero. Or we can make sure the default constructor
initializes to zero (we are currently relying on the compiler
generated constructor).

'Course the benefit to having the ZeroIndex static was that 
we could avoid one constructor call per use.

I only count about 20 places it is used (outside the Examples
and Testing). Add another 40 occurances in Examples and Testing.



> -----Original Message-----
> From: Bill Hoffman [mailto:bill.hoffman@kitware.com]
> Sent: Tuesday, August 27, 2002 10:07 AM
> To: insight-developers@public.kitware.com
> Cc: James V. Miller
> Subject: [Insight-developers] ZeroIndex
> 
> 
> OK, there is only one static left that is breaking the 
> compile on the Mac.
> 
> template<unsigned int VIndexDimension=2>
> class Index {
> public:
>   static const Self ZeroIndex;
> ...
> 
> 
> // Set the const definition of the ZeroIndex. This uses the aggregate
> // initialization shortcut to assign all the data in the 
> aggregate to zero.
> template<unsigned int VIndexDimension>
> const Index<VIndexDimension>
> Index<VIndexDimension>
> ::ZeroIndex = {{0}};
> 
> 
> However, this one seems a bit harder to remove than the rest of them.
> Any ideas?
> 
> To get around the problem, you can add explicit 
> instantiations for Index.
> 
> template class itk::Index<2>; 
> template class itk::Index<3>; 
> template class itk::Index<4>; 
> template class itk::Index<5>; 
> 
> This gets around the problem on the Mac, but if you ever 
> template over a different
> number, it will not work.
> 
> -Bill
> 
> 
> _______________________________________________
> Insight-developers mailing list
> Insight-developers@public.kitware.com
> http://public.kitware.com/mailman/listinfo/insight-developers
>