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 #include "mitkPointSet.h"
00019 #include "mitkPointSetWriter.h"
00020
00021 #include "mitkTestingMacros.h"
00022
00023 #include <iostream>
00024 #include <time.h>
00025
00034 int mitkPointSetWriterTest(int , char* [])
00035 {
00036
00037 MITK_TEST_BEGIN("PointSetWriter")
00038
00039
00040 mitk::PointSetWriter::Pointer myPointSetWriter = mitk::PointSetWriter::New();
00041
00042
00043
00044
00045 MITK_TEST_CONDITION_REQUIRED(myPointSetWriter.IsNotNull(),"Testing instantiation")
00046
00047
00048
00049
00050
00051 srand(time(NULL));
00052 mitk::PointSet::Pointer pointSet = mitk::PointSet::New();
00053 int numberOfPoints = rand()%100;
00054 for (int i=0; i<=numberOfPoints+1;i++)
00055 {
00056 mitk::Point3D point;
00057 point[0] = rand()%1000;
00058 point[1] = rand()%1000;
00059 point[2] = rand()%1000;
00060 pointSet->SetPoint(i,point);
00061 }
00062
00063 MITK_TEST_CONDITION_REQUIRED(pointSet.IsNotNull(),"PointSet creation")
00064
00065 try{
00066
00067 MITK_TEST_FOR_EXCEPTION_BEGIN(itk::ExceptionObject)
00068 myPointSetWriter->SetInput(pointSet);
00069 myPointSetWriter->SetFileName("/usr/bin");
00070 myPointSetWriter->Update();
00071 MITK_TEST_FOR_EXCEPTION_END(itk::ExceptionObject)
00072 }
00073 catch(...) {
00074
00075 std::cout << "Wrong exception (i.e. no itk:Exception) caught during write [FAILED]" << std::endl;
00076 return EXIT_FAILURE;
00077 }
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096 MITK_TEST_OUTPUT( << "Check if input can be set correctly: ");
00097 myPointSetWriter->SetInput(pointSet);
00098 mitk::PointSet::Pointer pointSet2 = mitk::PointSet::New();
00099 pointSet2 = myPointSetWriter->GetInput();
00100
00101 MITK_TEST_CONDITION_REQUIRED( pointSet->GetSize() == pointSet2->GetSize(), "Pointsets have unequal size" );
00102
00103 for(int i=0; i<pointSet->GetSize(); i++)
00104 {
00105 mitk::Point3D p1 = pointSet->GetPoint(i);
00106 mitk::Point3D p2 = pointSet2->GetPoint(i);
00107 MITK_TEST_CONDITION_REQUIRED( p1[0] == p2[0] && p1[0] == p2[0] && p1[0] == p2[0], "Pointsets aren't equal" );
00108 }
00109
00110 std::vector< std::string > extensions = myPointSetWriter->GetPossibleFileExtensions();
00111
00112
00113 MITK_TEST_END()
00114 }
00115