Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "mitkImage.h"
00020 #include "mitkDataNodeFactory.h"
00021 #include "mitkImageTimeSelector.h"
00022 #include <itksys/SystemTools.hxx>
00023
00024 #include <fstream>
00025 int mitkImageTimeSelectorTest(int argc, char* argv[])
00026 {
00027
00028 std::cout << "Loading file: ";
00029 if(argc==0)
00030 {
00031 std::cout<<"no file specified [FAILED]"<<std::endl;
00032 return EXIT_FAILURE;
00033 }
00034 mitk::Image::Pointer image = NULL;
00035 mitk::DataNodeFactory::Pointer factory = mitk::DataNodeFactory::New();
00036 try
00037 {
00038 factory->SetFileName( argv[1] );
00039 factory->Update();
00040
00041 if(factory->GetNumberOfOutputs()<1)
00042 {
00043 std::cout<<"file could not be loaded [FAILED]"<<std::endl;
00044 return EXIT_FAILURE;
00045 }
00046 mitk::DataNode::Pointer node = factory->GetOutput( 0 );
00047 image = dynamic_cast<mitk::Image*>(node->GetData());
00048 if(image.IsNull())
00049 {
00050 std::cout<<"file not an image - test will not be applied [PASSED]"<<std::endl;
00051 std::cout<<"[TEST DONE]"<<std::endl;
00052 return EXIT_SUCCESS;
00053 }
00054 }
00055 catch ( itk::ExceptionObject & ex )
00056 {
00057 std::cout << "Exception: " << ex << "[FAILED]" << std::endl;
00058 return EXIT_FAILURE;
00059 }
00060
00061
00062 mitk::ImageTimeSelector::Pointer timeSelector = mitk::ImageTimeSelector::New();
00063 timeSelector->SetInput(image);
00064 timeSelector->SetTimeNr( 0 );
00065 timeSelector->UpdateLargestPossibleRegion();
00066 mitk::Image::Pointer result = timeSelector->GetOutput();
00067
00068 std::cout << "Testing IsInitialized(): ";
00069 if(result->IsInitialized()==false)
00070 {
00071 std::cout<<"[FAILED]"<<std::endl;
00072 return EXIT_FAILURE;
00073 }
00074 std::cout<<"[PASSED]"<<std::endl;
00075
00076 std::cout << "Testing if Volume is set ";
00077
00078
00079
00080 if( result->IsVolumeSet(0) == false)
00081 {
00082 std::cout<<"[FAILED]"<<std::endl;
00083 return EXIT_FAILURE;
00084 }
00085 std::cout<<"[PASSED]"<<std::endl;
00086
00087
00088
00089 std::cout<<"[TEST DONE]"<<std::endl;
00090 return EXIT_SUCCESS;
00091 }