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 <mitkPlaneFit.h>
00019 #include <mitkPointSet.h>
00020 #include <mitkGeometry2D.h>
00021 #include <mitkVector.h>
00022 #include <mitkGeometryData.h>
00023 #include <fstream>
00024
00025 int mitkPlaneFitTest(int, char*[] )
00026 {
00027
00028
00029 mitk::PlaneFit::Pointer PlaneFit = mitk::PlaneFit::New();
00030 mitk::PointSet::Pointer PointSet = mitk::PointSet::New();
00031 mitk::Geometry3D::Pointer Geometry3D = mitk::Geometry3D::New();
00032
00033 mitk::Point3D Point;
00034
00035
00036 std::cout <<"Start PlaneFitTest "<<std::endl;
00037 for(int position=0; position<6; position++)
00038 {
00039
00040 mitk::FillVector3D(Point, (float) position , (float) position * 1.5 , 2.5);
00041 PointSet->GetPointSet()->GetPoints()->InsertElement(position, Point);
00042 }
00043
00044
00045 PlaneFit->SetInput(PointSet);
00046
00047 const mitk::PointSet* testPointSet = PlaneFit->GetInput();
00048 std::cout<<" Size test of Input Method: ";
00049 if( testPointSet->GetSize() == PointSet->GetSize() )
00050 {
00051 std::cout<<"[PASSED]"<<std::endl;
00052 }
00053 else
00054 {
00055 std::cout<<"[FAILED]"<<std::endl;
00056 return EXIT_FAILURE;
00057 }
00058
00059
00060
00061 std::cout << " Testing centroid calculaation: ";
00062 PlaneFit->Update();
00063 const mitk::Point3D ¢roid = PlaneFit->GetCentroid();
00064 mitk::Point3D expectedCentroid;
00065 expectedCentroid[0]=2.5;
00066 expectedCentroid[1]=3.75;
00067 expectedCentroid[2]=2.5;
00068
00069 if ( centroid == expectedCentroid )
00070 {
00071 std::cout<<"[PASSED]"<<std::endl;
00072 }
00073 else
00074 {
00075 std::cout<<"[FAILED]"<<std::endl;
00076 return EXIT_FAILURE;
00077 }
00078
00079
00080
00081
00082
00083 std::cout << " Test PlaneGeometry: ";
00084 mitk::Geometry2D* Geometry2D = dynamic_cast<mitk::Geometry2D*>( PlaneFit->GetOutput()->GetGeometry());
00085 if( Geometry2D )
00086 {
00087 std::cout<<"[PASSED]"<<std::endl;
00088 }
00089 else
00090 {
00091 std::cout<<"[FAILED]"<<std::endl;
00092 return EXIT_FAILURE;
00093 }
00094
00095 std::cout<<"[TEST DONE]"<<std::endl;
00096 return EXIT_SUCCESS;
00097 }
00098