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 "mitkSurface.h"
00020 #include "mitkSurfaceToSurfaceFilter.h"
00021 #include "mitkCommon.h"
00022 #include "mitkVector.h"
00023 #include "mitkTimeSlicedGeometry.h"
00024
00025 #include "vtkPolyData.h"
00026 #include "vtkSphereSource.h"
00027
00028 #include <fstream>
00029
00030 int mitkSurfaceToSurfaceFilterTest(int , char* [])
00031 {
00032 mitk::Surface::Pointer surface;
00033 surface = mitk::Surface::New();
00034 vtkSphereSource* sphereSource = vtkSphereSource::New();
00035 sphereSource->SetCenter(0,0,0);
00036 sphereSource->SetRadius(5.0);
00037 sphereSource->SetThetaResolution(10);
00038 sphereSource->SetPhiResolution(10);
00039 sphereSource->Update();
00040
00041 vtkPolyData* polys = sphereSource->GetOutput();
00042 surface->SetVtkPolyData( polys );
00043 sphereSource->Delete();
00044
00045
00046 mitk::SurfaceToSurfaceFilter::Pointer filter = mitk::SurfaceToSurfaceFilter::New();
00047 std::cout << "Testing mitk::SurfaceToSurfaceFilter::SetInput() and ::GetNumberOfInputs() : " ;
00048 filter->SetInput( surface );
00049 if ( filter->GetNumberOfInputs() < 1 )
00050 {
00051 std::cout<<"[FAILED] : zero inputs set "<<std::endl;
00052 return EXIT_FAILURE;
00053 }
00054
00055
00056 std::cout << "Testing if GetInput returns the right Input : " << std::endl;
00057 if ( filter->GetInput() != surface )
00058 {
00059 std::cout<<"[FAILED] : GetInput does not return correct input. "<<std::endl;
00060 return EXIT_FAILURE;
00061 }
00062 std::cout << "[SUCCESS] : input correct" << std::endl;
00063
00064
00065 if ( filter->GetInput(5) != NULL )
00066 {
00067 std::cout<<"[FAILED] : GetInput returns inputs that were not set. "<<std::endl;
00068 return EXIT_FAILURE;
00069 }
00070 std::cout << "[SUCCESS] : Input nr.5 was not set -> is NULL" << std::endl;
00071
00072
00073 std::cout << "Testing whether Output is created correctly : " << std::endl;
00074 if ( filter->GetNumberOfOutputs() != filter->GetNumberOfInputs() )
00075 {
00076 std::cout <<"[FAILED] : number of outputs != number of inputs" << std::endl;
00077 return EXIT_FAILURE;
00078 }
00079 std::cout << "[SUCCESS] : number of inputs == number of outputs." << std::endl;
00080
00081
00082 mitk::Surface::Pointer outputSurface = filter->GetOutput(0);
00083 if ( outputSurface->GetVtkPolyData()->GetNumberOfPolys() != surface->GetVtkPolyData()->GetNumberOfPolys() )
00084 {
00085 std::cout << "[FAILED] : number of Polys in PolyData of output != number of Polys in PolyData of input" << std::endl;
00086 return EXIT_FAILURE;
00087 }
00088 std::cout << "[SUCCESS] : number of Polys in PolyData of input and output are identical." << std::endl;
00089
00090
00091
00092 filter->Update();
00093 outputSurface = filter->GetOutput(0);
00094 if ( outputSurface->GetSizeOfPolyDataSeries() != surface->GetSizeOfPolyDataSeries() )
00095 {
00096 std::cout << "[FAILED] : number of PolyDatas in PolyDataSeries of output != number of PolyDatas of input" << std::endl;
00097 return EXIT_FAILURE;
00098 }
00099 std::cout << "[SUCCESS] : Size of PolyDataSeries of input and output are identical." << std::endl;
00100
00101
00102 std::cout << "Testing removeInputs() : " << std::endl;
00103 unsigned int numOfInputs = filter->GetNumberOfInputs();
00104 filter->RemoveInputs( mitk::Surface::New() );
00105 if ( filter->GetNumberOfInputs() != numOfInputs )
00106 {
00107 std::cout << "[FAILED] : input was removed that was not set." << std::endl;
00108 return EXIT_FAILURE;
00109 }
00110 std::cout << "[SUCCESS] : no iput was removed that was not set." << std::endl;
00111 filter->RemoveInputs( surface );
00112 if ( filter->GetNumberOfInputs() != 0 )
00113 {
00114 std::cout << "[FAILED] : existing input was not removed correctly." << std::endl;
00115 return EXIT_FAILURE;
00116 }
00117 std::cout << "[SUCCESS] : existing input was removed correctly." << std::endl;
00118
00119
00120
00121 std::cout<<"[TEST DONE]"<<std::endl;
00122 return EXIT_SUCCESS;
00123 }