From 439339669a3a5d2b08128f1121a2280701d49cd3 Mon Sep 17 00:00:00 2001
From: Guillaume Borrut <guillaume.borrut@c-s.fr>
Date: Fri, 5 Sep 2008 08:51:38 +0000
Subject: [PATCH] Ajout de la classe ArchitectureData et modif du nom de la
 classe functor

---
 Code/SARPolarimetry/otbPolarimetricData.cxx   | 122 ++++++++++++++++++
 Code/SARPolarimetry/otbPolarimetricData.h     |  91 +++++++++++++
 .../otbPolarimetricSynthesisFunctor.h         |  84 ++++++++++++
 3 files changed, 297 insertions(+)
 create mode 100644 Code/SARPolarimetry/otbPolarimetricData.cxx
 create mode 100644 Code/SARPolarimetry/otbPolarimetricData.h
 create mode 100644 Code/SARPolarimetry/otbPolarimetricSynthesisFunctor.h

diff --git a/Code/SARPolarimetry/otbPolarimetricData.cxx b/Code/SARPolarimetry/otbPolarimetricData.cxx
new file mode 100644
index 0000000000..ce40bfe729
--- /dev/null
+++ b/Code/SARPolarimetry/otbPolarimetricData.cxx
@@ -0,0 +1,122 @@
+/*=========================================================================
+
+  Program:   ORFEO Toolbox
+  Language:  C++
+  Date:      $Date$
+  Version:   $Revision$
+
+
+  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
+  See OTBCopyright.txt for details.
+
+
+     This software is distributed WITHOUT ANY WARRANTY; without even 
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+     PURPOSE.  See the above copyright notices for more information.
+
+=========================================================================*/
+#ifndef __otbPolarimetricData_cxx
+#define __otbPolarimetricData_cxx
+
+#include "otbPolarimetricData.h"
+
+
+namespace otb
+{
+/**
+ * Constructor
+ */
+PolarimetricData
+::PolarimetricData()
+{
+  SetArchitectureType(UNKNOWN);
+}
+
+void 
+PolarimetricData
+::DetermineArchitecture(bool *IsPresent)
+{
+
+  // With all the channels
+  if ( IsPresent[0] && IsPresent[1] && IsPresent[2] && IsPresent[3] )
+    {
+        SetArchitectureType(HH_HV_VH_VV);
+    }
+  else 
+  // With 3 channels : HH HV VV  
+  if ( IsPresent[0] && IsPresent[1] && !IsPresent[2] && IsPresent[3] )
+  {
+        SetArchitectureType( HH_HV_VV);  
+  }
+  else
+  // With 3 channels : HH VH VV
+  if ( IsPresent[0] && !IsPresent[1] && IsPresent[2] && IsPresent[3] )
+  {
+        SetArchitectureType(HH_VH_VV);
+  }
+  else    
+  // Only HH and HV are present
+  if ( IsPresent[0] && IsPresent[1] && !IsPresent[2] && !IsPresent[3] )
+    {
+        SetArchitectureType(HH_HV);
+  }    
+  else
+  // Only VH and VV are present
+  if ( !IsPresent[0] && !IsPresent[1] && IsPresent[2] && IsPresent[3] )
+  {
+        SetArchitectureType(VH_VV);
+  }
+  else
+  // Only HH and VV are present  
+  if ( IsPresent[0] && !IsPresent[1] && !IsPresent[2] && IsPresent[3] ) 
+  {
+       SetArchitectureType(HH_VV);
+  }
+  else
+  {
+       SetArchitectureType(UNKNOWN);
+  }
+}
+
+void 
+PolarimetricData
+::DetermineArchitecture(int NumberOfImages, bool EmissionH,bool EmissionV)
+{
+
+  switch(NumberOfImages)
+    {
+      case 4 :
+        SetArchitectureType(HH_HV_VH_VV);
+        break;
+        
+      case 3:
+        SetArchitectureType(HH_HV_VV);
+        break;
+
+      case 2 :
+        if (EmissionH && !EmissionV )
+          SetArchitectureType(HH_HV);
+        else if (!EmissionH && EmissionV )
+          SetArchitectureType(VH_VV);      
+        break;
+      
+      default:
+        itkExceptionMacro("Unknown architecture !");
+        return;
+    }           
+      
+}
+
+
+/**PrintSelf method */
+void 
+PolarimetricData
+::PrintSelf(std::ostream& os, itk::Indent indent) const
+{
+    os << indent << "ArchitectureType "<< m_ArchitectureType<< " : "<< std::endl;
+}
+
+} // end namespace otb
+
+#endif
+
diff --git a/Code/SARPolarimetry/otbPolarimetricData.h b/Code/SARPolarimetry/otbPolarimetricData.h
new file mode 100644
index 0000000000..9394a62ce2
--- /dev/null
+++ b/Code/SARPolarimetry/otbPolarimetricData.h
@@ -0,0 +1,91 @@
+/*=================g=======================================================
+
+  Program:   ORFEO Toolbox
+  Language:  C++
+  Date:      $Date$
+  Version:   $Revision$
+
+
+  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
+  See OTBCopyright.txt for details.
+
+
+     This software is distributed WITHOUT ANY WARRANTY; without even 
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+     PURPOSE.  See the above copyright notices for more information.
+
+=========================================================================*/
+#ifndef  _otb_PolarimetricData_h
+#define  _otb_PolarimetricData_h
+
+#include "itkDataObject.h"
+#include "itkObjectFactory.h"
+#include "otbMacro.h"
+
+namespace otb
+{
+/**
+ * This enumeration describes the different architectures we can find in polarimetry.
+ */
+ typedef enum {
+ HH_HV_VH_VV=0,
+ HH_HV_VV=1,
+ HH_VH_VV=2, 
+ HH_HV=3,
+ VH_VV=4,
+ HH_VV=5,
+ UNKNOWN=6} ArchitectureType;  
+ 
+ 
+ /** \class PolarimetricData
+ *  \brief This class allows to determine the type of architecture we get.
+ *
+ *
+ * \sa 
+ */
+
+class ITK_EXPORT PolarimetricData : public itk::DataObject
+{
+  public:
+ 
+  /** Standard typedefs */
+  typedef PolarimetricData                           Self;
+  typedef itk::DataObject                            Superclass;
+  typedef itk::SmartPointer<Self>                    Pointer;
+  typedef itk::SmartPointer<const Self>              ConstPointer;
+  
+  /** Type macro */
+  itkTypeMacro(PolarimetricData,DataObject);
+    
+  /** Creation through object factory macro */
+  itkNewMacro(Self);
+  
+  /** Determine the kind of architecture of the input */
+  void DetermineArchitecture(bool *PresentInputImages);
+  void DetermineArchitecture(int NumberOfImages, bool EmissionH,bool EmissionV);
+
+  /** Set/Get ArchitectureType */
+  itkSetMacro(ArchitectureType,ArchitectureType);
+  itkGetMacro(ArchitectureType,ArchitectureType);     
+  
+  protected:
+  /** Constructor */
+  PolarimetricData();
+  /** Destructor */
+  ~PolarimetricData(){};  
+  /**PrintSelf method */
+  void PrintSelf(std::ostream& os, itk::Indent indent) const;      
+
+  
+  private:
+  PolarimetricData(const Self&); //purposely not implemented
+  void operator=(const Self&); //purposely not implemented
+   
+  /** Architecture Type */
+  ArchitectureType m_ArchitectureType;
+
+};
+
+} // end namespace otb
+
+#endif
diff --git a/Code/SARPolarimetry/otbPolarimetricSynthesisFunctor.h b/Code/SARPolarimetry/otbPolarimetricSynthesisFunctor.h
new file mode 100644
index 0000000000..2713b07228
--- /dev/null
+++ b/Code/SARPolarimetry/otbPolarimetricSynthesisFunctor.h
@@ -0,0 +1,84 @@
+/*=========================================================================
+
+  Program:   ORFEO Toolbox
+  Language:  C++
+  Date:      $Date$
+  Version:   $Revision$
+
+
+  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
+  See OTBCopyright.txt for details.
+
+
+     This software is distributed WITHOUT ANY WARRANTY; without even 
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+     PURPOSE.  See the above copyright notices for more information.
+
+=========================================================================*/
+#ifndef __otbPolarimetricSynthesisFunctor_h
+#define __otbPolarimetricSynthesisFunctor_h
+#include "vcl_complex.h"
+
+namespace otb
+{
+namespace Functor
+  {
+    /** \class PolarimetricSynthesisFunctor
+     *  \brief This functor calculate the polarimetric synthesis
+     *  using the electroMagneticField vectors as follow:
+     *  $$ \sigma(\psi_{i},\chi_{i},\psi_{r},\chi_{r}) = 
+                       \vec(E_{r}}\cdot\left[ S \right] \vec(E_{i}}$$
+     *
+     *  \ingroup Functor
+     */
+    template <class TInput1, class TInput2, class TInput3, class TInput4, class TOutput>
+      class PolarimetricSynthesisFunctor
+      {
+      public:
+        /** Some typedefs. */
+        typedef typename     std::complex <double>       ComplexType;        
+        typedef typename     itk::FixedArray<ComplexType,2>    ComplexArrayType;        
+        
+        /** Set the ElectroMagneticField Incident */
+        void SetEi( ComplexArrayType ei ){
+                m_Ei = ei;
+        }
+        
+        /** Set the ElectroMagneticField Reflected */        
+        void SetEr( ComplexArrayType er ){
+                m_Er = er;
+        }
+               
+        /** Constructor */                  
+	PolarimetricSynthesisFunctor() 
+        {
+                m_Ei.Fill(1);
+                m_Er.Fill(1);
+        };
+        /** Destructor */        
+	virtual ~PolarimetricSynthesisFunctor() {};
+        inline TOutput operator()(const TInput1 &Shh, const TInput2 &Shv, const TInput3 &Svh, const TInput4 &Svv)
+	{
+                ComplexType tmp;
+                double scalar;
+
+                tmp = vcl_conj(m_Er[0])*( m_Ei[0]*Shh + m_Ei[1]*Shv ) + vcl_conj(m_Er[1])*( m_Ei[0]*Svh + m_Ei[1]*Svv );
+                
+                scalar=(double) ( vcl_pow( std::abs(tmp),2)  );
+                              
+                return ( static_cast<TOutput>(scalar) );
+        }
+      
+      private :
+        /** Electromagnetic Field Incident */
+        ComplexArrayType m_Ei;
+        /** Electromagnetic Field Reflected */
+        ComplexArrayType m_Er;         
+        
+      };
+
+  } // namespace Functor
+} // namespace otb
+
+#endif
+
-- 
GitLab