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 <vtkProperty.h>
00019 #include "mitkEnumerationProperty.h"
00020 #include "mitkVtkInterpolationProperty.h"
00021 #include "mitkVtkRepresentationProperty.h"
00022
00023
00024 int mitkEnumerationPropertyTest( int , char* [] )
00025 {
00026 mitk::EnumerationProperty::Pointer enumerationProperty(mitk::EnumerationProperty::New());
00027
00028 std::cout << "Testing mitk::EnumerationProperty::AddEnum(...): ";
00029 bool success = true;
00030 success = success && enumerationProperty->AddEnum( "first", 1 );
00031 success = success && enumerationProperty->AddEnum( "second", 2 );
00032 success = success && enumerationProperty->AddEnum( "third", 3 );
00033 if ( ! success )
00034 {
00035 std::cout << "[FAILED]" << std::endl;
00036 return EXIT_FAILURE;
00037 }
00038 else
00039 {
00040 std::cout << "[PASSED]" << std::endl;
00041 }
00042
00043
00044
00045
00046
00047 std::cout << "Testing mitk::EnumerationProperty::Size(): " ;
00048 if ( enumerationProperty->Size() != 3 )
00049 {
00050 std::cout << "[FAILED]" << std::endl;
00051 return EXIT_FAILURE;
00052 }
00053 else
00054 {
00055 std::cout << "[PASSED]" << std::endl;
00056 }
00057
00058 std::cout << "Testing mitk::EnumerationProperty::AddEnum() with invalid entries: ";
00059 if ( enumerationProperty->AddEnum( "first", 0 ) )
00060 {
00061 std::cout << "[FAILED]" << std::endl;
00062 return EXIT_FAILURE;
00063 }
00064 else
00065 {
00066 std::cout << "[PASSED]" << std::endl;
00067 }
00068
00069
00070
00071
00072
00073 std::cout << "Testing mitk::EnumerationProperty::SetValue(id): ";
00074 if ( ! enumerationProperty->SetValue( 2 ) )
00075 {
00076 std::cout << "[FAILED]" << std::endl;
00077 return EXIT_FAILURE;
00078 }
00079 if ( enumerationProperty->GetValueAsId() != 2 )
00080 {
00081 std::cout << "[FAILED]" << std::endl;
00082 return EXIT_FAILURE;
00083 }
00084 if ( enumerationProperty->GetValueAsString() != "second" )
00085 {
00086 std::cout << "[FAILED]" << std::endl;
00087 return EXIT_FAILURE;
00088 }
00089 std::cout << "[PASSED]" << std::endl;
00090
00091
00092
00093
00094
00095 std::cout << "Testing mitk::EnumerationProperty::SetValue(name): ";
00096 if ( ! enumerationProperty->SetValue( "third" ) )
00097 {
00098 std::cout << "[FAILED]" << std::endl;
00099 return EXIT_FAILURE;
00100 }
00101 if ( enumerationProperty->GetValueAsId() != 3 )
00102 {
00103 std::cout << "[FAILED]" << std::endl;
00104 return EXIT_FAILURE;
00105 }
00106 if ( enumerationProperty->GetValueAsString() != "third" )
00107 {
00108 std::cout << "[FAILED]" << std::endl;
00109 return EXIT_FAILURE;
00110 }
00111 std::cout << "[PASSED]" << std::endl;
00112
00113
00114
00115
00116
00117 std::cout << "Testing mitk::EnumerationProperty::SetValue(invalid id): ";
00118 if ( enumerationProperty->SetValue( 100 ) )
00119 {
00120 std::cout << "[FAILED]" << std::endl;
00121 return EXIT_FAILURE;
00122 }
00123 std::cout << "[PASSED]" << std::endl;
00124
00125 std::cout << "Testing mitk::EnumerationProperty::SetValue(invalid name): ";
00126 if ( enumerationProperty->SetValue( "madmax" ) )
00127 {
00128 std::cout << "[FAILED]" << std::endl;
00129 return EXIT_FAILURE;
00130 }
00131 std::cout << "[PASSED]" << std::endl;
00132
00133
00134
00135
00136
00137
00138 std::cout << "Testing mitk::VtkInterpolationType::SetInterpolationToPhong(): ";
00139 mitk::VtkInterpolationProperty::Pointer vtkInterpolationProperty(mitk::VtkInterpolationProperty::New());;
00140 vtkInterpolationProperty->SetInterpolationToPhong();
00141 if ( vtkInterpolationProperty->GetValueAsString() != "Phong" )
00142 {
00143 std::cout << "[FAILED]" << std::endl;
00144 return EXIT_FAILURE;
00145 }
00146 if ( vtkInterpolationProperty->GetValueAsId() != 2 )
00147 {
00148 std::cout << "[FAILED]" << std::endl;
00149 return EXIT_FAILURE;
00150 }
00151 if ( vtkInterpolationProperty->GetVtkInterpolation() != VTK_PHONG )
00152 {
00153 std::cout << "[FAILED]" << std::endl;
00154 return EXIT_FAILURE;
00155 }
00156 std::cout << "[PASSED]" << std::endl;
00157
00158
00159
00160
00161
00162 std::cout << "Testing mitk::VtkRepresentationType::SetRepresentationToWireframe(): ";
00163 mitk::VtkRepresentationProperty::Pointer vtkRepresentationProperty(mitk::VtkRepresentationProperty::New());
00164 vtkRepresentationProperty->SetRepresentationToWireframe();
00165 if ( vtkRepresentationProperty->GetValueAsString() != "Wireframe" )
00166 {
00167 std::cout << "[FAILED]" << std::endl;
00168 return EXIT_FAILURE;
00169 }
00170 if ( vtkRepresentationProperty->GetValueAsId() != 1 )
00171 {
00172 std::cout << "[FAILED]" << std::endl;
00173 return EXIT_FAILURE;
00174 }
00175 if ( vtkRepresentationProperty->GetVtkRepresentation() != VTK_WIREFRAME )
00176 {
00177 std::cout << "[FAILED]" << std::endl;
00178 return EXIT_FAILURE;
00179 }
00180 std::cout << "[PASSED]" << std::endl;
00181
00182 std::cout << "[TEST DONE]" << std::endl;
00183 return EXIT_SUCCESS;
00184 }