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 "mitkCylindricToCartesianFilter.h"
00022 #include "mitkImageSliceSelector.h"
00023
00024 #include <fstream>
00025 int mitkCylindricToCartesianFilterTest(int argc, char* argv[])
00026 {
00027 std::cout << "Loading file: ";
00028 if(argc==0)
00029 {
00030 std::cout<<"no file specified [FAILED]"<<std::endl;
00031 return EXIT_FAILURE;
00032 }
00033 mitk::Image::Pointer image = NULL;
00034 mitk::DataNodeFactory::Pointer factory = mitk::DataNodeFactory::New();
00035 try
00036 {
00037 factory->SetFileName( argv[1] );
00038 factory->Update();
00039
00040 if(factory->GetNumberOfOutputs()<1)
00041 {
00042 std::cout<<"file could not be loaded [FAILED]"<<std::endl;
00043 return EXIT_FAILURE;
00044 }
00045 mitk::DataNode::Pointer node = factory->GetOutput( 0 );
00046 image = dynamic_cast<mitk::Image*>(node->GetData());
00047 if(image.IsNull())
00048 {
00049 std::cout<<"file not an image - test will not be applied [PASSED]"<<std::endl;
00050 std::cout<<"[TEST DONE]"<<std::endl;
00051 return EXIT_SUCCESS;
00052 }
00053 }
00054 catch ( itk::ExceptionObject & ex )
00055 {
00056 std::cout << "Exception: " << ex << "[FAILED]" << std::endl;
00057 return EXIT_FAILURE;
00058 }
00059
00060
00061 mitk::CylindricToCartesianFilter::Pointer cyl2cart = mitk::CylindricToCartesianFilter::New();
00062 cyl2cart->SetInput(image);
00063 cyl2cart->SetTargetXSize( 64 );
00064
00065
00066 mitk::ImageSliceSelector::Pointer slice = mitk::ImageSliceSelector::New();
00067 slice->SetInput(cyl2cart->GetOutput());
00068 slice->SetSliceNr(1);
00069 slice->Update();
00070
00071 std::cout << "Testing IsInitialized(): ";
00072 if(slice->GetOutput()->IsInitialized()==false)
00073 {
00074 std::cout<<"[FAILED]"<<std::endl;
00075 return EXIT_FAILURE;
00076 }
00077 std::cout<<"[PASSED]"<<std::endl;
00078
00079 std::cout << "Testing IsSliceSet(): ";
00080 if(slice->GetOutput()->IsSliceSet(0)==false)
00081 {
00082 std::cout<<"[FAILED]"<<std::endl;
00083 return EXIT_FAILURE;
00084 }
00085 std::cout<<"[PASSED]"<<std::endl;
00086
00087 if(image->GetDimension(3) > 1)
00088 {
00089 int time=image->GetDimension(3)-1;
00090
00091 std::cout << "Testing 3D+t: Setting time to " << time << ": ";
00092 slice->SetTimeNr(time);
00093 if(slice->GetTimeNr()!=time)
00094 {
00095 std::cout<<"[FAILED]"<<std::endl;
00096 return EXIT_FAILURE;
00097 }
00098 std::cout<<"[PASSED]"<<std::endl;
00099
00100 std::cout << "Testing 3D+t: Updating slice: ";
00101 slice->Update();
00102 if(slice->GetOutput()->IsInitialized()==false)
00103 {
00104 std::cout<<"[FAILED]"<<std::endl;
00105 return EXIT_FAILURE;
00106 }
00107 std::cout<<"[PASSED]"<<std::endl;
00108
00109 std::cout << "Testing 3D+t: IsSliceSet(): ";
00110 if(slice->GetOutput()->IsSliceSet(0)==false)
00111 {
00112 std::cout<<"[FAILED]"<<std::endl;
00113 return EXIT_FAILURE;
00114 }
00115 std::cout<<"[PASSED]"<<std::endl;
00116
00117 std::cout << "Testing 3D+t: First slice in reader available: ";
00118 if(image->IsSliceSet(0, time)==false)
00119 {
00120 std::cout<<"[FAILED]"<<std::endl;
00121 return EXIT_FAILURE;
00122 }
00123 std::cout<<"[PASSED]"<<std::endl;
00124 }
00125
00126 std::cout<<"[TEST DONE]"<<std::endl;
00127 return EXIT_SUCCESS;
00128 }