From facfce3a3c8525c0bbd83527ca018c8300a13c89 Mon Sep 17 00:00:00 2001
From: Emmanuel Christophe <emmanuel.christophe@orfeo-toolbox.org>
Date: Mon, 10 Dec 2007 08:30:42 +0000
Subject: [PATCH] Corrections de Luis pour le divide image filter sur des
 vector image

---
 .../Code/BasicFilters/itkDivideImageFilter.h  |  14 +-
 .../ITK/Code/Common/itkConceptChecking.h      |  10 +-
 ...NumericTraitsVariableLengthVectorPixel.cxx | 175 +-------------
 ...tkNumericTraitsVariableLengthVectorPixel.h | 220 +++++-------------
 4 files changed, 73 insertions(+), 346 deletions(-)

diff --git a/Utilities/ITK/Code/BasicFilters/itkDivideImageFilter.h b/Utilities/ITK/Code/BasicFilters/itkDivideImageFilter.h
index fc2a0c119f..1abd73437a 100755
--- a/Utilities/ITK/Code/BasicFilters/itkDivideImageFilter.h
+++ b/Utilities/ITK/Code/BasicFilters/itkDivideImageFilter.h
@@ -3,8 +3,8 @@
   Program:   Insight Segmentation & Registration Toolkit
   Module:    $RCSfile: itkDivideImageFilter.h,v $
   Language:  C++
-  Date:      $Date: 2006/03/31 14:31:04 $
-  Version:   $Revision: 1.11 $
+  Date:      $Date: 2007/12/08 17:18:04 $
+  Version:   $Revision: 1.13 $
 
   Copyright (c) Insight Software Consortium. All rights reserved.
   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
@@ -53,9 +53,13 @@ public:
   inline TOutput operator()( const TInput1 & A, const TInput2 & B)
   {
     if(B != (TInput2) 0)
+      {
       return (TOutput)(A / B);
+      }
     else
-      return NumericTraits<TOutput>::max();
+      {
+      return NumericTraits<TOutput>::max(A);
+      }
   }
 }; 
 }
@@ -96,6 +100,10 @@ public:
    */
   itkNewMacro(Self);
 
+  /** Runtime information support. */
+  itkTypeMacro(DivideImageFilter, 
+               BinaryFunctorImageFilter);
+
 #ifdef ITK_USE_CONCEPT_CHECKING
   /** Begin concept checking */
   itkConceptMacro(IntConvertibleToInput2Check,
diff --git a/Utilities/ITK/Code/Common/itkConceptChecking.h b/Utilities/ITK/Code/Common/itkConceptChecking.h
index 0082ca59cc..d3bdb315ab 100755
--- a/Utilities/ITK/Code/Common/itkConceptChecking.h
+++ b/Utilities/ITK/Code/Common/itkConceptChecking.h
@@ -3,8 +3,8 @@
   Program:   Insight Segmentation & Registration Toolkit
   Module:    $RCSfile: itkConceptChecking.h,v $
   Language:  C++
-  Date:      $Date: 2007/02/13 18:34:17 $
-  Version:   $Revision: 1.28 $
+  Date:      $Date: 2007/12/08 17:16:01 $
+  Version:   $Revision: 1.30 $
 
   Copyright (c) Insight Software Consortium. All rights reserved.
   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
@@ -21,6 +21,8 @@
 #define __itkConceptChecking_h
 
 #include "itkPixelTraits.h"
+#include "itkNumericTraits.h"
+#include <iostream>
 
 /** Choose a concept checking implementation based on compiler abilities. */
 #ifndef ITK_CONCEPT_NO_CHECKING
@@ -372,13 +374,13 @@ struct DivisionOperators
     void constraints()
       {
       a = static_cast<T3>(b / c);
-      a /= static_cast<T3>(c);
+      a /= c;
       const_constraints(b, c);
       }
     void const_constraints(const T1& d, const T2& e)
       {
       a = static_cast<T3>(d / e);
-      a /= static_cast<T3>(e);
+      a /= e;
       }
     T3 a;
     T1 b;
diff --git a/Utilities/ITK/Code/Common/itkNumericTraitsVariableLengthVectorPixel.cxx b/Utilities/ITK/Code/Common/itkNumericTraitsVariableLengthVectorPixel.cxx
index 7a8bc71ba2..525cb49dd2 100755
--- a/Utilities/ITK/Code/Common/itkNumericTraitsVariableLengthVectorPixel.cxx
+++ b/Utilities/ITK/Code/Common/itkNumericTraitsVariableLengthVectorPixel.cxx
@@ -3,8 +3,8 @@
   Program:   Insight Segmentation & Registration Toolkit
   Module:    $RCSfile: itkNumericTraitsVariableLengthVectorPixel.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/09/16 15:02:28 $
-  Version:   $Revision: 1.1 $
+  Date:      $Date: 2007/12/08 17:14:10 $
+  Version:   $Revision: 1.2 $
 
   Copyright (c) Insight Software Consortium. All rights reserved.
   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
@@ -19,174 +19,7 @@
 namespace itk
 {
 
-const VariableLengthVector<unsigned char>  
-NumericTraits<VariableLengthVector<unsigned char> >::Zero( const VariableLengthVector<unsigned char>  &a )
-{ 
-  VariableLengthVector< unsigned char > b(a.Size()); 
-  b.Fill( NumericTraits< unsigned char >::Zero );
-  return b;
-}
-const VariableLengthVector<unsigned char>  
-NumericTraits<VariableLengthVector<unsigned char> >::One( const VariableLengthVector<unsigned char> &a )
-{ 
-  VariableLengthVector< unsigned char > b(a.Size()); 
-  b.Fill( NumericTraits< unsigned char >::One );
-  return b;
-}
-const VariableLengthVector<signed char>  
-NumericTraits<VariableLengthVector<signed char> >::Zero( const VariableLengthVector<signed char> &a )
-{ 
-  VariableLengthVector< signed char > b(a.Size()); 
-  b.Fill( NumericTraits< signed char >::Zero );
-  return b;
-}
-const VariableLengthVector<signed char>  
-NumericTraits<VariableLengthVector<signed char> >::One( const VariableLengthVector<signed char> &a )
-{ 
-  VariableLengthVector< signed char > b(a.Size()); 
-  b.Fill( NumericTraits< signed char >::One );
-  return b;
-}
-const VariableLengthVector<char>  
-NumericTraits<VariableLengthVector<char> >::Zero( const VariableLengthVector<char> &a )
-{ 
-  VariableLengthVector< char > b(a.Size()); 
-  b.Fill( NumericTraits< char >::Zero );
-  return b;
-}
-const VariableLengthVector<char>  
-NumericTraits<VariableLengthVector<char> >::One( const VariableLengthVector<char> &a )
-{ 
-  VariableLengthVector< char > b(a.Size()); 
-  b.Fill( NumericTraits< char >::One );
-  return b;
-}
-const VariableLengthVector<short>  
-NumericTraits<VariableLengthVector<short> >::Zero( const VariableLengthVector<short> &a )
-{ 
-  VariableLengthVector< short > b(a.Size()); 
-  b.Fill( NumericTraits< short >::Zero );
-  return b;
-}
-const VariableLengthVector<short>  
-NumericTraits<VariableLengthVector<short> >::One( const VariableLengthVector<short> &a )
-{ 
-  VariableLengthVector< short > b(a.Size()); 
-  b.Fill( NumericTraits<short >::One );
-  return b;
-}
-const VariableLengthVector<unsigned short>  
-NumericTraits<VariableLengthVector<unsigned short> >::Zero( const VariableLengthVector<unsigned short> &a )
-{ 
-  VariableLengthVector< unsigned short > b(a.Size()); 
-  b.Fill( NumericTraits< unsigned short >::Zero );
-  return b;
-}
-const VariableLengthVector<unsigned short>  
-NumericTraits<VariableLengthVector<unsigned short> >::One( const VariableLengthVector<unsigned short> &a )
-{ 
-  VariableLengthVector< unsigned short > b(a.Size()); 
-  b.Fill( NumericTraits< unsigned short >::One );
-  return b;
-}
-const VariableLengthVector<int>  
-NumericTraits<VariableLengthVector<int> >::Zero( const VariableLengthVector<int> &a )
-{ 
-  VariableLengthVector< int > b(a.Size()); 
-  b.Fill( NumericTraits< int >::Zero );
-  return b;
-}
-const VariableLengthVector<int>  
-NumericTraits<VariableLengthVector<int> >::One( const VariableLengthVector<int> &a )
-{ 
-  VariableLengthVector< int > b(a.Size()); 
-  b.Fill( NumericTraits< int >::One );
-  return b;
-}
-const VariableLengthVector<unsigned int>  
-NumericTraits<VariableLengthVector<unsigned int> >::Zero( const VariableLengthVector<unsigned int> &a )
-{ 
-  VariableLengthVector< unsigned int > b(a.Size()); 
-  b.Fill( NumericTraits< unsigned int >::Zero );
-  return b;
-}
-const VariableLengthVector<unsigned int>  
-NumericTraits<VariableLengthVector<unsigned int> >::One( const VariableLengthVector<unsigned int> &a )
-{ 
-  VariableLengthVector< unsigned int > b(a.Size()); 
-  b.Fill( NumericTraits< unsigned int >::One );
-  return b;
-}
-const VariableLengthVector<long>  
-NumericTraits<VariableLengthVector<long> >::Zero( const VariableLengthVector<long> &a )
-{ 
-  VariableLengthVector< long > b(a.Size()); 
-  b.Fill( NumericTraits< long >::Zero );
-  return b;
-}
-const VariableLengthVector<long>  
-NumericTraits<VariableLengthVector<long> >::One( const VariableLengthVector<long> &a )
-{ 
-  VariableLengthVector< long > b(a.Size()); 
-  b.Fill( NumericTraits< long >::One );
-  return b;
-}
-const VariableLengthVector<unsigned long>  
-NumericTraits<VariableLengthVector<unsigned long> >::Zero( const VariableLengthVector<unsigned long> &a )
-{ 
-  VariableLengthVector< unsigned long > b(a.Size()); 
-  b.Fill( NumericTraits< unsigned long >::Zero );
-  return b;
-}
-const VariableLengthVector<unsigned long>  
-NumericTraits<VariableLengthVector<unsigned long> >::One( const VariableLengthVector<unsigned long> &a )
-{ 
-  VariableLengthVector< unsigned long > b(a.Size()); 
-  b.Fill( NumericTraits< unsigned long >::One );
-  return b;
-}
-const VariableLengthVector<double>  
-NumericTraits<VariableLengthVector<double> >::Zero( const VariableLengthVector<double> &a )
-{ 
-  VariableLengthVector< double > b(a.Size()); 
-  b.Fill( NumericTraits< double >::Zero );
-  return b;
-}
-const VariableLengthVector<double>  
-NumericTraits<VariableLengthVector<double> >::One( const VariableLengthVector<double> &a )
-{ 
-  VariableLengthVector< double > b(a.Size()); 
-  b.Fill( NumericTraits< double >::One );
-  return b;
-}
-const VariableLengthVector<float>  
-NumericTraits<VariableLengthVector<float> >::Zero( const VariableLengthVector<float> &a )
-{ 
-  VariableLengthVector< float > b(a.Size()); 
-  b.Fill( NumericTraits< float >::Zero );
-  return b;
-}
-const VariableLengthVector<float>  
-NumericTraits<VariableLengthVector<float> >::One( const VariableLengthVector<float> &a )
-{ 
-  VariableLengthVector< float > b(a.Size()); 
-  b.Fill( NumericTraits< float >::One );
-  return b;
-}
-const VariableLengthVector<long double>  
-NumericTraits<VariableLengthVector<long double> >::Zero( const VariableLengthVector<long double> &a )
-{ 
-  VariableLengthVector< long double > b(a.Size()); 
-  b.Fill( NumericTraits< long double >::Zero );
-  return b;
-}
-const VariableLengthVector<long double>  
-NumericTraits<VariableLengthVector<long double> >::One( const VariableLengthVector<long double> &a )
-{ 
-  VariableLengthVector< long double > b(a.Size()); 
-  b.Fill( NumericTraits< long double >::One );
-  return b;
-}
-   
+// All the specializations that were here previously have now been 
+// replaced with a single template in the header file.
 
 } // end namespace itk
diff --git a/Utilities/ITK/Code/Common/itkNumericTraitsVariableLengthVectorPixel.h b/Utilities/ITK/Code/Common/itkNumericTraitsVariableLengthVectorPixel.h
index c6c12f145a..d0b4c9afc9 100755
--- a/Utilities/ITK/Code/Common/itkNumericTraitsVariableLengthVectorPixel.h
+++ b/Utilities/ITK/Code/Common/itkNumericTraitsVariableLengthVectorPixel.h
@@ -3,8 +3,8 @@
   Program:   Insight Segmentation & Registration Toolkit
   Module:    $RCSfile: itkNumericTraitsVariableLengthVectorPixel.h,v $
   Language:  C++
-  Date:      $Date: 2007/09/19 22:32:47 $
-  Version:   $Revision: 1.3 $
+  Date:      $Date: 2007/12/08 17:14:10 $
+  Version:   $Revision: 1.4 $
 
   Copyright (c) Insight Software Consortium. All rights reserved.
   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
@@ -34,173 +34,57 @@
  
 namespace itk
 {
-template <> class NumericTraits<VariableLengthVector<unsigned char > > {
-public:
-  typedef unsigned char ValueType;
-  typedef VariableLengthVector<unsigned char> PrintType;
-  typedef VariableLengthVector<unsigned char> AbsType;
-  typedef VariableLengthVector<unsigned short> AccumulateType;
-  typedef VariableLengthVector<double> RealType;
-  typedef double ScalarRealType;
-  typedef VariableLengthVector<float> FloatType;
-  static const VariableLengthVector<unsigned char> ITKCommon_EXPORT 
-                        Zero( const VariableLengthVector< unsigned char > & );
-  static const VariableLengthVector<unsigned char> ITKCommon_EXPORT 
-                        One(const VariableLengthVector< unsigned char >&);
-};
-template <> class NumericTraits<VariableLengthVector<signed char> > {
-public:
-  typedef signed char ValueType;
-  typedef VariableLengthVector<signed char> PrintType;
-  typedef VariableLengthVector<unsigned char> AbsType;
-  typedef VariableLengthVector<short> AccumulateType;
-  typedef VariableLengthVector<double> RealType;
-  typedef double ScalarRealType;
-  typedef VariableLengthVector<float> FloatType;
-  static const VariableLengthVector<signed char> ITKCommon_EXPORT 
-                        Zero( const VariableLengthVector< signed char > & );
-  static const VariableLengthVector<signed char> ITKCommon_EXPORT 
-                        One(const VariableLengthVector< signed char >&);
-};
-template <> class NumericTraits<VariableLengthVector<char> > {
-public:
-  typedef char ValueType;
-  typedef VariableLengthVector<char> PrintType;
-  typedef VariableLengthVector<unsigned char> AbsType;
-  typedef VariableLengthVector<short> AccumulateType;
-  typedef VariableLengthVector<double> RealType;
-  typedef double ScalarRealType;
-  typedef VariableLengthVector<float> FloatType;
-  static const VariableLengthVector<char> ITKCommon_EXPORT 
-                        Zero( const VariableLengthVector< char > & );
-  static const VariableLengthVector<char> ITKCommon_EXPORT 
-                        One(const VariableLengthVector< char >&);
-};
-template <> class NumericTraits<VariableLengthVector<short> > {
-public:
-  typedef short ValueType;
-  typedef VariableLengthVector<short> PrintType;
-  typedef VariableLengthVector<unsigned short> AbsType;
-  typedef VariableLengthVector<int> AccumulateType;
-  typedef VariableLengthVector<double> RealType;
-  typedef double ScalarRealType;
-  typedef VariableLengthVector<float> FloatType;
-  static const VariableLengthVector<short> ITKCommon_EXPORT 
-                        Zero( const VariableLengthVector< short > & );
-  static const VariableLengthVector<short> ITKCommon_EXPORT 
-                        One(const VariableLengthVector< short >&);
-};
-template <> class NumericTraits<VariableLengthVector<unsigned short> > {
-public:
-  typedef unsigned short ValueType;
-  typedef VariableLengthVector<unsigned short> PrintType;
-  typedef VariableLengthVector<unsigned short> AbsType;
-  typedef VariableLengthVector<unsigned int> AccumulateType;
-  typedef VariableLengthVector<double> RealType;
-  typedef double ScalarRealType;
-  typedef VariableLengthVector<float> FloatType;
-  static const VariableLengthVector<unsigned short> ITKCommon_EXPORT 
-                        Zero( const VariableLengthVector< unsigned short > & );
-  static const VariableLengthVector<unsigned short> ITKCommon_EXPORT 
-                        One(const VariableLengthVector< unsigned short >&);
-};
-template <> class NumericTraits<VariableLengthVector<int> > {
-public:
-  typedef int ValueType;
-  typedef VariableLengthVector<int> PrintType;
-  typedef VariableLengthVector<unsigned int> AbsType;
-  typedef VariableLengthVector<long> AccumulateType;
-  typedef VariableLengthVector<double> RealType;
-  typedef double ScalarRealType;
-  typedef VariableLengthVector<float> FloatType;
-  static const VariableLengthVector<int> ITKCommon_EXPORT 
-                        Zero( const VariableLengthVector< int > & );
-  static const VariableLengthVector<int> ITKCommon_EXPORT 
-                        One(const VariableLengthVector< int >&);
-};
-template <> class NumericTraits<VariableLengthVector<unsigned int> > {
-public:
-  typedef unsigned int ValueType;
-  typedef VariableLengthVector<unsigned int> PrintType;
-  typedef VariableLengthVector<unsigned int> AbsType;
-  typedef VariableLengthVector<unsigned long> AccumulateType;
-  typedef VariableLengthVector<double> RealType;
-  typedef double ScalarRealType;
-  typedef VariableLengthVector<float> FloatType;
-  static const VariableLengthVector<unsigned int> ITKCommon_EXPORT 
-                        Zero( const VariableLengthVector< unsigned int > & );
-  static const VariableLengthVector<unsigned int> ITKCommon_EXPORT 
-                        One(const VariableLengthVector< unsigned int >&);
-};
-template <> class NumericTraits<VariableLengthVector<long> > {
-public:
-  typedef long ValueType;
-  typedef VariableLengthVector<long> PrintType;
-  typedef VariableLengthVector<unsigned long> AbsType;
-  typedef VariableLengthVector<long> AccumulateType;
-  typedef VariableLengthVector<double> RealType;
-  typedef double ScalarRealType;
-  typedef VariableLengthVector<float> FloatType;
-  static const VariableLengthVector<long> ITKCommon_EXPORT 
-                        Zero( const VariableLengthVector< long > & );
-  static const VariableLengthVector<long> ITKCommon_EXPORT 
-                        One(const VariableLengthVector< long >&);
-};
-template <> class NumericTraits<VariableLengthVector<unsigned long> > {
-public:
-  typedef unsigned long ValueType;
-  typedef VariableLengthVector<unsigned long> PrlongType;
-  typedef VariableLengthVector<unsigned long> AbsType;
-  typedef VariableLengthVector<unsigned long> AccumulateType;
-  typedef VariableLengthVector<double> RealType;
-  typedef double ScalarRealType;
-  typedef VariableLengthVector<float> FloatType;
-  static const VariableLengthVector<unsigned long> ITKCommon_EXPORT 
-                        Zero( const VariableLengthVector< unsigned long > & );
-  static const VariableLengthVector<unsigned long> ITKCommon_EXPORT 
-                        One(const VariableLengthVector< unsigned long >&);
-};
-template <> class NumericTraits<VariableLengthVector<float> > {
-public:
-  typedef float ValueType;
-  typedef VariableLengthVector<float> PrintType;
-  typedef VariableLengthVector<float> AbsType;
-  typedef VariableLengthVector<double> AccumulateType;
-  typedef VariableLengthVector<double> RealType;
-  typedef double ScalarRealType;
-  typedef VariableLengthVector<float> FloatType;
-  static const VariableLengthVector<float> ITKCommon_EXPORT 
-                        Zero( const VariableLengthVector< float > & );
-  static const VariableLengthVector<float> ITKCommon_EXPORT 
-                        One(const VariableLengthVector< float >&);
-};
-template <> class NumericTraits<VariableLengthVector<double> > {
-public:
-  typedef double ValueType;
-  typedef VariableLengthVector<double> PrintType;
-  typedef VariableLengthVector<double> AbsType;
-  typedef VariableLengthVector<long double> AccumulateType;
-  typedef VariableLengthVector<double> RealType;
-  typedef VariableLengthVector<float> FloatType;
-  typedef double ScalarRealType;
-  static const VariableLengthVector<double> ITKCommon_EXPORT 
-                        Zero( const VariableLengthVector< double > & );
-  static const VariableLengthVector<double> ITKCommon_EXPORT 
-                        One(const VariableLengthVector< double >&);
-};
-template <> class NumericTraits<VariableLengthVector<long double> > {
+// We provide here a generic implementation based on creating types of
+// VariableLengthVectors whose components are the types of the NumericTraits
+// from the original VariableLengthVectors components.
+template <class T> 
+class NumericTraits<VariableLengthVector< T > > 
+{
 public:
-  typedef long double ValueType;
-  typedef VariableLengthVector<long double> PrintType;
-  typedef VariableLengthVector<long double> AbsType;
-  typedef VariableLengthVector<long double> AccumulateType;
-  typedef VariableLengthVector<long double> RealType;
-  typedef long double ScalarRealType;
-  typedef VariableLengthVector<float> FloatType;
-  static const VariableLengthVector<long double> ITKCommon_EXPORT 
-                        Zero( const VariableLengthVector< long double > & );
-  static const VariableLengthVector<long double> ITKCommon_EXPORT 
-                        One(const VariableLengthVector< long double >&);
+  typedef T ValueType;
+
+  // Get traits from the component
+  typedef typename NumericTraits<T>::AbsType        ElementAbsType;
+  typedef typename NumericTraits<T>::AccumulateType ElementAccumulateType;
+  typedef typename NumericTraits<T>::FloatType      ElementFloatType;
+  typedef typename NumericTraits<T>::PrintType      ElementPrintType;
+  typedef typename NumericTraits<T>::RealType       ElementRealType;
+
+  typedef VariableLengthVector<T>                   Self;
+
+  // Use the component traits to define the VariableLengthVector traits.
+  typedef VariableLengthVector<ElementAbsType>          AbsType;
+  typedef VariableLengthVector<ElementAccumulateType>   AccumulateType;
+  typedef VariableLengthVector<ElementFloatType>        FloatType;
+  typedef VariableLengthVector<ElementPrintType>        PrintType;
+  typedef VariableLengthVector<ElementRealType>         RealType;
+
+  typedef ElementRealType ScalarRealType;
+
+  static const RealType max( const Self & a )
+    { 
+      RealType b(a.Size()); 
+      b.Fill( NumericTraits< T >::max() );
+      return b;
+    }
+  static const RealType min( const Self & a )
+    { 
+      RealType b(a.Size()); 
+      b.Fill( NumericTraits< T >::min() );
+      return b;
+    }
+  static const Self Zero( const Self  & a )
+  { 
+    Self b(a.Size()); 
+    b.Fill( NumericTraits< T >::Zero );
+    return b;
+  }
+  static const Self One( const Self & a )
+  { 
+    Self b(a.Size()); 
+    b.Fill( NumericTraits< T >::One );
+    return b;
+  }
 };
 
 } // end namespace itk
-- 
GitLab