From 97b128de78fc6699c377501dcc3b0f7dc846cead Mon Sep 17 00:00:00 2001
From: Thomas Feuvrier <thomas.feuvrier@c-s.fr>
Date: Thu, 6 Jul 2006 18:33:04 +0000
Subject: [PATCH] Correction du CMakeLists.txt des tests de BasicFilters et
 ajout fichiers .cxx

---
 Testing/Code/BasicFilters/CMakeLists.txt      |   2 +
 .../BasicFilters/otbBasicFiltersTests.cxx     |   2 +
 Testing/Code/BasicFilters/otbFrostFilter.cxx  | 102 ------------------
 .../Code/BasicFilters/otbFrostFilterNew.cxx   |  61 +++++++++++
 .../Code/BasicFilters/otbFrostFilterTest.cxx  |  98 +++++++++++++++++
 5 files changed, 163 insertions(+), 102 deletions(-)
 create mode 100644 Testing/Code/BasicFilters/otbFrostFilterNew.cxx
 create mode 100644 Testing/Code/BasicFilters/otbFrostFilterTest.cxx

diff --git a/Testing/Code/BasicFilters/CMakeLists.txt b/Testing/Code/BasicFilters/CMakeLists.txt
index 8657431d3b..7668c174fc 100755
--- a/Testing/Code/BasicFilters/CMakeLists.txt
+++ b/Testing/Code/BasicFilters/CMakeLists.txt
@@ -51,6 +51,8 @@ ADD_TEST(bfTuImageToPointSetFilterTest ${BASICFILTERS_TESTS}
 # A enrichir
 SET(BasicFilters_SRCS
 otbLeeFilter.cxx
+otbFrostFilterTest.cxx
+otbFrostFilterNew.cxx
 otbFrostFilter.cxx
 otbImageToPointSetFilterTest.cxx
 )
diff --git a/Testing/Code/BasicFilters/otbBasicFiltersTests.cxx b/Testing/Code/BasicFilters/otbBasicFiltersTests.cxx
index f7ac480c1d..2bef373d7e 100755
--- a/Testing/Code/BasicFilters/otbBasicFiltersTests.cxx
+++ b/Testing/Code/BasicFilters/otbBasicFiltersTests.cxx
@@ -28,6 +28,8 @@
 void RegisterTests()
 {
 REGISTER_TEST(otbLeeFilter);
+REGISTER_TEST(otbFrostFilterNew);
+REGISTER_TEST(otbFrostFilterTest);
 REGISTER_TEST(otbFrostFilter);
 REGISTER_TEST(otbImageToPointSetFilterTest);
 }
diff --git a/Testing/Code/BasicFilters/otbFrostFilter.cxx b/Testing/Code/BasicFilters/otbFrostFilter.cxx
index 9e42ada37f..4150f7ed8d 100644
--- a/Testing/Code/BasicFilters/otbFrostFilter.cxx
+++ b/Testing/Code/BasicFilters/otbFrostFilter.cxx
@@ -19,8 +19,6 @@
 #pragma warning ( disable : 4786 )
 #endif
 
-//#define MAIN
-
 #include "otbImageFileReader.h"
 #include "otbFrostImageFilter.h"
 
@@ -31,106 +29,6 @@
 #include "itkMeanImageFilter.h"
 
 
-int otbFrostFilterNew( int argc, char ** argv )
-{
-  try 
-    { 
-        typedef unsigned char                                   InputPixelType;
-        typedef unsigned char   	                        OutputPixelType;
-        const   unsigned int        	                        Dimension = 2;
-
-        typedef itk::Image< InputPixelType,  Dimension >        InputImageType;
-        typedef itk::Image< OutputPixelType, Dimension >        OutputImageType;
-
-        typedef otb::FrostImageFilter< InputImageType,OutputImageType >   FilterType;
-
-        FilterType::Pointer frost = FilterType::New();
-    } 
-  catch( itk::ExceptionObject & err ) 
-    { 
-    std::cout << "Exception itk::ExceptionObject levee !" << std::endl; 
-    std::cout << err << std::endl; 
-    return EXIT_FAILURE;
-    } 
-  catch( ... ) 
-    { 
-    std::cout << "Exception levee inconnue !" << std::endl; 
-    return EXIT_FAILURE;
-    } 
-
-  return EXIT_SUCCESS;
-}
-
-
-int otbFrostFilterTest( int argc, char ** argv )
-{
-
-  typedef itk::Image<float,2> FloatImage2DType;
-
-  itk::RandomImageSource<FloatImage2DType>::Pointer random;
-  random = itk::RandomImageSource<FloatImage2DType>::New();
-  random->SetMin(0.0);
-  random->SetMax(1000.0);
-
-  unsigned long randomSize[2];
-  randomSize[0] = randomSize[1] = 8;
-  random->SetSize(randomSize);
-  
-  float spacing[2] = {0.7, 2.1};
-  random->SetSpacing( spacing );
-  float origin[2] = {15, 400};
-  random->SetOrigin( origin );
-    
-  // Create a mean image
-  otb::FrostImageFilter<FloatImage2DType, FloatImage2DType>::Pointer frost;
-  frost = otb::FrostImageFilter<FloatImage2DType,FloatImage2DType>::New();
-  frost->SetInput(random->GetOutput());
-
-  // define the neighborhood size used for the mean filter (5x5)
-  FloatImage2DType::SizeType neighRadius;
-  neighRadius[0] = 1;
-  neighRadius[1] = 1;
-  frost->SetRadius(neighRadius);
-
-  // run the algorithm
-  frost->Update();
-
-  itk::ImageRegionIterator<FloatImage2DType> it;
-  it = itk::ImageRegionIterator<FloatImage2DType>(random->GetOutput(),
-                               random->GetOutput()->GetBufferedRegion());
-  std::cout << "Input image" << std::endl;
-  unsigned int i;
-  for (i=1; !it.IsAtEnd(); ++i, ++it)
-    {
-    std::cout << "\t" << it.Get();
-    if ((i % 8) == 0)
-      {
-      std::cout << std::endl;
-      }
-    }
-
-  std::cout << "Output image" << std::endl;
-  it = itk::ImageRegionIterator<FloatImage2DType>(frost->GetOutput(),
-                               frost->GetOutput()->GetBufferedRegion());
-  for (i=1; !it.IsAtEnd(); ++i, ++it)
-    {
-    std::cout << "\t" << it.Get();
-    if ((i % 8) == 0)
-      {
-      std::cout << std::endl;
-      }
-    }
-  
-  // Test the itkGetConstReferenceMacro
-  const FloatImage2DType::SizeType & radius = frost->GetRadius();
-  std::cout << "frost->GetRadius():" << radius << std::endl;
-
-  return EXIT_SUCCESS;
-
-}
-
-
-
 int otbFrostFilter( int argc, char ** argv )
 {
   try 
diff --git a/Testing/Code/BasicFilters/otbFrostFilterNew.cxx b/Testing/Code/BasicFilters/otbFrostFilterNew.cxx
new file mode 100644
index 0000000000..fca26053a1
--- /dev/null
+++ b/Testing/Code/BasicFilters/otbFrostFilterNew.cxx
@@ -0,0 +1,61 @@
+/*=========================================================================
+
+  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.
+
+=========================================================================*/
+#if defined(_MSC_VER)
+#pragma warning ( disable : 4786 )
+#endif
+
+#include "otbImageFileReader.h"
+#include "otbFrostImageFilter.h"
+
+#include "itkExceptionObject.h"
+#include "itkImageFileWriter.h"
+#include "itkImage.h"
+#include "itkRandomImageSource.h"
+#include "itkMeanImageFilter.h"
+
+
+int otbFrostFilterNew( int argc, char ** argv )
+{
+  try 
+    { 
+        typedef unsigned char                                   InputPixelType;
+        typedef unsigned char   	                        OutputPixelType;
+        const   unsigned int        	                        Dimension = 2;
+
+        typedef itk::Image< InputPixelType,  Dimension >        InputImageType;
+        typedef itk::Image< OutputPixelType, Dimension >        OutputImageType;
+
+        typedef otb::FrostImageFilter< InputImageType,OutputImageType >   FilterType;
+
+        FilterType::Pointer frost = FilterType::New();
+    } 
+  catch( itk::ExceptionObject & err ) 
+    { 
+    std::cout << "Exception itk::ExceptionObject levee !" << std::endl; 
+    std::cout << err << std::endl; 
+    return EXIT_FAILURE;
+    } 
+  catch( ... ) 
+    { 
+    std::cout << "Exception levee inconnue !" << std::endl; 
+    return EXIT_FAILURE;
+    } 
+
+  return EXIT_SUCCESS;
+}
+
diff --git a/Testing/Code/BasicFilters/otbFrostFilterTest.cxx b/Testing/Code/BasicFilters/otbFrostFilterTest.cxx
new file mode 100644
index 0000000000..bde1bef858
--- /dev/null
+++ b/Testing/Code/BasicFilters/otbFrostFilterTest.cxx
@@ -0,0 +1,98 @@
+/*=========================================================================
+
+  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.
+
+=========================================================================*/
+#if defined(_MSC_VER)
+#pragma warning ( disable : 4786 )
+#endif
+
+#include "otbImageFileReader.h"
+#include "otbFrostImageFilter.h"
+
+#include "itkExceptionObject.h"
+#include "itkImageFileWriter.h"
+#include "itkImage.h"
+#include "itkRandomImageSource.h"
+#include "itkMeanImageFilter.h"
+
+
+int otbFrostFilterTest( int argc, char ** argv )
+{
+
+  typedef itk::Image<float,2> FloatImage2DType;
+
+  itk::RandomImageSource<FloatImage2DType>::Pointer random;
+  random = itk::RandomImageSource<FloatImage2DType>::New();
+  random->SetMin(0.0);
+  random->SetMax(1000.0);
+
+  unsigned long randomSize[2];
+  randomSize[0] = randomSize[1] = 8;
+  random->SetSize(randomSize);
+  
+  float spacing[2] = {0.7, 2.1};
+  random->SetSpacing( spacing );
+  float origin[2] = {15, 400};
+  random->SetOrigin( origin );
+    
+  // Create a mean image
+  otb::FrostImageFilter<FloatImage2DType, FloatImage2DType>::Pointer frost;
+  frost = otb::FrostImageFilter<FloatImage2DType,FloatImage2DType>::New();
+  frost->SetInput(random->GetOutput());
+
+  // define the neighborhood size used for the mean filter (5x5)
+  FloatImage2DType::SizeType neighRadius;
+  neighRadius[0] = 1;
+  neighRadius[1] = 1;
+  frost->SetRadius(neighRadius);
+
+  // run the algorithm
+  frost->Update();
+
+  itk::ImageRegionIterator<FloatImage2DType> it;
+  it = itk::ImageRegionIterator<FloatImage2DType>(random->GetOutput(),
+                               random->GetOutput()->GetBufferedRegion());
+  std::cout << "Input image" << std::endl;
+  unsigned int i;
+  for (i=1; !it.IsAtEnd(); ++i, ++it)
+    {
+    std::cout << "\t" << it.Get();
+    if ((i % 8) == 0)
+      {
+      std::cout << std::endl;
+      }
+    }
+
+  std::cout << "Output image" << std::endl;
+  it = itk::ImageRegionIterator<FloatImage2DType>(frost->GetOutput(),
+                               frost->GetOutput()->GetBufferedRegion());
+  for (i=1; !it.IsAtEnd(); ++i, ++it)
+    {
+    std::cout << "\t" << it.Get();
+    if ((i % 8) == 0)
+      {
+      std::cout << std::endl;
+      }
+    }
+  
+  // Test the itkGetConstReferenceMacro
+  const FloatImage2DType::SizeType & radius = frost->GetRadius();
+  std::cout << "frost->GetRadius():" << radius << std::endl;
+
+  return EXIT_SUCCESS;
+
+}
+
-- 
GitLab