From f6ec1a4413cfcccaa23f992b805c160d8572dc7a Mon Sep 17 00:00:00 2001
From: Julien Michel <julien.michel@c-s.fr>
Date: Fri, 24 Nov 2006 16:46:13 +0000
Subject: [PATCH] Ajout du filtre de base ImageListToImageListFilter

---
 Code/Common/otbImageListToImageListFilter.h   | 83 +++++++++++++++++++
 Code/Common/otbImageListToImageListFilter.txx | 76 +++++++++++++++++
 .../otbImageListToImageListFilterNew.cxx      | 52 ++++++++++++
 3 files changed, 211 insertions(+)
 create mode 100644 Code/Common/otbImageListToImageListFilter.h
 create mode 100644 Code/Common/otbImageListToImageListFilter.txx
 create mode 100644 Testing/Code/Common/otbImageListToImageListFilterNew.cxx

diff --git a/Code/Common/otbImageListToImageListFilter.h b/Code/Common/otbImageListToImageListFilter.h
new file mode 100644
index 0000000000..e8d8a9fad5
--- /dev/null
+++ b/Code/Common/otbImageListToImageListFilter.h
@@ -0,0 +1,83 @@
+/*=========================================================================
+
+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 _otbImageListToImageListFilter_h
+#define _otbImageListToImageListFilter_h
+
+#include "otbImageListSource.h"
+
+namespace otb 
+{
+/** \class ImageListSource
+ *  \brief Base class for all the filters taking an image list as input 
+ *  to produce an image list.
+ * \ingroup Images
+ * \ingroup Lists
+ */
+template <class TInputImage, class TOutputImage>
+class ITK_EXPORT ImageListToImageListFilter
+  : public ImageListSource<TOutputImage>
+{
+public:
+  /** Standard typedefs */
+  typedef ImageListToImageListFilter            Self;
+  typedef ImageListSource<TOutputImage>     Superclass;
+  typedef itk::SmartPointer<Self>           Pointer;
+  typedef itk::SmartPointer<const Self>     ConstPointer;
+  /** Type macro */
+  itkNewMacro(Self);
+  /** Creation through object factory macro */
+  itkTypeMacro(ImageListToImageListFilter, ImageListSource);
+  /** Template parameters typedefs */
+  typedef          TInputImage                    InputImageType;
+  typedef typename InputImageType::ConstPointer   InputImagePointer;
+  typedef typename InputImageType::RegionType     InputImageRegionType;
+  typedef typename InputImageType::PixelType      InputImagePixelType;
+  typedef typename InputImageType::SizeType       SizeType;
+  typedef typename InputImageType::ValueType      ValueType;
+  typedef ImageList<InputImageType>               InputImageListType;
+  typedef typename InputImageListType::Pointer    InputImageListPointerType;
+  typedef typename InputImageListType::ConstPointer InputImageListConstPointer;
+  /** Derived typedefs */
+  typedef typename Superclass::OutputImageType         OutputImageType;
+  typedef typename Superclass::OutputImageListType     OutputImageListType;
+  typedef typename Superclass::OutputImageListPointerType OutputImageListPointerType;
+  typedef typename Superclass::OutputImagePointerType  OutputImagePointer;
+  /** InputImage dimension constant */
+  itkStaticConstMacro(InputImageDimension, unsigned int,TInputImage::ImageDimension);
+  /** Overiding the SetInput() and GetInput() methods */
+  virtual void SetInput( const InputImageListType * imageList);
+  virtual InputImageListType * GetInput(void);
+
+protected:
+  /** Constructor */
+  ImageListToImageListFilter();
+  /** Destructor */
+  virtual ~ImageListToImageListFilter() {};
+ /**PrintSelf method */
+  virtual void PrintSelf(std::ostream& os, itk::Indent indent) const;
+
+private:
+  ImageListToImageListFilter(const Self&); //purposely not implemented
+  void operator=(const Self&); //purposely not implemented
+};
+}// End namespace otb
+#ifndef OTB_MANUAL_INSTANTIATION
+#include "otbImageListToImageListFilter.txx"
+#endif
+
+#endif
diff --git a/Code/Common/otbImageListToImageListFilter.txx b/Code/Common/otbImageListToImageListFilter.txx
new file mode 100644
index 0000000000..5426d3022d
--- /dev/null
+++ b/Code/Common/otbImageListToImageListFilter.txx
@@ -0,0 +1,76 @@
+/*=========================================================================
+
+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 _otbImageListToImageListFilter_txx
+#define _otbImageListToImageListFilter_txx
+
+#include "otbImageListToImageListFilter.h"
+
+namespace otb
+{
+/**
+ * Constructor
+ */
+template <class TInputImage, class TOutputImage>
+ImageListToImageListFilter<TInputImage,TOutputImage>
+::ImageListToImageListFilter()
+{
+  this->SetNumberOfRequiredInputs(1);
+}
+/**
+ * Input Connection 
+ * \param image The input image.
+ */
+template <class TInputImage, class TOutputImage>
+void
+ImageListToImageListFilter<TInputImage,TOutputImage>
+::SetInput(const InputImageListType *imageList)
+{
+  // A single input image
+  this->itk::ProcessObject::SetNthInput(0,const_cast<InputImageListType*>(imageList));
+}
+/**
+ * Input image retrieval 
+ * \return The input image.
+ */
+template <class TInputImage, class TOutputImage>
+typename ImageListToImageListFilter<TInputImage,TOutputImage>::InputImageListType *
+ImageListToImageListFilter<TInputImage,TOutputImage>
+::GetInput(void)
+{
+  // If there is no input 
+  if (this->GetNumberOfInputs()<1)
+    {
+    // exit
+    return 0;
+    }
+  // else return the first input
+  return static_cast<InputImageListType * >
+    (this->itk::ProcessObject::GetInput(0) );
+}
+/**
+ * PrintSelf Method
+ */
+template <class TInputImage, class TOutputImage>
+void
+ImageListToImageListFilter<TInputImage,TOutputImage>
+::PrintSelf(std::ostream& os, itk::Indent indent) const
+{
+  Superclass::PrintSelf(os, indent);
+}
+} // End namespace otb
+#endif
diff --git a/Testing/Code/Common/otbImageListToImageListFilterNew.cxx b/Testing/Code/Common/otbImageListToImageListFilterNew.cxx
new file mode 100644
index 0000000000..303c4f685c
--- /dev/null
+++ b/Testing/Code/Common/otbImageListToImageListFilterNew.cxx
@@ -0,0 +1,52 @@
+/*=========================================================================
+
+  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.
+
+=========================================================================*/
+#include "itkExceptionObject.h"
+
+#include "otbImageListToImageListFilter.h"
+#include "otbImage.h"
+
+int otbImageListToImageListFilterNew(int argc, char * argv[])
+{
+  try
+    {
+      const unsigned int Dimension = 2;
+      typedef unsigned char InputPixelType;
+      typedef unsigned char OutputPixelType;
+      typedef otb::Image<InputPixelType,Dimension> InputImageType;
+      typedef otb::Image<OutputPixelType,Dimension> OutputImageType;
+      typedef otb::ImageListToImageListFilter<InputImageType,OutputImageType> ImageToImageListFilterType;
+
+      // Instantiating ImageListSource object
+      ImageToImageListFilterType::Pointer imageList = ImageToImageListFilterType::New();
+    }
+
+  catch( itk::ExceptionObject & err ) 
+    { 
+    std::cout << "Exception itk::ExceptionObject thrown !" << std::endl; 
+    std::cout << err << std::endl; 
+    return EXIT_FAILURE;
+    } 
+
+  catch( ... ) 
+    { 
+    std::cout << "Unknown exception thrown !" << std::endl; 
+    return EXIT_FAILURE;
+    } 
+
+  return EXIT_SUCCESS;
+}
-- 
GitLab