00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "mitkMaterial.h"
00019 #include "mitkBaseProperty.h"
00020 #include "mitkBaseRenderer.h"
00021 #include "mitkTestingMacros.h"
00022 #include "mitkDataNode.h"
00023 #include <mitkVtkPropRenderer.h>
00024 #include <mitkColorProperty.h>
00025
00026 #include <iostream>
00027
00040 class MaterialTest
00041 {
00042 public:
00043 mitk::Material::Pointer myMP;
00044
00045 MaterialTest(){myMP = NULL;}
00046
00047 void testConstructor()
00048 {
00049 myMP = mitk::Material::New();
00050 MITK_TEST_CONDITION_REQUIRED(myMP.IsNotNull(),"Testing instantiation")
00051 }
00052
00053 void testConstructorWithColorOpacity()
00054 {
00055 mitk::Color color;
00056 color.Set(0, 0, 0);
00057 vtkFloatingPointType opacity = 1.0f;
00058 myMP = mitk::Material::New(color, opacity);
00059 MITK_TEST_CONDITION_REQUIRED(myMP.IsNotNull(),"Testing instantiation")
00060 MITK_TEST_CONDITION( color==myMP->GetColor(), "Testing if a Color object was set correctly" )
00061 MITK_TEST_CONDITION( opacity==myMP->GetOpacity(), "Testing if a Opacity object was set correctly" )
00062 }
00063
00064 void testConstructorWithRedGreenBlueOpacity()
00065 {
00066 mitk::Material::Color color;
00067 color.Set(0, 0, 0);
00068 vtkFloatingPointType opacity = 1.0f;
00069 vtkFloatingPointType rgb = 0;
00070
00071 myMP = mitk::Material::New(rgb, rgb, rgb, opacity);
00072 MITK_TEST_CONDITION_REQUIRED(myMP.IsNotNull(),"Testing instantiation")
00073 MITK_TEST_CONDITION( color==myMP->GetColor(), "Testing if a Color object was set correctly" )
00074 MITK_TEST_CONDITION( opacity==myMP->GetOpacity(), "Testing if a Opacity object was set correctly" )
00075 }
00076
00077 void testConstructorRedGreenBlueColorCoefficientSpecularCoefficientSpecularPowerOpacity()
00078 {
00079 mitk::Material::Color color;
00080 color.Set(0, 0, 0);
00081 vtkFloatingPointType opacity = 1.0f;
00082 vtkFloatingPointType rgb = 0;
00083 vtkFloatingPointType colorCoefficient = 0;
00084 vtkFloatingPointType specularCoefficient = 0;
00085 vtkFloatingPointType specularPower = 0;
00086
00087 myMP = mitk::Material::New(rgb, rgb, rgb, colorCoefficient,
00088 specularCoefficient, specularPower, opacity);
00089 MITK_TEST_CONDITION_REQUIRED(myMP.IsNotNull(),"Testing instantiation")
00090 MITK_TEST_CONDITION( color==myMP->GetColor(), "Testing if a Color object was set correctly" )
00091 MITK_TEST_CONDITION( opacity==myMP->GetOpacity(), "Testing if a Opacity object was set correctly" )
00092 MITK_TEST_CONDITION( specularCoefficient==myMP->GetSpecularCoefficient(), "Testing if a Coefficient object was set correctly" )
00093 MITK_TEST_CONDITION( specularPower==myMP->GetSpecularPower(), "Testing if a SpecularPower object was set correctly" )
00094 MITK_TEST_CONDITION( colorCoefficient==myMP->GetColorCoefficient(), "Testing if a colorCoefficient object was set correctly" )
00095 }
00096
00097 void testConstructorColorColorCoefficientSpecularCoefficientSpecularPowerOpacity()
00098 {
00099 mitk::Material::Color color;
00100 color.Set(0, 0, 0);
00101 vtkFloatingPointType opacity = 1.0f;
00102 vtkFloatingPointType rgb = 0;
00103 vtkFloatingPointType colorCoefficient = 0;
00104 vtkFloatingPointType specularCoefficient = 0;
00105 vtkFloatingPointType specularPower = 0;
00106
00107 myMP = mitk::Material::New(rgb, rgb, rgb, colorCoefficient,
00108 specularCoefficient, specularPower, opacity);
00109 MITK_TEST_CONDITION_REQUIRED(myMP.IsNotNull(),"Testing instantiation")
00110 MITK_TEST_CONDITION( color==myMP->GetColor(), "Testing if a Color object was set correctly" )
00111 MITK_TEST_CONDITION( opacity==myMP->GetOpacity(), "Testing if a Opacity object was set correctly" )
00112 MITK_TEST_CONDITION( specularCoefficient==myMP->GetSpecularCoefficient(), "Testing if a Coefficient object was set correctly" )
00113 MITK_TEST_CONDITION( specularPower==myMP->GetSpecularPower(), "Testing if a SpecularPower object was set correctly" )
00114 }
00115
00116 void testConstructorPropertyRedGreenBlueOpacityAndName()
00117 {
00118 mitk::Material::Pointer reference = myMP;
00119 vtkFloatingPointType opacity = 1.0f;
00120 vtkFloatingPointType rgb = 0;
00121 std::string name = "Hans Wurst";
00122
00123 myMP = mitk::Material::New(*reference, rgb, rgb, rgb, opacity, name);
00124 MITK_TEST_CONDITION_REQUIRED(myMP.IsNotNull(),"Testing instantiation")
00125 MITK_TEST_CONDITION( opacity==myMP->GetOpacity(), "Testing if a Opacity object was set correctly" )
00126
00127 }
00128 void testSetColor()
00129 {
00130 mitk::Material::Color color;
00131 color.Set(0,0,0);
00132 myMP = mitk::Material::New();
00133 myMP->SetColor(color);
00134 MITK_TEST_CONDITION_REQUIRED(myMP.IsNotNull(),"Testing instantiation")
00135 MITK_TEST_CONDITION(color==myMP->GetColor(),"Testing if a color was set correctly")
00136 color.Set(0,0,0);
00137 myMP->SetColor(color);
00138 MITK_TEST_CONDITION(color==myMP->GetColor(),"Testing if a color was set correctly")
00139 }
00140
00141 void testSetColorCoefficient()
00142 {
00143
00144 vtkFloatingPointType colorCoefficient = 0;
00145 myMP = mitk::Material::New();
00146 myMP->SetColorCoefficient(colorCoefficient);
00147 MITK_TEST_CONDITION(colorCoefficient == myMP->GetColorCoefficient(), "Testing if a colorcoefficent was set correctly")
00148
00149 }
00150 void testSetSpecularColor()
00151 {
00152 mitk::Material::Color color;
00153 color.Set(0,0,0);
00154 myMP = mitk::Material::New();
00155 myMP->SetSpecularColor(color);
00156 MITK_TEST_CONDITION(color == myMP->GetSpecularColor(),"Testing if a SpecularColor was set correctly")
00157
00158
00159
00160 }
00161
00162 void testSetSpecularCoefficient()
00163 {
00164 myMP = mitk::Material::New();
00165 vtkFloatingPointType specularCoefficient = 1;
00166 myMP->SetSpecularCoefficient(specularCoefficient);
00167 MITK_TEST_CONDITION(specularCoefficient == myMP->GetSpecularCoefficient(),"Testing if a SpecularCoefficient was set correctly")
00168
00169 }
00170 void testSetSpecularPower()
00171 {
00172 myMP = mitk::Material::New();
00173 vtkFloatingPointType specularPower = 1;
00174 myMP->SetSpecularPower(specularPower);
00175 MITK_TEST_CONDITION(specularPower==myMP->GetSpecularPower(), "Testing if a SpecularPower was set correctly")
00176
00177
00178 }
00179 void testSetOpacity()
00180 {
00181 myMP = mitk::Material::New();
00182 vtkFloatingPointType opacity = 1;
00183 myMP->SetOpacity(opacity);
00184 MITK_TEST_CONDITION(opacity==myMP->GetOpacity(), "Testing if a Opacity was set correctly")
00185
00186 }
00187
00188
00189 void testSetInterpolation()
00190 {
00191 myMP = mitk::Material::New();
00192 mitk::Material::InterpolationType interpolation = mitk::Material::Flat;
00193 myMP->SetInterpolation(interpolation);
00194 MITK_TEST_CONDITION(interpolation == myMP->GetInterpolation(), "Testing if a Interpolation was set correctly")
00195 }
00196 void testSetRepresentation()
00197 {
00198 myMP = mitk::Material::New();
00199 mitk::Material::RepresentationType representation = mitk::Material::Wireframe;
00200 myMP->SetRepresentation(representation);
00201 MITK_TEST_CONDITION(representation == myMP->GetRepresentation(), "Testing if a Representation was set correctly")
00202
00203 }
00204
00205 void testSetLineWidth()
00206 {
00207 myMP = mitk::Material::New();
00208 vtkFloatingPointType lineWidth = 1;
00209 myMP->SetLineWidth(lineWidth);
00210 MITK_TEST_CONDITION(lineWidth==myMP->GetLineWidth(), "Testing if a LineWidth was set correctly")
00211 }
00212
00213 void testInitialize()
00214 {
00215 mitk::Material::Color color;
00216 color.Set(0, 0, 0);
00217 vtkFloatingPointType opacity = 1.0f;
00218 vtkFloatingPointType rgb = 0;
00219 vtkFloatingPointType colorCoefficient = 0;
00220 vtkFloatingPointType specularCoefficient = 0;
00221 vtkFloatingPointType specularPower = 0;
00222
00223 myMP = mitk::Material::New(rgb, rgb, rgb, colorCoefficient,
00224 specularCoefficient, specularPower, opacity);
00225 vtkFloatingPointType lineWidth = 1;
00226 myMP->SetLineWidth(lineWidth);
00227 mitk::Material::RepresentationType representation = mitk::Material::Wireframe;
00228 myMP->SetRepresentation(representation);mitk::Material::InterpolationType interpolation = mitk::Material::Flat;
00229 myMP->SetInterpolation(interpolation);
00230 myMP->SetSpecularColor(color);
00231 std::string name = "Hans Wurst";
00232 myMP->SetName(name);
00233 mitk::Material::Pointer myMP2 = mitk::Material::New();
00234 myMP2->Initialize(*myMP);
00235 MITK_TEST_CONDITION(*myMP == *myMP2, "testing equality after .Intitialize")
00236 }
00237 void testOperatorequality()
00238 {
00239 {
00240 mitk::Material::Color color;
00241 color.Set(0, 0, 0);
00242 vtkFloatingPointType opacity = 1.0f;
00243 vtkFloatingPointType rgb = 0;
00244 vtkFloatingPointType colorCoefficient = 0;
00245 vtkFloatingPointType specularCoefficient = 0;
00246 vtkFloatingPointType specularPower = 0;
00247
00248 myMP = mitk::Material::New(rgb, rgb, rgb, colorCoefficient,
00249 specularCoefficient, specularPower, opacity);
00250 vtkFloatingPointType lineWidth = 1;
00251 myMP->SetLineWidth(lineWidth);
00252 mitk::Material::RepresentationType representation = mitk::Material::Wireframe;
00253 myMP->SetRepresentation(representation);mitk::Material::InterpolationType interpolation = mitk::Material::Flat;
00254 myMP->SetInterpolation(interpolation);
00255 myMP->SetSpecularColor(color);
00256 std::string name = "Hans Wurst";
00257 myMP->SetName(name);
00258
00259
00260 mitk::Material::Color color2;
00261 color2.Set(0, 0, 0);
00262 vtkFloatingPointType opacity2 = 1.0f;
00263 vtkFloatingPointType rgb2 = 0;
00264 vtkFloatingPointType colorCoefficient2 = 0;
00265 vtkFloatingPointType specularCoefficient2 = 0;
00266 vtkFloatingPointType specularPower2 = 0;
00267
00268 mitk::Material::Pointer myMP2 = mitk::Material::New(rgb2, rgb2, rgb2, colorCoefficient2,
00269 specularCoefficient2, specularPower2, opacity2);
00270 vtkFloatingPointType lineWidth2 = 1;
00271 myMP2->SetLineWidth(lineWidth2);
00272 mitk::Material::RepresentationType representation2 = mitk::Material::Wireframe;
00273 myMP2->SetRepresentation(representation2);
00274 mitk::Material::InterpolationType interpolation2 = mitk::Material::Flat;
00275 myMP2->SetInterpolation(interpolation2);
00276 myMP2->SetSpecularColor(color2);
00277 std::string name2 = "Hans Wurst";
00278 myMP2->SetName(name2);
00279 MITK_TEST_CONDITION(*myMP == *myMP2, "testing equality Operator")
00280 }
00281 {
00282 mitk::Material::Color color;
00283 color.Set(0, 0, 0);
00284 vtkFloatingPointType opacity = 1.0f;
00285 vtkFloatingPointType rgb = 0;
00286 vtkFloatingPointType colorCoefficient = 0;
00287 vtkFloatingPointType specularCoefficient = 0;
00288 vtkFloatingPointType specularPower = 0;
00289
00290 myMP = mitk::Material::New(rgb, rgb, rgb, colorCoefficient,
00291 specularCoefficient, specularPower, opacity);
00292 vtkFloatingPointType lineWidth = 1;
00293 myMP->SetLineWidth(lineWidth);
00294 mitk::Material::RepresentationType representation = mitk::Material::Wireframe;
00295 myMP->SetRepresentation(representation);mitk::Material::InterpolationType interpolation = mitk::Material::Flat;
00296 myMP->SetInterpolation(interpolation);
00297 myMP->SetSpecularColor(color);
00298 std::string name = "Hans Wurst";
00299 myMP->SetName(name);
00300
00301
00302 mitk::Material::Color color2;
00303 color2.Set(0, 0, 0);
00304 vtkFloatingPointType opacity2 = 1.0f;
00305 vtkFloatingPointType rgb2 = 1;
00306 vtkFloatingPointType colorCoefficient2 = 0;
00307 vtkFloatingPointType specularCoefficient2 = 0;
00308 vtkFloatingPointType specularPower2 = 0;
00309
00310 mitk::Material::Pointer myMP2 = mitk::Material::New(rgb2, rgb2, rgb2, colorCoefficient2,
00311 specularCoefficient2, specularPower2, opacity2);
00312 vtkFloatingPointType lineWidth2 = 1;
00313 myMP2->SetLineWidth(lineWidth2);
00314 mitk::Material::RepresentationType representation2 = mitk::Material::Wireframe;
00315 myMP2->SetRepresentation(representation2);
00316 mitk::Material::InterpolationType interpolation2 = mitk::Material::Flat;
00317 myMP2->SetInterpolation(interpolation2);
00318 myMP2->SetSpecularColor(color2);
00319 std::string name2 = "Hans Wurst";
00320 myMP2->SetName(name2);
00321 MITK_TEST_CONDITION(!(*myMP == *myMP2), "testing equality Operator")
00322 }
00323
00324
00325 }
00326
00327 void testAssignable()
00328 {
00329 mitk::Material::Pointer materialProp = mitk::Material::New();
00330 MITK_TEST_CONDITION(myMP->Assignable(*materialProp),"testing Assignable with Material" )
00331 }
00332
00333 void testOperatorAssign()
00334 {
00335 mitk::Material::Pointer myMP2 = mitk::Material::New();
00336 *myMP2 = *myMP;
00337 MITK_TEST_CONDITION(*myMP == *myMP2, "Testing Assignment Operator")
00338 }
00339 };
00340
00341
00342
00343
00344
00345 int
00346 mitkMaterialTest(int , char* [])
00347 {
00348
00349 MITK_TEST_BEGIN("Material")
00350
00351 MaterialTest materialTest;
00352
00353 materialTest.testConstructor();
00354 materialTest.testConstructorWithColorOpacity();
00355 materialTest.testConstructorWithRedGreenBlueOpacity();
00356 materialTest.testConstructorRedGreenBlueColorCoefficientSpecularCoefficientSpecularPowerOpacity();
00357 materialTest.testConstructorColorColorCoefficientSpecularCoefficientSpecularPowerOpacity();
00358 materialTest.testConstructorPropertyRedGreenBlueOpacityAndName();
00359 materialTest.testAssignable();
00360 materialTest.testOperatorAssign();
00361 materialTest.testSetColor();
00362 materialTest.testSetColorCoefficient();
00363 materialTest.testSetSpecularColor();
00364 materialTest.testSetSpecularCoefficient();
00365 materialTest.testSetSpecularPower();
00366 materialTest.testSetOpacity();
00367 materialTest.testSetInterpolation();
00368 materialTest.testSetRepresentation();
00369 materialTest.testSetLineWidth();
00370 materialTest.testInitialize();
00371 materialTest.testOperatorequality();
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381 MITK_TEST_END ()
00382 }
00383
00384