From ae8ff2982a9701b99c437da32de30e20afbfd339 Mon Sep 17 00:00:00 2001 From: Cyrille Valladeau <cyrille.valladeau@c-s.fr> Date: Tue, 9 Sep 2008 08:04:44 +0000 Subject: [PATCH] STYLE : try/catch blocs supression in visu testing. --- Testing/Code/Visu/otbAlternateViewerTest.cxx | 52 +++++--- .../Visu/otbDoubleImageViewerWithLink.cxx | 89 ++++++------- .../Code/Visu/otbFixedSizeFullImageWidget.cxx | 121 ++++++++--------- .../Visu/otbFixedSizeFullImageWidgetNew.cxx | 25 +--- .../Visu/otbFullResolutionImageWidget.cxx | 118 ++++++++-------- .../Visu/otbFullResolutionImageWidgetNew.cxx | 25 +--- ...otbImageToGrayscaleAnaglyphImageFilter.cxx | 62 ++++----- ...ImageToGrayscaleAnaglyphImageFilterNew.cxx | 35 ++--- Testing/Code/Visu/otbImageViewer.cxx | 60 ++++----- Testing/Code/Visu/otbImageViewerNew.cxx | 25 +--- .../otbImageViewerWithMultiBandFilter.cxx | 75 +++++------ .../Code/Visu/otbImageViewerWithOtbImage.cxx | 50 +++---- Testing/Code/Visu/otbImageWidgetBaseNew.cxx | 23 +--- ...rImageToColorAnaglyphVectorImageFilter.cxx | 51 +++---- ...ageToColorAnaglyphVectorImageFilterNew.cxx | 33 ++--- Testing/Code/Visu/otbZoomableImageWidget.cxx | 126 ++++++++---------- 16 files changed, 388 insertions(+), 582 deletions(-) diff --git a/Testing/Code/Visu/otbAlternateViewerTest.cxx b/Testing/Code/Visu/otbAlternateViewerTest.cxx index 7e2d99aedb..b10b64eafb 100644 --- a/Testing/Code/Visu/otbAlternateViewerTest.cxx +++ b/Testing/Code/Visu/otbAlternateViewerTest.cxx @@ -1,3 +1,21 @@ +/*========================================================================= + +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 "otbVectorImage.h" #include "otbVectorRescaleIntensityImageFilter.h" #include "otbImageFileReader.h" @@ -7,7 +25,7 @@ int otbAlternateViewerTest(int argc, char* argv[]) { - const unsigned int Dimension = 2; + const unsigned int Dimension = 2; typedef double PixelType; typedef otb::VectorImage<PixelType,Dimension> ImageType; typedef otb::ImageFileReader<ImageType> ReaderType; @@ -24,23 +42,23 @@ int otbAlternateViewerTest(int argc, char* argv[]) ImageType::PixelType min,max; min.SetSize(reader->GetOutput()->GetNumberOfComponentsPerPixel()); max.SetSize(reader->GetOutput()->GetNumberOfComponentsPerPixel()); -// min[0]=195; -// min[1]=241; -// min[2]=127; -// min[3]=130; -// max[0]=387; -// max[1]=602; -// max[2]=469; -// max[3]=740; - min.Fill(0); - max.Fill(255); + // min[0]=195; + // min[1]=241; + // min[2]=127; + // min[3]=130; + // max[0]=387; + // max[1]=602; + // max[2]=469; + // max[3]=740; + min.Fill(0); + max.Fill(255); - // RescalerType::Pointer rescaler = RescalerType::New(); -// rescaler->SetOutputMinimum(min); -// rescaler->SetOutputMaximum(max); -// rescaler->SetInput(reader->GetOutput()); -// rescaler->SetClampThreshold(atof(argv[2])); -// rescaler->GenerateOutputInformation(); + // RescalerType::Pointer rescaler = RescalerType::New(); + // rescaler->SetOutputMinimum(min); + // rescaler->SetOutputMaximum(max); + // rescaler->SetInput(reader->GetOutput()); + // rescaler->SetClampThreshold(atof(argv[2])); + // rescaler->GenerateOutputInformation(); Fl_Window window(512,512); ViewerType::Pointer viewer = ViewerType::New(); diff --git a/Testing/Code/Visu/otbDoubleImageViewerWithLink.cxx b/Testing/Code/Visu/otbDoubleImageViewerWithLink.cxx index 6dffc7e658..7d27c61f91 100644 --- a/Testing/Code/Visu/otbDoubleImageViewerWithLink.cxx +++ b/Testing/Code/Visu/otbDoubleImageViewerWithLink.cxx @@ -22,64 +22,51 @@ int otbDoubleImageViewerWithLink( int argc, char * argv[] ) { - try - { - char * filename1 = argv[1]; - char * filename2 = argv[2]; + char * filename1 = argv[1]; + char * filename2 = argv[2]; - // Parse command line parameters - typedef double PixelType; - typedef otb::ImageViewer<PixelType> ImageViewerType; - typedef ImageViewerType::OffsetType OffsetType; - typedef ImageViewerType::ImageType ImageType; - typedef otb::ImageFileReader<ImageType> ReaderType; + // Parse command line parameters + typedef double PixelType; + typedef otb::ImageViewer<PixelType> ImageViewerType; + typedef ImageViewerType::OffsetType OffsetType; + typedef ImageViewerType::ImageType ImageType; + typedef otb::ImageFileReader<ImageType> ReaderType; - // instantiation - ImageViewerType::Pointer viewer1 = ImageViewerType::New(); - ImageViewerType::Pointer viewer2 = ImageViewerType::New(); + // instantiation + ImageViewerType::Pointer viewer1 = ImageViewerType::New(); + ImageViewerType::Pointer viewer2 = ImageViewerType::New(); - // check for input images - ReaderType::Pointer reader1 = ReaderType::New(); - reader1->SetFileName(filename1); - reader1->GenerateOutputInformation(); - viewer1->SetImage(reader1->GetOutput()); + // check for input images + ReaderType::Pointer reader1 = ReaderType::New(); + reader1->SetFileName(filename1); + reader1->GenerateOutputInformation(); + viewer1->SetImage(reader1->GetOutput()); - ReaderType::Pointer reader2 = ReaderType::New(); - reader2->SetFileName(filename2); - reader2->GenerateOutputInformation(); - viewer2->SetImage(reader2->GetOutput()); + ReaderType::Pointer reader2 = ReaderType::New(); + reader2->SetFileName(filename2); + reader2->GenerateOutputInformation(); + viewer2->SetImage(reader2->GetOutput()); - // CASE 1: Simple link - viewer1->Link(viewer2); - viewer1->Show(); - viewer2->Show(); - Fl::check(); + // CASE 1: Simple link + viewer1->Link(viewer2); + viewer1->Show(); + viewer2->Show(); + Fl::check(); - // CASE 2: Unlink - viewer1->Unlink(viewer2); - viewer1->Show(); - viewer2->Show(); - Fl::check(); + // CASE 2: Unlink + viewer1->Unlink(viewer2); + viewer1->Show(); + viewer2->Show(); + Fl::check(); + + // CASE 3: Link with Offset + OffsetType offset; + offset.Fill(50); + viewer2->Link(viewer1,offset); + viewer1->Show(); + viewer2->Show(); + Fl::check(); - // CASE 3: Link with Offset - OffsetType offset; - offset.Fill(50); - viewer2->Link(viewer1,offset); - viewer1->Show(); - viewer2->Show(); - Fl::check(); - } - 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/Visu/otbFixedSizeFullImageWidget.cxx b/Testing/Code/Visu/otbFixedSizeFullImageWidget.cxx index a1115cf41d..828bc7d3a2 100644 --- a/Testing/Code/Visu/otbFixedSizeFullImageWidget.cxx +++ b/Testing/Code/Visu/otbFixedSizeFullImageWidget.cxx @@ -22,80 +22,65 @@ PURPOSE. See the above copyright notices for more information. int otbFixedSizeFullImageWidget( int argc, char * argv[] ) { - try - { - char * filename = argv[1]; - typedef float PixelType; - typedef otb::FixedSizeFullImageWidget<PixelType> WidgetType; - typedef WidgetType::ImageType ImageType; - typedef otb::ImageFileReader<ImageType> ReaderType; + char * filename = argv[1]; + typedef float PixelType; + typedef otb::FixedSizeFullImageWidget<PixelType> WidgetType; + typedef WidgetType::ImageType ImageType; + typedef otb::ImageFileReader<ImageType> ReaderType; - ReaderType::Pointer reader = ReaderType::New(); - ImageType::SizeType size; - ImageType::IndexType index; - ImageType::RegionType region; + ReaderType::Pointer reader = ReaderType::New(); + ImageType::SizeType size; + ImageType::IndexType index; + ImageType::RegionType region; - index[0]=0; - index[1]=0; - size[0]=1; - size[1]=1; - reader->SetFileName(filename); - reader->Update(); + index[0]=0; + index[1]=0; + size[0]=1; + size[1]=1; + reader->SetFileName(filename); + reader->Update(); - Fl_Window window(size[0],size[1]); + Fl_Window window(size[0],size[1]); - WidgetType::Pointer widget = WidgetType::New(); - window.resizable(widget.GetPointer()); - widget->SetInput(reader->GetOutput()); - if(reader->GetOutput()->GetNumberOfComponentsPerPixel()>=3) - { - widget->SetViewModel(WidgetType::RGB); - } - else - { - widget->SetViewModel(WidgetType::GRAYSCALE); - } - widget->Init(0,0,size[0],size[1],"Test Full Image Widget"); - widget->redraw(); - window.end(); - window.show(); - window.show(); - widget->Show(); - widget->redraw(); - Fl::check(); + WidgetType::Pointer widget = WidgetType::New(); + window.resizable(widget.GetPointer()); + widget->SetInput(reader->GetOutput()); + if(reader->GetOutput()->GetNumberOfComponentsPerPixel()>=3) + { + widget->SetViewModel(WidgetType::RGB); + } + else + { + widget->SetViewModel(WidgetType::GRAYSCALE); + } + widget->Init(0,0,size[0],size[1],"Test Full Image Widget"); + widget->redraw(); + window.end(); + window.show(); + window.show(); + widget->Show(); + widget->redraw(); + Fl::check(); - for(int i = 0;i<=400;i+=40) - { - Fl::check(); - window.resize(0,0,i,i); - Fl::wait(0.2); - Fl::check(); - } + for(int i = 0;i<=400;i+=40) + { + Fl::check(); + window.resize(0,0,i,i); + Fl::wait(0.2); + Fl::check(); + } - for(int i = 400;i>=0;i-=40) - { - Fl::check(); - window.resize(0,0,i,i); - Fl::wait(0.2); - Fl::check(); - } - // suppres child, without delete memory. - // delete memory is ITK respoability, since WidgetType::New() - window.remove(widget.GetPointer()); - } - - 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; - } - + for(int i = 400;i>=0;i-=40) + { + Fl::check(); + window.resize(0,0,i,i); + Fl::wait(0.2); + Fl::check(); + } + // suppres child, without delete memory. + // delete memory is ITK respoability, since WidgetType::New() + window.remove(widget.GetPointer()); + return EXIT_SUCCESS; } diff --git a/Testing/Code/Visu/otbFixedSizeFullImageWidgetNew.cxx b/Testing/Code/Visu/otbFixedSizeFullImageWidgetNew.cxx index 332cd27965..262d09a1ce 100644 --- a/Testing/Code/Visu/otbFixedSizeFullImageWidgetNew.cxx +++ b/Testing/Code/Visu/otbFixedSizeFullImageWidgetNew.cxx @@ -19,26 +19,11 @@ PURPOSE. See the above copyright notices for more information. int otbFixedSizeFullImageWidgetNew( int argc, char * argv[] ) { - try - { - typedef float PixelType; - typedef otb::FixedSizeFullImageWidget<PixelType> WidgetType; - - WidgetType::Pointer widget = WidgetType::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; - } - + typedef float PixelType; + typedef otb::FixedSizeFullImageWidget<PixelType> WidgetType; + + WidgetType::Pointer widget = WidgetType::New(); + return EXIT_SUCCESS; } diff --git a/Testing/Code/Visu/otbFullResolutionImageWidget.cxx b/Testing/Code/Visu/otbFullResolutionImageWidget.cxx index d41e38f98f..e282d08b8e 100644 --- a/Testing/Code/Visu/otbFullResolutionImageWidget.cxx +++ b/Testing/Code/Visu/otbFullResolutionImageWidget.cxx @@ -22,78 +22,64 @@ PURPOSE. See the above copyright notices for more information. int otbFullResolutionImageWidget( int argc, char * argv[] ) { - try - { - char * filename = argv[1]; - typedef float PixelType; - typedef otb::FullResolutionImageWidget<PixelType> WidgetType; - typedef WidgetType::ImageType ImageType; - typedef otb::ImageFileReader<ImageType> ReaderType; + char * filename = argv[1]; + typedef float PixelType; + typedef otb::FullResolutionImageWidget<PixelType> WidgetType; + typedef WidgetType::ImageType ImageType; + typedef otb::ImageFileReader<ImageType> ReaderType; - ReaderType::Pointer reader = ReaderType::New(); - ImageType::SizeType size; - ImageType::IndexType index; - ImageType::RegionType region; + ReaderType::Pointer reader = ReaderType::New(); + ImageType::SizeType size; + ImageType::IndexType index; + ImageType::RegionType region; - index[0]=0; - index[1]=0; - size[0]=1; - size[1]=1; - reader->SetFileName(filename); - reader->Update(); + index[0]=0; + index[1]=0; + size[0]=1; + size[1]=1; + reader->SetFileName(filename); + reader->Update(); - Fl_Window window(size[0],size[1]); + Fl_Window window(size[0],size[1]); - WidgetType::Pointer widget = WidgetType::New(); - window.resizable(widget.GetPointer()); - widget->SetInput(reader->GetOutput()); - if(reader->GetOutput()->GetNumberOfComponentsPerPixel()>=3) - widget->SetViewModel(WidgetType::RGB); - else - widget->SetViewModel(WidgetType::GRAYSCALE); - widget->SetUpperLeftCorner(index); - widget->Init(0,0,size[0],size[1],"Test Full Resolution Widget"); - widget->redraw(); - window.end(); - window.show(); - window.show(); - widget->Show(); - widget->redraw(); - Fl::check(); + WidgetType::Pointer widget = WidgetType::New(); + window.resizable(widget.GetPointer()); + widget->SetInput(reader->GetOutput()); + if(reader->GetOutput()->GetNumberOfComponentsPerPixel()>=3) + widget->SetViewModel(WidgetType::RGB); + else + widget->SetViewModel(WidgetType::GRAYSCALE); + widget->SetUpperLeftCorner(index); + widget->Init(0,0,size[0],size[1],"Test Full Resolution Widget"); + widget->redraw(); + window.end(); + window.show(); + window.show(); + widget->Show(); + widget->redraw(); + Fl::check(); - int StepX =(reader->GetOutput()->GetLargestPossibleRegion().GetSize()[0]-size[0])/100; - int StepY =(reader->GetOutput()->GetLargestPossibleRegion().GetSize()[1]-size[1])/100; - for(int i = 0;i<=100;i+=5) - { - Fl::check(); - window.resize(0,0,size[0]+i*StepX,size[1]+i*StepY); - Fl::wait(0.2); - Fl::check(); - } + int StepX =(reader->GetOutput()->GetLargestPossibleRegion().GetSize()[0]-size[0])/100; + int StepY =(reader->GetOutput()->GetLargestPossibleRegion().GetSize()[1]-size[1])/100; + for(int i = 0;i<=100;i+=5) + { + Fl::check(); + window.resize(0,0,size[0]+i*StepX,size[1]+i*StepY); + Fl::wait(0.2); + Fl::check(); + } - for(int i = 100;i>=0;i-=5) - { - Fl::check(); - window.resize(0,0,size[0]+i*StepX,size[1]+i*StepY); - Fl::wait(0.2); - Fl::check(); - } - // suppres child, without delete memory. - // delete memory is ITK respoability, since WidgetType::New() - window.remove(widget.GetPointer()); - } - - 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; - } + for(int i = 100;i>=0;i-=5) + { + Fl::check(); + window.resize(0,0,size[0]+i*StepX,size[1]+i*StepY); + Fl::wait(0.2); + Fl::check(); + } + // suppres child, without delete memory. + // delete memory is ITK respoability, since WidgetType::New() + window.remove(widget.GetPointer()); + return EXIT_SUCCESS; diff --git a/Testing/Code/Visu/otbFullResolutionImageWidgetNew.cxx b/Testing/Code/Visu/otbFullResolutionImageWidgetNew.cxx index 0dd20fe47f..f496dcbf71 100644 --- a/Testing/Code/Visu/otbFullResolutionImageWidgetNew.cxx +++ b/Testing/Code/Visu/otbFullResolutionImageWidgetNew.cxx @@ -19,26 +19,11 @@ PURPOSE. See the above copyright notices for more information. int otbFullResolutionImageWidgetNew( int argc, char * argv[] ) { - try - { - typedef float PixelType; - typedef otb::FullResolutionImageWidget<PixelType> WidgetType; - - WidgetType::Pointer widget = WidgetType::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; - } - + typedef float PixelType; + typedef otb::FullResolutionImageWidget<PixelType> WidgetType; + + WidgetType::Pointer widget = WidgetType::New(); + return EXIT_SUCCESS; } diff --git a/Testing/Code/Visu/otbImageToGrayscaleAnaglyphImageFilter.cxx b/Testing/Code/Visu/otbImageToGrayscaleAnaglyphImageFilter.cxx index da0feb9bc4..da1a47f5be 100644 --- a/Testing/Code/Visu/otbImageToGrayscaleAnaglyphImageFilter.cxx +++ b/Testing/Code/Visu/otbImageToGrayscaleAnaglyphImageFilter.cxx @@ -25,44 +25,30 @@ int otbImageToGrayscaleAnaglyphImageFilter(int argc, char * argv[]) { - try - { - const unsigned int Dimension = 2; - typedef double PixelType; + const unsigned int Dimension = 2; + typedef double PixelType; + + typedef otb::Image<PixelType,Dimension> ImageType; + typedef otb::VectorImage<PixelType,Dimension> VectorImageType; + typedef otb::ImageToGrayscaleAnaglyphImageFilter<ImageType,ImageType,VectorImageType> FilterType; + typedef otb::ImageFileReader<ImageType> ReaderType; + typedef otb::StreamingImageFileWriter<VectorImageType> WriterType; + + // Instantiating object + FilterType::Pointer filter = FilterType::New(); + ReaderType::Pointer reader1 = ReaderType::New(); + ReaderType::Pointer reader2 = ReaderType::New(); + WriterType::Pointer writer = WriterType::New(); + + reader1->SetFileName(argv[1]); + reader2->SetFileName(argv[2]); + writer->SetFileName(argv[3]); + + filter->SetInput1(reader1->GetOutput()); + filter->SetInput2(reader2->GetOutput()); + writer->SetInput(filter->GetOutput()); + writer->Update(); + - typedef otb::Image<PixelType,Dimension> ImageType; - typedef otb::VectorImage<PixelType,Dimension> VectorImageType; - typedef otb::ImageToGrayscaleAnaglyphImageFilter<ImageType,ImageType,VectorImageType> FilterType; - typedef otb::ImageFileReader<ImageType> ReaderType; - typedef otb::StreamingImageFileWriter<VectorImageType> WriterType; - - // Instantiating object - FilterType::Pointer filter = FilterType::New(); - ReaderType::Pointer reader1 = ReaderType::New(); - ReaderType::Pointer reader2 = ReaderType::New(); - WriterType::Pointer writer = WriterType::New(); - - reader1->SetFileName(argv[1]); - reader2->SetFileName(argv[2]); - writer->SetFileName(argv[3]); - - filter->SetInput1(reader1->GetOutput()); - filter->SetInput2(reader2->GetOutput()); - writer->SetInput(filter->GetOutput()); - writer->Update(); - } - - 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; } diff --git a/Testing/Code/Visu/otbImageToGrayscaleAnaglyphImageFilterNew.cxx b/Testing/Code/Visu/otbImageToGrayscaleAnaglyphImageFilterNew.cxx index 00f77151ba..edd576f060 100644 --- a/Testing/Code/Visu/otbImageToGrayscaleAnaglyphImageFilterNew.cxx +++ b/Testing/Code/Visu/otbImageToGrayscaleAnaglyphImageFilterNew.cxx @@ -23,30 +23,15 @@ int otbImageToGrayscaleAnaglyphImageFilterNew(int argc, char * argv[]) { - try - { - const unsigned int Dimension = 2; - typedef unsigned char PixelType; - - typedef otb::Image<PixelType,Dimension> ImageType; - typedef otb::VectorImage<PixelType,Dimension> VectorImageType; - typedef otb::ImageToGrayscaleAnaglyphImageFilter<ImageType,ImageType,VectorImageType> FilterType; - - // Instantiating object - FilterType::Pointer object = FilterType::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; - } + const unsigned int Dimension = 2; + typedef unsigned char PixelType; + + typedef otb::Image<PixelType,Dimension> ImageType; + typedef otb::VectorImage<PixelType,Dimension> VectorImageType; + typedef otb::ImageToGrayscaleAnaglyphImageFilter<ImageType,ImageType,VectorImageType> FilterType; + + // Instantiating object + FilterType::Pointer object = FilterType::New(); + return EXIT_SUCCESS; } diff --git a/Testing/Code/Visu/otbImageViewer.cxx b/Testing/Code/Visu/otbImageViewer.cxx index 61dc624d9c..a02cbc2e47 100644 --- a/Testing/Code/Visu/otbImageViewer.cxx +++ b/Testing/Code/Visu/otbImageViewer.cxx @@ -22,47 +22,35 @@ int otbImageViewer( int argc, char * argv[] ) { - try - { - char * filename = argv[1]; - - // Parse command line parameters - typedef double PixelType; - typedef otb::ImageViewer<PixelType> ImageViewerType; - typedef ImageViewerType::ImageType ImageType; - typedef ImageViewerType::ViewModelType ViewModelType; - typedef otb::ImageFileReader<ImageType> ReaderType; + char * filename = argv[1]; + + // Parse command line parameters + typedef double PixelType; + typedef otb::ImageViewer<PixelType> ImageViewerType; + typedef ImageViewerType::ImageType ImageType; + typedef ImageViewerType::ViewModelType ViewModelType; + typedef otb::ImageFileReader<ImageType> ReaderType; - ViewModelType mode = static_cast<ViewModelType>(atoi(argv[2])); + ViewModelType mode = static_cast<ViewModelType>(atoi(argv[2])); - // instantiation - ImageViewerType::Pointer viewer = ImageViewerType::New(); + // instantiation + ImageViewerType::Pointer viewer = ImageViewerType::New(); - // check for input images - ReaderType::Pointer reader = ReaderType::New(); - reader->SetFileName(filename); - reader->GenerateOutputInformation(); - viewer->SetImage(reader->GetOutput()); + // check for input images + ReaderType::Pointer reader = ReaderType::New(); + reader->SetFileName(filename); + reader->GenerateOutputInformation(); + viewer->SetImage(reader->GetOutput()); - // build the app - viewer->Build(); - viewer->SetViewModel(mode); - viewer->Show(); + // build the app + viewer->Build(); + viewer->SetViewModel(mode); + viewer->Show(); - Fl::check(); - // Fl::run(); - } - 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; - } + Fl::check(); + // Fl::run(); + + return EXIT_SUCCESS; } diff --git a/Testing/Code/Visu/otbImageViewerNew.cxx b/Testing/Code/Visu/otbImageViewerNew.cxx index 76754e526b..664a9973e1 100644 --- a/Testing/Code/Visu/otbImageViewerNew.cxx +++ b/Testing/Code/Visu/otbImageViewerNew.cxx @@ -22,25 +22,12 @@ int otbImageViewerNew( int argc, char * argv[] ) { - try - { - // Parse command line parameters - typedef double PixelType; - typedef otb::ImageViewer<PixelType> ImageViewerType; - // instantiation - ImageViewerType::Pointer viewer = ImageViewerType::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; - } + // Parse command line parameters + typedef double PixelType; + typedef otb::ImageViewer<PixelType> ImageViewerType; + // instantiation + ImageViewerType::Pointer viewer = ImageViewerType::New(); + return EXIT_SUCCESS; } diff --git a/Testing/Code/Visu/otbImageViewerWithMultiBandFilter.cxx b/Testing/Code/Visu/otbImageViewerWithMultiBandFilter.cxx index 0cd47f66d5..963e84cadb 100644 --- a/Testing/Code/Visu/otbImageViewerWithMultiBandFilter.cxx +++ b/Testing/Code/Visu/otbImageViewerWithMultiBandFilter.cxx @@ -26,51 +26,38 @@ int otbImageViewerWithMultiBandFilter( int argc, char * argv[] ) { - try - { - char * filename = argv[1]; + char * filename = argv[1]; - // Parse command line parameters - typedef double PixelType; - typedef otb::ImageViewer<PixelType> ImageViewerType; - typedef ImageViewerType::ImageType VectorImageType; - typedef ImageViewerType::SingleImageType ImageType; - typedef itk::SobelEdgeDetectionImageFilter<ImageType,ImageType> FilterType; - typedef otb::PerBandVectorImageFilter<VectorImageType,VectorImageType,FilterType> - PerBandFilterType; - typedef otb::ImageFileReader<VectorImageType> ReaderType; - - // instantiation - ImageViewerType::Pointer viewer = ImageViewerType::New(); - PerBandFilterType::Pointer filter = PerBandFilterType::New(); - - // check for input images - ReaderType::Pointer reader = ReaderType::New(); - reader->SetFileName(filename); - - filter->SetInput(reader->GetOutput()); - filter->UpdateOutputInformation(); - - std::cout<<"Main - number of bands: "<<filter->GetOutput()->GetNumberOfComponentsPerPixel()<<std::endl; - std::cout<<"Main - largest region: "<<filter->GetOutput()->GetLargestPossibleRegion()<<std::endl; - - viewer->SetImage(filter->GetOutput()); - - // build the app - viewer->Show(); - Fl::check(); - } - 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; - } + // Parse command line parameters + typedef double PixelType; + typedef otb::ImageViewer<PixelType> ImageViewerType; + typedef ImageViewerType::ImageType VectorImageType; + typedef ImageViewerType::SingleImageType ImageType; + typedef itk::SobelEdgeDetectionImageFilter<ImageType,ImageType> FilterType; + typedef otb::PerBandVectorImageFilter<VectorImageType,VectorImageType,FilterType> + PerBandFilterType; + typedef otb::ImageFileReader<VectorImageType> ReaderType; + + // instantiation + ImageViewerType::Pointer viewer = ImageViewerType::New(); + PerBandFilterType::Pointer filter = PerBandFilterType::New(); + + // check for input images + ReaderType::Pointer reader = ReaderType::New(); + reader->SetFileName(filename); + + filter->SetInput(reader->GetOutput()); + filter->UpdateOutputInformation(); + + std::cout<<"Main - number of bands: "<<filter->GetOutput()->GetNumberOfComponentsPerPixel()<<std::endl; + std::cout<<"Main - largest region: "<<filter->GetOutput()->GetLargestPossibleRegion()<<std::endl; + + viewer->SetImage(filter->GetOutput()); + + // build the app + viewer->Show(); + Fl::check(); + return EXIT_SUCCESS; } diff --git a/Testing/Code/Visu/otbImageViewerWithOtbImage.cxx b/Testing/Code/Visu/otbImageViewerWithOtbImage.cxx index 686bd21dcb..dbbbf9ce98 100644 --- a/Testing/Code/Visu/otbImageViewerWithOtbImage.cxx +++ b/Testing/Code/Visu/otbImageViewerWithOtbImage.cxx @@ -22,40 +22,28 @@ int otbImageViewerWithOtbImage( int argc, char * argv[] ) { - try - { - char * filename = argv[1]; - - // Parse command line parameters - typedef double PixelType; - typedef otb::ImageViewer<PixelType> ImageViewerType; - typedef ImageViewerType::SingleImageType ImageType; - typedef otb::ImageFileReader<ImageType> ReaderType; + char * filename = argv[1]; + + // Parse command line parameters + typedef double PixelType; + typedef otb::ImageViewer<PixelType> ImageViewerType; + typedef ImageViewerType::SingleImageType ImageType; + typedef otb::ImageFileReader<ImageType> ReaderType; - // instantiation - ImageViewerType::Pointer viewer = ImageViewerType::New(); + // instantiation + ImageViewerType::Pointer viewer = ImageViewerType::New(); - // check for input images - ReaderType::Pointer reader = ReaderType::New(); - reader->SetFileName(filename); - reader->GenerateOutputInformation(); - viewer->SetImage(reader->GetOutput()); + // check for input images + ReaderType::Pointer reader = ReaderType::New(); + reader->SetFileName(filename); + reader->GenerateOutputInformation(); + viewer->SetImage(reader->GetOutput()); - // build the app - viewer->Show(); - Fl::check(); - } - 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; - } + // build the app + viewer->Show(); + Fl::check(); + + return EXIT_SUCCESS; } diff --git a/Testing/Code/Visu/otbImageWidgetBaseNew.cxx b/Testing/Code/Visu/otbImageWidgetBaseNew.cxx index 2f7e49f3c5..27add946e8 100644 --- a/Testing/Code/Visu/otbImageWidgetBaseNew.cxx +++ b/Testing/Code/Visu/otbImageWidgetBaseNew.cxx @@ -19,26 +19,11 @@ PURPOSE. See the above copyright notices for more information. int otbImageWidgetBaseNew( int argc, char * argv[] ) { - try - { - typedef float PixelType; - typedef otb::ImageWidgetBase<PixelType> WidgetType; + typedef float PixelType; + typedef otb::ImageWidgetBase<PixelType> WidgetType; - WidgetType::Pointer widget = WidgetType::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; - } - + WidgetType::Pointer widget = WidgetType::New(); + return EXIT_SUCCESS; } diff --git a/Testing/Code/Visu/otbVectorImageToColorAnaglyphVectorImageFilter.cxx b/Testing/Code/Visu/otbVectorImageToColorAnaglyphVectorImageFilter.cxx index cc7860bcfc..741ff2c58d 100644 --- a/Testing/Code/Visu/otbVectorImageToColorAnaglyphVectorImageFilter.cxx +++ b/Testing/Code/Visu/otbVectorImageToColorAnaglyphVectorImageFilter.cxx @@ -24,43 +24,28 @@ int otbVectorImageToColorAnaglyphVectorImageFilter(int argc, char * argv[]) { - try - { - const unsigned int Dimension = 2; - typedef unsigned char PixelType; + const unsigned int Dimension = 2; + typedef unsigned char PixelType; - typedef otb::VectorImage<PixelType,Dimension> VectorImageType; - typedef otb::VectorImageToColorAnaglyphVectorImageFilter<VectorImageType,VectorImageType,VectorImageType> FilterType; - typedef otb::ImageFileReader<VectorImageType> ReaderType; - typedef otb::StreamingImageFileWriter<VectorImageType> WriterType; + typedef otb::VectorImage<PixelType,Dimension> VectorImageType; + typedef otb::VectorImageToColorAnaglyphVectorImageFilter<VectorImageType,VectorImageType,VectorImageType> FilterType; + typedef otb::ImageFileReader<VectorImageType> ReaderType; + typedef otb::StreamingImageFileWriter<VectorImageType> WriterType; - // Instantiating object - FilterType::Pointer filter = FilterType::New(); - ReaderType::Pointer reader1 = ReaderType::New(); - ReaderType::Pointer reader2 = ReaderType::New(); - WriterType::Pointer writer = WriterType::New(); + // Instantiating object + FilterType::Pointer filter = FilterType::New(); + ReaderType::Pointer reader1 = ReaderType::New(); + ReaderType::Pointer reader2 = ReaderType::New(); + WriterType::Pointer writer = WriterType::New(); - reader1->SetFileName(argv[1]); - reader2->SetFileName(argv[2]); - writer->SetFileName(argv[3]); + reader1->SetFileName(argv[1]); + reader2->SetFileName(argv[2]); + writer->SetFileName(argv[3]); - filter->SetInput1(reader1->GetOutput()); - filter->SetInput2(reader2->GetOutput()); - writer->SetInput(filter->GetOutput()); - writer->Update(); - } + filter->SetInput1(reader1->GetOutput()); + filter->SetInput2(reader2->GetOutput()); + writer->SetInput(filter->GetOutput()); + writer->Update(); - 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; } diff --git a/Testing/Code/Visu/otbVectorImageToColorAnaglyphVectorImageFilterNew.cxx b/Testing/Code/Visu/otbVectorImageToColorAnaglyphVectorImageFilterNew.cxx index ea29183991..26bf61e5fa 100644 --- a/Testing/Code/Visu/otbVectorImageToColorAnaglyphVectorImageFilterNew.cxx +++ b/Testing/Code/Visu/otbVectorImageToColorAnaglyphVectorImageFilterNew.cxx @@ -22,29 +22,14 @@ int otbVectorImageToColorAnaglyphVectorImageFilterNew(int argc, char * argv[]) { - try - { - const unsigned int Dimension = 2; - typedef unsigned char PixelType; - - typedef otb::VectorImage<PixelType,Dimension> VectorImageType; - typedef otb::VectorImageToColorAnaglyphVectorImageFilter<VectorImageType,VectorImageType,VectorImageType> FilterType; - - // Instantiating object - FilterType::Pointer object = FilterType::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; - } + const unsigned int Dimension = 2; + typedef unsigned char PixelType; + + typedef otb::VectorImage<PixelType,Dimension> VectorImageType; + typedef otb::VectorImageToColorAnaglyphVectorImageFilter<VectorImageType,VectorImageType,VectorImageType> FilterType; + + // Instantiating object + FilterType::Pointer object = FilterType::New(); + return EXIT_SUCCESS; } diff --git a/Testing/Code/Visu/otbZoomableImageWidget.cxx b/Testing/Code/Visu/otbZoomableImageWidget.cxx index f619cee730..063f27bb7c 100644 --- a/Testing/Code/Visu/otbZoomableImageWidget.cxx +++ b/Testing/Code/Visu/otbZoomableImageWidget.cxx @@ -22,82 +22,66 @@ PURPOSE. See the above copyright notices for more information. int otbZoomableImageWidget( int argc, char * argv[] ) { - try - { - char * filename = argv[1]; - typedef float PixelType; - typedef otb::ZoomableImageWidget<PixelType> WidgetType; - typedef WidgetType::ImageType ImageType; - typedef otb::ImageFileReader<ImageType> ReaderType; + char * filename = argv[1]; + typedef float PixelType; + typedef otb::ZoomableImageWidget<PixelType> WidgetType; + typedef WidgetType::ImageType ImageType; + typedef otb::ImageFileReader<ImageType> ReaderType; + + ReaderType::Pointer reader = ReaderType::New(); + ImageType::SizeType size; + ImageType::IndexType index; + ImageType::RegionType region; + reader->SetFileName(filename); + reader->Update(); + size=reader->GetOutput()->GetLargestPossibleRegion().GetSize(); + + Fl_Window window(size[0],size[1]); + + WidgetType::Pointer widget = WidgetType::New(); + window.resizable(widget.GetPointer()); + widget->SetInput(reader->GetOutput()); + if(reader->GetOutput()->GetNumberOfComponentsPerPixel()>=3) + widget->SetViewModel(WidgetType::RGB); + else + widget->SetViewModel(WidgetType::GRAYSCALE); + widget->Init(0,0,size[0],size[1],"Test Full Image Widget"); + widget->redraw(); + window.end(); + window.show(); + window.show(); + widget->Show(); + widget->redraw(); + Fl::check(); + + for(double zoom = 1.0;zoom<10.;zoom++) + { + Fl::check(); - ReaderType::Pointer reader = ReaderType::New(); - ImageType::SizeType size; - ImageType::IndexType index; - ImageType::RegionType region; - reader->SetFileName(filename); - reader->Update(); - size=reader->GetOutput()->GetLargestPossibleRegion().GetSize(); - - Fl_Window window(size[0],size[1]); - - WidgetType::Pointer widget = WidgetType::New(); - window.resizable(widget.GetPointer()); - widget->SetInput(reader->GetOutput()); - if(reader->GetOutput()->GetNumberOfComponentsPerPixel()>=3) - widget->SetViewModel(WidgetType::RGB); - else - widget->SetViewModel(WidgetType::GRAYSCALE); - widget->Init(0,0,size[0],size[1],"Test Full Image Widget"); + index[0]=size[0]/2-static_cast<int>(static_cast<double>(size[0]/2)/zoom+0.5); + index[1]=size[1]/2-static_cast<int>(static_cast<double>(size[1]/2)/zoom+0.5); + widget->SetZoomUpperLeftCorner(index); + widget->SetZoomFactor(zoom); widget->redraw(); - window.end(); - window.show(); - window.show(); - widget->Show(); + Fl::wait(0.2); + Fl::check(); + } + + for(double zoom=10.;zoom>=1.;zoom--) + { + Fl::check(); + index[0]=size[0]/2-static_cast<int>(static_cast<double>(size[0])/(2*zoom)+0.5); + index[1]=size[1]/2-static_cast<int>(static_cast<double>(size[1])/(2*zoom)+0.5); + widget->SetZoomUpperLeftCorner(index); + widget->SetZoomFactor(zoom); widget->redraw(); + Fl::wait(0.2); Fl::check(); - - for(double zoom = 1.0;zoom<10.;zoom++) - { - Fl::check(); - - index[0]=size[0]/2-static_cast<int>(static_cast<double>(size[0]/2)/zoom+0.5); - index[1]=size[1]/2-static_cast<int>(static_cast<double>(size[1]/2)/zoom+0.5); - widget->SetZoomUpperLeftCorner(index); - widget->SetZoomFactor(zoom); - widget->redraw(); - Fl::wait(0.2); - Fl::check(); - } - - for(double zoom=10.;zoom>=1.;zoom--) - { - Fl::check(); - index[0]=size[0]/2-static_cast<int>(static_cast<double>(size[0])/(2*zoom)+0.5); - index[1]=size[1]/2-static_cast<int>(static_cast<double>(size[1])/(2*zoom)+0.5); - widget->SetZoomUpperLeftCorner(index); - widget->SetZoomFactor(zoom); - widget->redraw(); - Fl::wait(0.2); - Fl::check(); - } - - // suppres child, without delete memory. - // delete memory is ITK respoability, since WidgetType::New() - window.remove(widget.GetPointer()); - } + } - 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; - } - + // suppres child, without delete memory. + // delete memory is ITK respoability, since WidgetType::New() + window.remove(widget.GetPointer()); return EXIT_SUCCESS; } -- GitLab