00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "mitkPlaneGeometry.h"
00020 #include "mitkRotationOperation.h"
00021 #include "mitkInteractionConst.h"
00022
00023 #include "mitkTestingMacros.h"
00024
00025 #include <vnl/vnl_quaternion.h>
00026 #include <vnl/vnl_quaternion.txx>
00027
00028 #include <fstream>
00029
00030 int mappingTests2D(const mitk::PlaneGeometry* planegeometry, const mitk::ScalarType& width, const mitk::ScalarType& height, const mitk::ScalarType& widthInMM, const mitk::ScalarType& heightInMM, const mitk::Point3D& origin, const mitk::Vector3D& right, const mitk::Vector3D& bottom)
00031 {
00032
00033 std::cout << "Testing mapping Map(pt2d_mm(x=widthInMM/2.3,y=heightInMM/2.5), pt3d_mm) and compare with expected: ";
00034 mitk::Point2D pt2d_mm;
00035 mitk::Point3D pt3d_mm, expected_pt3d_mm;
00036 pt2d_mm[0] = widthInMM/2.3; pt2d_mm[1] = heightInMM/2.5;
00037 expected_pt3d_mm = origin+right*(pt2d_mm[0]/right.GetNorm())+bottom*(pt2d_mm[1]/bottom.GetNorm());
00038 planegeometry->Map(pt2d_mm, pt3d_mm);
00039 if(mitk::Equal(pt3d_mm, expected_pt3d_mm) == false)
00040 {
00041 std::cout<<"[FAILED]"<<std::endl;
00042 return EXIT_FAILURE;
00043 }
00044 std::cout<<"[PASSED]"<<std::endl;
00045
00046 std::cout << "Testing mapping Map(pt3d_mm, pt2d_mm) and compare with expected: ";
00047 mitk::Point2D testpt2d_mm;
00048 planegeometry->Map(pt3d_mm, testpt2d_mm);
00049 if(mitk::Equal(pt2d_mm, testpt2d_mm) == false)
00050 {
00051 std::cout<<"[FAILED]"<<std::endl;
00052 return EXIT_FAILURE;
00053 }
00054 std::cout<<"[PASSED]"<<std::endl;
00055
00056 std::cout << "Testing IndexToWorld(pt2d_units, pt2d_mm) and compare with expected: ";
00057 mitk::Point2D pt2d_units;
00058 pt2d_units[0] = width/2.0; pt2d_units[1] = height/2.0;
00059 pt2d_mm[0] = widthInMM/2.0; pt2d_mm[1] = heightInMM/2.0;
00060 planegeometry->IndexToWorld(pt2d_units, testpt2d_mm);
00061 if(mitk::Equal(pt2d_mm, testpt2d_mm) == false)
00062 {
00063 std::cout<<"[FAILED]"<<std::endl;
00064 return EXIT_FAILURE;
00065 }
00066 std::cout<<"[PASSED]"<<std::endl;
00067
00068 std::cout << "Testing WorldToIndex(pt2d_mm, pt2d_units) and compare with expected: ";
00069 mitk::Point2D testpt2d_units;
00070 planegeometry->WorldToIndex(pt2d_mm, testpt2d_units);
00071 if(mitk::Equal(pt2d_units, testpt2d_units) == false)
00072 {
00073 std::cout<<"[FAILED]"<<std::endl;
00074 return EXIT_FAILURE;
00075 }
00076 std::cout<<"[PASSED]"<<std::endl;
00077
00078 return EXIT_SUCCESS;
00079 }
00080
00081 int TestCase1210()
00082 {
00083 mitk::PlaneGeometry::Pointer planegeometry = mitk::PlaneGeometry::New();
00084
00085 mitk::Point3D origin;
00086 mitk::Vector3D right, down, spacing;
00087 mitk::ScalarType thicknessInMM;
00088
00089 thicknessInMM = 1.0;
00090 mitk::FillVector3D(origin, 4.5, 7.3, 11.2);
00091 mitk::FillVector3D(right,
00092 1.015625, 1.015625, 1.1999969482421875
00093 );
00094
00095 mitk::FillVector3D(down,
00096 1.4012984643248170709237295832899161312802619418765e-45, 0, 0
00097 );
00098 mitk::FillVector3D(spacing,
00099 0, 1.4713633875410579244699160624544119378442750389703e-43, 9.2806360452222355258639080851310540729807238879469e-32
00100 );
00101
00102 std::cout << "Testing InitializeStandardPlane(rightVector, downVector, spacing = NULL): "<<std::endl;
00103 planegeometry->InitializeStandardPlane(right, down, &spacing);
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126 std::cout<<"[PASSED]"<<std::endl;
00127
00128 return EXIT_SUCCESS;
00129 }
00130
00136 int TestProjectPointOntoPlane()
00137 {
00138 mitk::PlaneGeometry::Pointer myPlaneGeometry = mitk::PlaneGeometry::New();
00139
00140
00141 mitk::Vector3D normal;
00142 normal[0] = 0.0;
00143 normal[1] = 0.0;
00144 normal[2] = 1.0;
00145
00146
00147 mitk::Point3D origin;
00148 origin[0] = -27.582859;
00149 origin[1] = 50;
00150 origin[2] = 200.27742;
00151
00152
00153 myPlaneGeometry->InitializePlane(origin,normal);
00154
00155
00156 std::cout << "Testing PlaneGeometry according to bug #3409" << std::endl;
00157 std::cout << "Our normal is: " << normal << std::endl;
00158 std::cout << "So ALL projected points should have exactly the same z-value!" << std::endl;
00159
00160
00161 mitk::Point3D myPoints[5];
00162 myPoints[0][0] = -27.582859;
00163 myPoints[0][1] = 50.00;
00164 myPoints[0][2] = 200.27742;
00165
00166 myPoints[1][0] = -26.58662;
00167 myPoints[1][1] = 50.00;
00168 myPoints[1][2] = 200.19026;
00169
00170 myPoints[2][0] = -26.58662;
00171 myPoints[2][1] = 50.00;
00172 myPoints[2][2] = 200.33124;
00173
00174 myPoints[3][0] = 104.58662;
00175 myPoints[3][1] = 452.12313;
00176 myPoints[3][2] = 866.41236;
00177
00178 myPoints[4][0] = -207.58662;
00179 myPoints[4][1] = 312.00;
00180 myPoints[4][2] = -300.12346;
00181
00182
00183 mitk::Point3D myProjectedPoints[5];
00184 for ( unsigned int i = 0; i < 5; ++i )
00185 {
00186 myProjectedPoints[i] = myPlaneGeometry->ProjectPointOntoPlane( myPoints[i] );
00187 }
00188
00189
00190 bool allPointsOnPlane = true;
00191 for ( unsigned int i = 0; i < 5; ++i )
00192 {
00193 if ( fabs(myProjectedPoints[i][2] - origin[2]) > mitk::sqrteps )
00194 {
00195 allPointsOnPlane = false;
00196 }
00197 }
00198 if (!allPointsOnPlane)
00199 {
00200 std::cout<<"[FAILED]"<<std::endl;
00201 return EXIT_FAILURE;
00202 }
00203 else
00204 {
00205 std::cout<<"[PASSED]"<<std::endl;
00206 return EXIT_SUCCESS;
00207 }
00208 }
00209
00210 int mitkPlaneGeometryTest(int , char* [])
00211 {
00212 int result;
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222 mitk::PlaneGeometry::Pointer planegeometry = mitk::PlaneGeometry::New();
00223
00224 mitk::Point3D origin;
00225 mitk::Vector3D right, bottom, normal;
00226 mitk::ScalarType width, height;
00227 mitk::ScalarType widthInMM, heightInMM, thicknessInMM;
00228
00229 width = 100; widthInMM = width;
00230 height = 200; heightInMM = height;
00231 thicknessInMM = 1.0;
00232 mitk::FillVector3D(origin, 4.5, 7.3, 11.2);
00233 mitk::FillVector3D(right, widthInMM, 0, 0);
00234 mitk::FillVector3D(bottom, 0, heightInMM, 0);
00235 mitk::FillVector3D(normal, 0, 0, thicknessInMM);
00236
00237 std::cout << "Testing InitializeStandardPlane(rightVector, downVector, spacing = NULL): "<<std::endl;
00238 planegeometry->InitializeStandardPlane(right.Get_vnl_vector(), bottom.Get_vnl_vector());
00239
00240 std::cout << "Testing width, height and thickness (in units): ";
00241 if((mitk::Equal(planegeometry->GetExtent(0),width)==false) ||
00242 (mitk::Equal(planegeometry->GetExtent(1),height)==false) ||
00243 (mitk::Equal(planegeometry->GetExtent(2),1)==false)
00244 )
00245 {
00246 std::cout<<"[FAILED]"<<std::endl;
00247 return EXIT_FAILURE;
00248 }
00249 std::cout<<"[PASSED]"<<std::endl;
00250
00251 std::cout << "Testing width, height and thickness (in mm): ";
00252 if((mitk::Equal(planegeometry->GetExtentInMM(0),widthInMM)==false) ||
00253 (mitk::Equal(planegeometry->GetExtentInMM(1),heightInMM)==false) ||
00254 (mitk::Equal(planegeometry->GetExtentInMM(2),thicknessInMM)==false)
00255 )
00256 {
00257 std::cout<<"[FAILED]"<<std::endl;
00258 return EXIT_FAILURE;
00259 }
00260 std::cout<<"[PASSED]"<<std::endl;
00261
00262 std::cout << "Testing GetAxisVector(): ";
00263 if((mitk::Equal(planegeometry->GetAxisVector(0), right)==false) || (mitk::Equal(planegeometry->GetAxisVector(1), bottom)==false) || (mitk::Equal(planegeometry->GetAxisVector(2), normal)==false))
00264 {
00265 std::cout<<"[FAILED]"<<std::endl;
00266 return EXIT_FAILURE;
00267 }
00268 std::cout<<"[PASSED]"<<std::endl;
00269
00270
00271
00272 std::cout << "Testing InitializeStandardPlane(rightVector, downVector, spacing = {1.0, 1.0, 1.5}): "<<std::endl;
00273 mitk::Vector3D spacing;
00274 thicknessInMM = 1.5;
00275 normal.Normalize(); normal *= thicknessInMM;
00276 mitk::FillVector3D(spacing, 1.0, 1.0, thicknessInMM);
00277 planegeometry->InitializeStandardPlane(right.Get_vnl_vector(), bottom.Get_vnl_vector(), &spacing);
00278
00279 std::cout << "Testing width, height and thickness (in units): ";
00280 if((mitk::Equal(planegeometry->GetExtent(0),width)==false) ||
00281 (mitk::Equal(planegeometry->GetExtent(1),height)==false) ||
00282 (mitk::Equal(planegeometry->GetExtent(2),1)==false)
00283 )
00284 {
00285 std::cout<<"[FAILED]"<<std::endl;
00286 return EXIT_FAILURE;
00287 }
00288 std::cout<<"[PASSED]"<<std::endl;
00289
00290 std::cout << "Testing width, height and thickness (in mm): ";
00291 if((mitk::Equal(planegeometry->GetExtentInMM(0),widthInMM)==false) ||
00292 (mitk::Equal(planegeometry->GetExtentInMM(1),heightInMM)==false) ||
00293 (mitk::Equal(planegeometry->GetExtentInMM(2),thicknessInMM)==false)
00294 )
00295 {
00296 std::cout<<"[FAILED]"<<std::endl;
00297 return EXIT_FAILURE;
00298 }
00299 std::cout<<"[PASSED]"<<std::endl;
00300
00301 std::cout << "Testing GetAxisVector(): ";
00302 if((mitk::Equal(planegeometry->GetAxisVector(0), right)==false) || (mitk::Equal(planegeometry->GetAxisVector(1), bottom)==false) || (mitk::Equal(planegeometry->GetAxisVector(2), normal)==false))
00303 {
00304 std::cout<<"[FAILED]"<<std::endl;
00305 return EXIT_FAILURE;
00306 }
00307 std::cout<<"[PASSED]"<<std::endl;
00308
00309
00310
00311 std::cout << "Testing SetExtentInMM(2, ...), querying by GetExtentInMM(2): ";
00312 thicknessInMM = 3.5;
00313 normal.Normalize(); normal *= thicknessInMM;
00314 planegeometry->SetExtentInMM(2, thicknessInMM);
00315 if(mitk::Equal(planegeometry->GetExtentInMM(2),thicknessInMM)==false)
00316 {
00317 std::cout<<"[FAILED]"<<std::endl;
00318 return EXIT_FAILURE;
00319 }
00320 std::cout<<"[PASSED]"<<std::endl;
00321
00322 std::cout << "Testing SetExtentInMM(2, ...), querying by GetAxisVector(2) and comparing to normal: ";
00323 if(mitk::Equal(planegeometry->GetAxisVector(2), normal)==false)
00324 {
00325 std::cout<<"[FAILED]"<<std::endl;
00326 return EXIT_FAILURE;
00327 }
00328 std::cout<<"[PASSED]"<<std::endl;
00329
00330 std::cout << "Testing SetOrigin: ";
00331 planegeometry->SetOrigin(origin);
00332 if(mitk::Equal(planegeometry->GetOrigin(), origin)==false)
00333 {
00334 std::cout<<"[FAILED]"<<std::endl;
00335 return EXIT_FAILURE;
00336 }
00337 std::cout<<"[PASSED]"<<std::endl;
00338
00339 std::cout << "Testing GetAxisVector() after SetOrigin: ";
00340 if((mitk::Equal(planegeometry->GetAxisVector(0), right)==false) || (mitk::Equal(planegeometry->GetAxisVector(1), bottom)==false) || (mitk::Equal(planegeometry->GetAxisVector(2), normal)==false))
00341 {
00342 std::cout<<"[FAILED]"<<std::endl;
00343 return EXIT_FAILURE;
00344 }
00345 std::cout<<"[PASSED]"<<std::endl;
00346
00347 result = mappingTests2D(planegeometry, width, height, widthInMM, heightInMM, origin, right, bottom);
00348 if(result!=EXIT_SUCCESS)
00349 return result;
00350
00351
00352
00353 std::cout << "Changing the IndexToWorldTransform to a rotated version by SetIndexToWorldTransform() (keep origin): "<<std::endl;
00354 mitk::AffineTransform3D::Pointer transform = mitk::AffineTransform3D::New();
00355 mitk::AffineTransform3D::MatrixType::InternalMatrixType vnlmatrix;
00356 vnlmatrix = planegeometry->GetIndexToWorldTransform()->GetMatrix().GetVnlMatrix();
00357 mitk::VnlVector axis(3);
00358 mitk::FillVector3D(axis, 1.0, 1.0, 1.0); axis.normalize();
00359 vnl_quaternion<mitk::ScalarType> rotation(axis, 0.223);
00360 vnlmatrix = rotation.rotation_matrix_transpose()*vnlmatrix;
00361 mitk::Matrix3D matrix;
00362 matrix = vnlmatrix;
00363 transform->SetMatrix(matrix);
00364 transform->SetOffset(planegeometry->GetIndexToWorldTransform()->GetOffset());
00365
00366 right.Set_vnl_vector( rotation.rotation_matrix_transpose()*right.Get_vnl_vector() );
00367 bottom.Set_vnl_vector(rotation.rotation_matrix_transpose()*bottom.Get_vnl_vector());
00368 normal.Set_vnl_vector(rotation.rotation_matrix_transpose()*normal.Get_vnl_vector());
00369 planegeometry->SetIndexToWorldTransform(transform);
00370
00371
00372
00373
00374
00375 planegeometry->SetOrigin(origin);
00376 mitk::Point3D cornerpoint0 = planegeometry->GetCornerPoint(0);
00377
00378 std::cout << "Testing whether SetIndexToWorldTransform kept origin: ";
00379 if(mitk::Equal(planegeometry->GetOrigin(), origin)==false)
00380 {
00381 std::cout<<"[FAILED]"<<std::endl;
00382 return EXIT_FAILURE;
00383 }
00384
00385 MITK_TEST_OUTPUT( << "Testing consistancy of index and world coordinates. ");
00386 mitk::Point2D point; point[0] = 4; point[1] = 3;
00387 mitk::Point2D dummy;
00388 planegeometry->WorldToIndex(point, dummy);
00389 planegeometry->IndexToWorld(dummy, dummy);
00390 MITK_TEST_CONDITION_REQUIRED(dummy == point, "");
00391
00392 std::cout<<"[PASSED]"<<std::endl;
00393
00394 std::cout << "Testing width, height and thickness (in mm) of rotated version: ";
00395 if((mitk::Equal(planegeometry->GetExtentInMM(0),widthInMM)==false) ||
00396 (mitk::Equal(planegeometry->GetExtentInMM(1),heightInMM)==false) ||
00397 (mitk::Equal(planegeometry->GetExtentInMM(2),thicknessInMM)==false)
00398 )
00399 {
00400 std::cout<<"[FAILED]"<<std::endl;
00401 return EXIT_FAILURE;
00402 }
00403 std::cout<<"[PASSED]"<<std::endl;
00404
00405 std::cout << "Testing GetAxisVector() of rotated version: ";
00406 if((mitk::Equal(planegeometry->GetAxisVector(0), right)==false) || (mitk::Equal(planegeometry->GetAxisVector(1), bottom)==false) || (mitk::Equal(planegeometry->GetAxisVector(2), normal)==false))
00407 {
00408 std::cout<<"[FAILED]"<<std::endl;
00409 return EXIT_FAILURE;
00410 }
00411 std::cout<<"[PASSED]"<<std::endl;
00412
00413 std::cout << "Testing GetAxisVector(direction).GetNorm() != planegeometry->GetExtentInMM(direction) of rotated version: ";
00414 if((mitk::Equal(planegeometry->GetAxisVector(0).GetNorm(),planegeometry->GetExtentInMM(0))==false) ||
00415 (mitk::Equal(planegeometry->GetAxisVector(1).GetNorm(),planegeometry->GetExtentInMM(1))==false) ||
00416 (mitk::Equal(planegeometry->GetAxisVector(2).GetNorm(),planegeometry->GetExtentInMM(2))==false)
00417 )
00418 {
00419 std::cout<<"[FAILED]"<<std::endl;
00420 return EXIT_FAILURE;
00421 }
00422 std::cout<<"[PASSED]"<<std::endl;
00423
00424 result = mappingTests2D(planegeometry, width, height, widthInMM, heightInMM, origin, right, bottom);
00425 if(result!=EXIT_SUCCESS)
00426 return result;
00427
00428 std::cout << "Testing SetSizeInUnits() of rotated version: "<<std::endl;
00429 width *= 2;
00430 height *= 3;
00431 planegeometry->SetSizeInUnits(width, height);
00432
00433 std::cout << "Testing width, height and thickness (in units): ";
00434 if((mitk::Equal(planegeometry->GetExtent(0),width)==false) ||
00435 (mitk::Equal(planegeometry->GetExtent(1),height)==false) ||
00436 (mitk::Equal(planegeometry->GetExtent(2),1)==false)
00437 )
00438 {
00439 std::cout<<"[FAILED]"<<std::endl;
00440 return EXIT_FAILURE;
00441 }
00442 std::cout<<"[PASSED]"<<std::endl;
00443
00444 std::cout << "Testing width, height and thickness (in mm) of version with changed size in units: ";
00445 if(!mitk::Equal(planegeometry->GetExtentInMM(0), widthInMM) || !mitk::Equal(planegeometry->GetExtentInMM(1), heightInMM) || !mitk::Equal(planegeometry->GetExtentInMM(2), thicknessInMM))
00446 {
00447 std::cout<<"[FAILED]"<<std::endl;
00448 return EXIT_FAILURE;
00449 }
00450 std::cout<<"[PASSED]"<<std::endl;
00451
00452 std::cout << "Testing GetAxisVector() of version with changed size in units: ";
00453 if((mitk::Equal(planegeometry->GetAxisVector(0), right)==false) || (mitk::Equal(planegeometry->GetAxisVector(1), bottom)==false) || (mitk::Equal(planegeometry->GetAxisVector(2), normal)==false))
00454 {
00455 std::cout<<"[FAILED]"<<std::endl;
00456 return EXIT_FAILURE;
00457 }
00458 std::cout<<"[PASSED]"<<std::endl;
00459
00460 std::cout << "Testing GetAxisVector(direction).GetNorm() != planegeometry->GetExtentInMM(direction) of rotated version: ";
00461 if((mitk::Equal(planegeometry->GetAxisVector(0).GetNorm(),planegeometry->GetExtentInMM(0))==false) ||
00462 (mitk::Equal(planegeometry->GetAxisVector(1).GetNorm(),planegeometry->GetExtentInMM(1))==false) ||
00463 (mitk::Equal(planegeometry->GetAxisVector(2).GetNorm(),planegeometry->GetExtentInMM(2))==false)
00464 )
00465 {
00466 std::cout<<"[FAILED]"<<std::endl;
00467 return EXIT_FAILURE;
00468 }
00469 std::cout<<"[PASSED]"<<std::endl;
00470
00471 result = mappingTests2D(planegeometry, width, height, widthInMM, heightInMM, origin, right, bottom);
00472 if(result!=EXIT_SUCCESS)
00473 return result;
00474
00475
00476
00477 std::cout << "Testing Clone(): ";
00478 mitk::PlaneGeometry::Pointer clonedplanegeometry = dynamic_cast<mitk::PlaneGeometry*>(planegeometry->Clone().GetPointer());
00479 if((clonedplanegeometry.IsNull()) || (clonedplanegeometry->GetReferenceCount()!=1))
00480 {
00481 std::cout<<"[FAILED]"<<std::endl;
00482 return EXIT_FAILURE;
00483 }
00484 std::cout<<"[PASSED]"<<std::endl;
00485
00486 std::cout << "Testing origin of cloned version: ";
00487 if(mitk::Equal(clonedplanegeometry->GetOrigin(), origin)==false)
00488 {
00489 std::cout<<"[FAILED]"<<std::endl;
00490 return EXIT_FAILURE;
00491 }
00492 std::cout<<"[PASSED]"<<std::endl;
00493
00494 std::cout << "Testing width, height and thickness (in units) of cloned version: ";
00495 if((mitk::Equal(clonedplanegeometry->GetExtent(0),width)==false) ||
00496 (mitk::Equal(clonedplanegeometry->GetExtent(1),height)==false) ||
00497 (mitk::Equal(clonedplanegeometry->GetExtent(2),1)==false)
00498 )
00499 {
00500 std::cout<<"[FAILED]"<<std::endl;
00501 return EXIT_FAILURE;
00502 }
00503 std::cout<<"[PASSED]"<<std::endl;
00504
00505 std::cout << "Testing width, height and thickness (in mm) of cloned version: ";
00506 if(!mitk::Equal(clonedplanegeometry->GetExtentInMM(0), widthInMM) || !mitk::Equal(clonedplanegeometry->GetExtentInMM(1), heightInMM) || !mitk::Equal(clonedplanegeometry->GetExtentInMM(2), thicknessInMM))
00507 {
00508 std::cout<<"[FAILED]"<<std::endl;
00509 return EXIT_FAILURE;
00510 }
00511 std::cout<<"[PASSED]"<<std::endl;
00512
00513 std::cout << "Testing GetAxisVector() of cloned version: ";
00514 if((mitk::Equal(clonedplanegeometry->GetAxisVector(0), right)==false) || (mitk::Equal(clonedplanegeometry->GetAxisVector(1), bottom)==false) || (mitk::Equal(clonedplanegeometry->GetAxisVector(2), normal)==false))
00515 {
00516 std::cout<<"[FAILED]"<<std::endl;
00517 return EXIT_FAILURE;
00518 }
00519 std::cout<<"[PASSED]"<<std::endl;
00520
00521 result = mappingTests2D(clonedplanegeometry, width, height, widthInMM, heightInMM, origin, right, bottom);
00522 if(result!=EXIT_SUCCESS)
00523 return result;
00524
00525
00526
00527 std::cout << "Testing Clone(): ";
00528 mitk::PlaneGeometry::Pointer clonedplanegeometry2 = dynamic_cast<mitk::PlaneGeometry*>(planegeometry->Clone().GetPointer());
00529 if((clonedplanegeometry2.IsNull()) || (clonedplanegeometry2->GetReferenceCount()!=1))
00530 {
00531 std::cout<<"[FAILED]"<<std::endl;
00532 return EXIT_FAILURE;
00533 }
00534 std::cout << "Testing if cloned and original version are at the same place: ";
00535 if(mitk::Equal(clonedplanegeometry2->IsOnPlane(planegeometry), true) ==false)
00536 {
00537 std::cout<<"[FAILED]"<<std::endl;
00538 return EXIT_FAILURE;
00539 }
00540 std::cout<<"[PASSED]"<<std::endl;
00541
00542 std::cout << "Testing if the origin is on the plane: ";
00543 if(mitk::Equal(clonedplanegeometry2->IsOnPlane(origin), true)==false)
00544 {
00545 std::cout<<"[FAILED]"<<std::endl;
00546 return EXIT_FAILURE;
00547 }
00548 std::cout<<"[PASSED]"<<std::endl;
00549
00550 mitk::VnlVector newaxis(3);
00551 mitk::FillVector3D(newaxis, 1.0, 1.0, 1.0); newaxis.normalize();
00552 vnl_quaternion<mitk::ScalarType> rotation2(newaxis, 0.0);
00553
00554 mitk::Vector3D clonednormal = clonedplanegeometry2->GetNormal();
00555 mitk::Point3D clonedorigin = clonedplanegeometry2->GetOrigin();
00556
00557 mitk::RotationOperation* planerot = new mitk::RotationOperation( mitk::OpROTATE, origin, clonedplanegeometry2->GetAxisVector( 0 ), 180.0 );
00558
00559 clonedplanegeometry2->ExecuteOperation( planerot );
00560
00561 std::cout << "Testing whether the flipped plane is still the original plane: ";
00562 if( mitk::Equal( clonedplanegeometry2->IsOnPlane(planegeometry), true )==false )
00563 {
00564 std::cout<<"[FAILED]"<<std::endl;
00565 return EXIT_FAILURE;
00566 }
00567 std::cout<<"[PASSED]"<<std::endl;
00568
00569 clonedorigin += clonednormal;
00570 clonedplanegeometry2->SetOrigin( clonedorigin );
00571
00572 std::cout << "Testing if the translated (cloned, flipped) plane is parallel to its origin plane: ";
00573 if( mitk::Equal( clonedplanegeometry2->IsParallel(planegeometry), true )==false )
00574 {
00575 std::cout<<"[FAILED]"<<std::endl;
00576 return EXIT_FAILURE;
00577 }
00578 std::cout<<"[PASSED]"<<std::endl;
00579
00580
00581 delete planerot;
00582
00583 planerot = new mitk::RotationOperation( mitk::OpROTATE, origin, clonedplanegeometry2->GetAxisVector( 0 ), 0.5 );
00584 clonedplanegeometry2->ExecuteOperation( planerot );
00585
00586 std::cout << "Testing if a non-paralell plane gets recognized as not paralell [rotation +0.5 degree] : ";
00587 if( mitk::Equal( clonedplanegeometry2->IsParallel(planegeometry), false )==false )
00588 {
00589 std::cout<<"[FAILED]"<<std::endl;
00590 return EXIT_FAILURE;
00591 }
00592 std::cout<<"[PASSED]"<<std::endl;
00593
00594 delete planerot;
00595
00596 planerot = new mitk::RotationOperation( mitk::OpROTATE, origin, clonedplanegeometry2->GetAxisVector( 0 ), -1.0 );
00597 clonedplanegeometry2->ExecuteOperation( planerot );
00598
00599 std::cout << "Testing if a non-paralell plane gets recognized as not paralell [rotation -0.5 degree] : ";
00600 if( mitk::Equal( clonedplanegeometry2->IsParallel(planegeometry), false )==false )
00601 {
00602 std::cout<<"[FAILED]"<<std::endl;
00603 return EXIT_FAILURE;
00604 }
00605 std::cout<<"[PASSED]"<<std::endl;
00606
00607 delete planerot;
00608
00609 planerot = new mitk::RotationOperation( mitk::OpROTATE, origin, clonedplanegeometry2->GetAxisVector( 0 ), 360.5 );
00610 clonedplanegeometry2->ExecuteOperation( planerot );
00611
00612 std::cout << "Testing if a non-paralell plane gets recognized as not paralell [rotation 360 degree] : ";
00613 if( mitk::Equal( clonedplanegeometry2->IsParallel(planegeometry), true )==false )
00614 {
00615 std::cout<<"[FAILED]"<<std::endl;
00616 return EXIT_FAILURE;
00617 }
00618 std::cout<<"[PASSED]"<<std::endl;
00619
00620
00621 std::cout << "Testing InitializeStandardPlane(clonedplanegeometry, planeorientation = Transversal, zPosition = 0, frontside=true): " <<std::endl;
00622 planegeometry->InitializeStandardPlane(clonedplanegeometry);
00623
00624 std::cout << "Testing origin of transversally initialized version: ";
00625 if(mitk::Equal(planegeometry->GetOrigin(), origin)==false)
00626 {
00627 std::cout<<"[FAILED]"<<std::endl;
00628 return EXIT_FAILURE;
00629 }
00630 std::cout<<"[PASSED]"<<std::endl;
00631
00632 std::cout << "Testing GetCornerPoint(0) of transversally initialized version: ";
00633 if(mitk::Equal(planegeometry->GetCornerPoint(0), cornerpoint0)==false)
00634 {
00635 std::cout<<"[FAILED]"<<std::endl;
00636 return EXIT_FAILURE;
00637 }
00638 std::cout<<"[PASSED]"<<std::endl;
00639
00640 std::cout << "Testing width, height and thickness (in units) of transversally initialized version (should be same as in mm due to unit spacing, except for thickness, which is always 1): ";
00641 if(!mitk::Equal(planegeometry->GetExtent(0), width) || !mitk::Equal(planegeometry->GetExtent(1), height) || !mitk::Equal(planegeometry->GetExtent(2), 1))
00642 {
00643 std::cout<<"[FAILED]"<<std::endl;
00644 return EXIT_FAILURE;
00645 }
00646 std::cout<<"[PASSED]"<<std::endl;
00647
00648 std::cout << "Testing width, height and thickness (in mm) of transversally initialized version: ";
00649 if(!mitk::Equal(planegeometry->GetExtentInMM(0), widthInMM) || !mitk::Equal(planegeometry->GetExtentInMM(1), heightInMM) || !mitk::Equal(planegeometry->GetExtentInMM(2), thicknessInMM))
00650 {
00651 std::cout<<"[FAILED]"<<std::endl;
00652 return EXIT_FAILURE;
00653 }
00654 std::cout<<"[PASSED]"<<std::endl;
00655
00656 std::cout << "Testing GetAxisVector() of transversally initialized version: ";
00657 if((mitk::Equal(planegeometry->GetAxisVector(0), right)==false) || (mitk::Equal(planegeometry->GetAxisVector(1), bottom)==false) || (mitk::Equal(planegeometry->GetAxisVector(2), normal)==false))
00658 {
00659 std::cout<<"[FAILED]"<<std::endl;
00660 return EXIT_FAILURE;
00661 }
00662 std::cout<<"[PASSED]"<<std::endl;
00663
00664 result = mappingTests2D(planegeometry, width, height, widthInMM, heightInMM, origin, right, bottom);
00665 if(result!=EXIT_SUCCESS)
00666 return result;
00667
00668
00669
00670 mitk::Vector3D newright, newbottom, newnormal;
00671 mitk::ScalarType newthicknessInMM;
00672 std::cout << "Testing InitializeStandardPlane(clonedplanegeometry, planeorientation = Frontal, zPosition = 0, frontside=true): " <<std::endl;
00673 planegeometry->InitializeStandardPlane(clonedplanegeometry, mitk::PlaneGeometry::Frontal);
00674 newright = right;
00675 newbottom = normal; newbottom.Normalize(); newbottom *= thicknessInMM;
00676 newthicknessInMM = heightInMM/height*1.0;
00677 newnormal = -bottom; newnormal.Normalize(); newnormal *= newthicknessInMM;
00678
00679 std::cout << "Testing GetCornerPoint(0) of frontally initialized version: ";
00680 if(mitk::Equal(planegeometry->GetCornerPoint(0), cornerpoint0)==false)
00681 {
00682 std::cout<<"[FAILED]"<<std::endl;
00683 return EXIT_FAILURE;
00684 }
00685 std::cout<<"[PASSED]"<<std::endl;
00686
00687 origin = planegeometry->GetOrigin();
00688
00689 std::cout << "Testing width, height and thickness (in units) of frontally initialized version: ";
00690 if(!mitk::Equal(planegeometry->GetExtent(0), width) || !mitk::Equal(planegeometry->GetExtent(1), 1) || !mitk::Equal(planegeometry->GetExtent(2), 1))
00691 {
00692 std::cout<<"[FAILED]"<<std::endl;
00693 return EXIT_FAILURE;
00694 }
00695 std::cout<<"[PASSED]"<<std::endl;
00696
00697 std::cout << "Testing width, height and thickness (in mm) of frontally initialized version: ";
00698 if(!mitk::Equal(planegeometry->GetExtentInMM(0), widthInMM) || !mitk::Equal(planegeometry->GetExtentInMM(1), thicknessInMM) || !mitk::Equal(planegeometry->GetExtentInMM(2), newthicknessInMM))
00699 {
00700 std::cout<<"[FAILED]"<<std::endl;
00701 return EXIT_FAILURE;
00702 }
00703 std::cout<<"[PASSED]"<<std::endl;
00704
00705 std::cout << "Testing GetAxisVector() of frontally initialized version: ";
00706 if((mitk::Equal(planegeometry->GetAxisVector(0), newright)==false) || (mitk::Equal(planegeometry->GetAxisVector(1), newbottom)==false) || (mitk::Equal(planegeometry->GetAxisVector(2), newnormal)==false))
00707 {
00708 std::cout<<"[FAILED]"<<std::endl;
00709 return EXIT_FAILURE;
00710 }
00711 std::cout<<"[PASSED]"<<std::endl;
00712
00713 result = mappingTests2D(planegeometry, width, 1, widthInMM, thicknessInMM, origin, newright, newbottom);
00714 if(result!=EXIT_SUCCESS)
00715 return result;
00716
00717
00718
00719 std::cout << "Changing plane to in-plane unit spacing using SetSizeInUnits: " <<std::endl;
00720 planegeometry->SetSizeInUnits(planegeometry->GetExtentInMM(0), planegeometry->GetExtentInMM(1));
00721
00722 std::cout << "Testing origin of unit spaced, frontally initialized version: ";
00723 if(mitk::Equal(planegeometry->GetOrigin(), origin)==false)
00724 {
00725 std::cout<<"[FAILED]"<<std::endl;
00726 return EXIT_FAILURE;
00727 }
00728 std::cout<<"[PASSED]"<<std::endl;
00729
00730 std::cout << "Testing width, height and thickness (in units) of unit spaced, frontally initialized version: ";
00731 if(!mitk::Equal(planegeometry->GetExtent(0), widthInMM) || !mitk::Equal(planegeometry->GetExtent(1), thicknessInMM) || !mitk::Equal(planegeometry->GetExtent(2), 1))
00732 {
00733 std::cout<<"[FAILED]"<<std::endl;
00734 return EXIT_FAILURE;
00735 }
00736 std::cout<<"[PASSED]"<<std::endl;
00737
00738 std::cout << "Testing width, height and thickness (in mm) of unit spaced, frontally initialized version: ";
00739 if(!mitk::Equal(planegeometry->GetExtentInMM(0), widthInMM) || !mitk::Equal(planegeometry->GetExtentInMM(1), thicknessInMM) || !mitk::Equal(planegeometry->GetExtentInMM(2), newthicknessInMM))
00740 {
00741 std::cout<<"[FAILED]"<<std::endl;
00742 return EXIT_FAILURE;
00743 }
00744 std::cout<<"[PASSED]"<<std::endl;
00745
00746 std::cout << "Testing GetAxisVector() of unit spaced, frontally initialized version: ";
00747 if((mitk::Equal(planegeometry->GetAxisVector(0), newright)==false) || (mitk::Equal(planegeometry->GetAxisVector(1), newbottom)==false) || (mitk::Equal(planegeometry->GetAxisVector(2), newnormal)==false))
00748 {
00749 std::cout<<"[FAILED]"<<std::endl;
00750 return EXIT_FAILURE;
00751 }
00752 std::cout<<"[PASSED]"<<std::endl;
00753
00754 result = mappingTests2D(planegeometry, widthInMM, thicknessInMM, widthInMM, thicknessInMM, origin, newright, newbottom);
00755 if(result!=EXIT_SUCCESS)
00756 return result;
00757
00758
00759
00760 std::cout << "Changing plane to unit spacing also in normal direction using SetExtentInMM(2, 1.0): " <<std::endl;
00761 planegeometry->SetExtentInMM(2, 1.0);
00762 newnormal.Normalize();
00763
00764 std::cout << "Testing origin of unit spaced, frontally initialized version: ";
00765 if(mitk::Equal(planegeometry->GetOrigin(), origin)==false)
00766 {
00767 std::cout<<"[FAILED]"<<std::endl;
00768 return EXIT_FAILURE;
00769 }
00770 std::cout<<"[PASSED]"<<std::endl;
00771
00772 std::cout << "Testing width, height and thickness (in units) of unit spaced, frontally initialized version: ";
00773 if(!mitk::Equal(planegeometry->GetExtent(0), widthInMM) || !mitk::Equal(planegeometry->GetExtent(1), thicknessInMM) || !mitk::Equal(planegeometry->GetExtent(2), 1))
00774 {
00775 std::cout<<"[FAILED]"<<std::endl;
00776 return EXIT_FAILURE;
00777 }
00778 std::cout<<"[PASSED]"<<std::endl;
00779
00780 std::cout << "Testing width, height and thickness (in mm) of unit spaced, frontally initialized version: ";
00781 if(!mitk::Equal(planegeometry->GetExtentInMM(0), widthInMM) || !mitk::Equal(planegeometry->GetExtentInMM(1), thicknessInMM) || !mitk::Equal(planegeometry->GetExtentInMM(2), 1.0))
00782 {
00783 std::cout<<"[FAILED]"<<std::endl;
00784 return EXIT_FAILURE;
00785 }
00786 std::cout<<"[PASSED]"<<std::endl;
00787
00788 std::cout << "Testing GetAxisVector() of unit spaced, frontally initialized version: ";
00789 if((mitk::Equal(planegeometry->GetAxisVector(0), newright)==false) || (mitk::Equal(planegeometry->GetAxisVector(1), newbottom)==false) || (mitk::Equal(planegeometry->GetAxisVector(2), newnormal)==false))
00790 {
00791 std::cout<<"[FAILED]"<<std::endl;
00792 return EXIT_FAILURE;
00793 }
00794 std::cout<<"[PASSED]"<<std::endl;
00795
00796 result = mappingTests2D(planegeometry, widthInMM, thicknessInMM, widthInMM, thicknessInMM, origin, newright, newbottom);
00797 if(result!=EXIT_SUCCESS)
00798 return result;
00799
00800
00801
00802 std::cout << "Testing InitializeStandardPlane(clonedplanegeometry, planeorientation = Sagittal, zPosition = 0, frontside=true): " <<std::endl;
00803 planegeometry->InitializeStandardPlane(clonedplanegeometry, mitk::PlaneGeometry::Sagittal);
00804 newright = bottom;
00805 newthicknessInMM = widthInMM/width*1.0;
00806 newnormal = right; newnormal.Normalize(); newnormal *= newthicknessInMM;
00807
00808 std::cout << "Testing GetCornerPoint(0) of sagitally initialized version: ";
00809 if(mitk::Equal(planegeometry->GetCornerPoint(0), cornerpoint0)==false)
00810 {
00811 std::cout<<"[FAILED]"<<std::endl;
00812 return EXIT_FAILURE;
00813 }
00814 std::cout<<"[PASSED]"<<std::endl;
00815
00816 origin = planegeometry->GetOrigin();
00817
00818 std::cout << "Testing width, height and thickness (in units) of sagitally initialized version: ";
00819 if(!mitk::Equal(planegeometry->GetExtent(0), height) || !mitk::Equal(planegeometry->GetExtent(1), 1) || !mitk::Equal(planegeometry->GetExtent(2), 1))
00820 {
00821 std::cout<<"[FAILED]"<<std::endl;
00822 return EXIT_FAILURE;
00823 }
00824 std::cout<<"[PASSED]"<<std::endl;
00825
00826 std::cout << "Testing width, height and thickness (in mm) of sagitally initialized version: ";
00827 if(!mitk::Equal(planegeometry->GetExtentInMM(0), heightInMM) || !mitk::Equal(planegeometry->GetExtentInMM(1), thicknessInMM) || !mitk::Equal(planegeometry->GetExtentInMM(2), newthicknessInMM))
00828 {
00829 std::cout<<"[FAILED]"<<std::endl;
00830 return EXIT_FAILURE;
00831 }
00832 std::cout<<"[PASSED]"<<std::endl;
00833
00834 std::cout << "Testing GetAxisVector() of sagitally initialized version: ";
00835 if((mitk::Equal(planegeometry->GetAxisVector(0), newright)==false) || (mitk::Equal(planegeometry->GetAxisVector(1), newbottom)==false) || (mitk::Equal(planegeometry->GetAxisVector(2), newnormal)==false))
00836 {
00837 std::cout<<"[FAILED]"<<std::endl;
00838 return EXIT_FAILURE;
00839 }
00840 std::cout<<"[PASSED]"<<std::endl;
00841
00842 result = mappingTests2D(planegeometry, height, 1, heightInMM, thicknessInMM, origin, newright, newbottom);
00843 if(result!=EXIT_SUCCESS)
00844 return result;
00845
00846
00847
00848
00849 origin = clonedplanegeometry->GetOrigin();
00850 std::cout << "Testing backside initialization: InitializeStandardPlane(clonedplanegeometry, planeorientation = Transversal, zPosition = 0, frontside=false, rotated=true): " <<std::endl;
00851 planegeometry->InitializeStandardPlane(clonedplanegeometry, mitk::PlaneGeometry::Transversal, 0, false, true);
00852 mitk::Point3D backsideorigin;
00853 backsideorigin=origin+clonedplanegeometry->GetAxisVector(1);
00854
00855 std::cout << "Testing origin of backsidedly, transversally initialized version: ";
00856 if(mitk::Equal(planegeometry->GetOrigin(), backsideorigin)==false)
00857 {
00858 std::cout<<"[FAILED]"<<std::endl;
00859 return EXIT_FAILURE;
00860 }
00861 std::cout<<"[PASSED]"<<std::endl;
00862
00863 std::cout << "Testing GetCornerPoint(0) of sagitally initialized version: ";
00864 mitk::Point3D backsidecornerpoint0;
00865 backsidecornerpoint0 = cornerpoint0+clonedplanegeometry->GetAxisVector(1);
00866 if(mitk::Equal(planegeometry->GetCornerPoint(0), backsidecornerpoint0)==false)
00867 {
00868 std::cout<<"[FAILED]"<<std::endl;
00869 return EXIT_FAILURE;
00870 }
00871 std::cout<<"[PASSED]"<<std::endl;
00872
00873 std::cout << "Testing width, height and thickness (in units) of backsidedly, transversally initialized version (should be same as in mm due to unit spacing, except for thickness, which is always 1): ";
00874 if(!mitk::Equal(planegeometry->GetExtent(0), width) || !mitk::Equal(planegeometry->GetExtent(1), height) || !mitk::Equal(planegeometry->GetExtent(2), 1))
00875 {
00876 std::cout<<"[FAILED]"<<std::endl;
00877 return EXIT_FAILURE;
00878 }
00879 std::cout<<"[PASSED]"<<std::endl;
00880
00881 std::cout << "Testing width, height and thickness (in mm) of backsidedly, transversally initialized version: ";
00882 if(!mitk::Equal(planegeometry->GetExtentInMM(0), widthInMM) || !mitk::Equal(planegeometry->GetExtentInMM(1), heightInMM) || !mitk::Equal(planegeometry->GetExtentInMM(2), thicknessInMM))
00883 {
00884 std::cout<<"[FAILED]"<<std::endl;
00885 return EXIT_FAILURE;
00886 }
00887 std::cout<<"[PASSED]"<<std::endl;
00888
00889 std::cout << "Testing GetAxisVector() of backsidedly, transversally initialized version: ";
00890 if((mitk::Equal(planegeometry->GetAxisVector(0), right)==false) || (mitk::Equal(planegeometry->GetAxisVector(1), -bottom)==false) || (mitk::Equal(planegeometry->GetAxisVector(2), -normal)==false))
00891 {
00892 std::cout<<"[FAILED]"<<std::endl;
00893 return EXIT_FAILURE;
00894 }
00895 std::cout<<"[PASSED]"<<std::endl;
00896
00897 result = mappingTests2D(planegeometry, width, height, widthInMM, heightInMM, backsideorigin, right, -bottom);
00898 if(result!=EXIT_SUCCESS)
00899 return result;
00900
00901
00902
00903
00904 result = TestProjectPointOntoPlane();
00905 if(result!=EXIT_SUCCESS)
00906 return result;
00907
00908
00909 std::cout<<"[TEST DONE]"<<std::endl;
00910 return EXIT_SUCCESS;
00911 }