MCPcopy Create free account
hub / github.com/MITK/MITK / testGeometryAfterCasting

Function testGeometryAfterCasting

Modules/Core/test/mitkGeometry3DTest.cpp:410–600  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

408}
409
410int testGeometryAfterCasting()
411{
412 // Epsilon. Allowed difference for rotationvalue
413 float eps = 0.0001;
414
415 // Cast ITK and MITK images and see if geometry stays
416 typedef itk::Image<char, 2> Image2DType;
417 typedef itk::Image<char, 3> Image3DType;
418
419 // Create 3D ITK Image from Scratch, cast to 3D MITK image, compare Geometries
420 Image3DType::Pointer image3DItk = Image3DType::New();
421 Image3DType::RegionType myRegion;
422 Image3DType::SizeType mySize;
423 Image3DType::IndexType myIndex;
424 Image3DType::SpacingType mySpacing;
425 Image3DType::DirectionType myDirection, rotMatrixX, rotMatrixY, rotMatrixZ;
426 mySpacing[0] = 31;
427 mySpacing[1] = 0.1;
428 mySpacing[2] = 2.9;
429 myIndex[0] = -15;
430 myIndex[1] = 15;
431 myIndex[2] = 12;
432 mySize[0] = 10;
433 mySize[1] = 2;
434 mySize[2] = 5;
435 myRegion.SetSize(mySize);
436 myRegion.SetIndex(myIndex);
437 image3DItk->SetSpacing(mySpacing);
438 image3DItk->SetRegions(myRegion);
439 image3DItk->Allocate();
440 image3DItk->FillBuffer(0);
441
442 myDirection.SetIdentity();
443 rotMatrixX.SetIdentity();
444 rotMatrixY.SetIdentity();
445 rotMatrixZ.SetIdentity();
446
447 mitk::Image::Pointer mitkImage;
448
449 // direction [row] [column]
450 MITK_TEST_OUTPUT(<< "Casting a rotated 3D ITK Image to a MITK Image and check if Geometry is still same");
451 for (double rotX = 0; rotX < itk::Math::pi * 2; rotX += itk::Math::pi * 0.4)
452 {
453 // Set Rotation X
454 rotMatrixX[1][1] = cos(rotX);
455 rotMatrixX[1][2] = -sin(rotX);
456 rotMatrixX[2][1] = sin(rotX);
457 rotMatrixX[2][2] = cos(rotX);
458
459 for (double rotY = 0; rotY < itk::Math::pi * 2; rotY += itk::Math::pi * 0.3)
460 {
461 // Set Rotation Y
462 rotMatrixY[0][0] = cos(rotY);
463 rotMatrixY[0][2] = sin(rotY);
464 rotMatrixY[2][0] = -sin(rotY);
465 rotMatrixY[2][2] = cos(rotY);
466
467 for (double rotZ = 0; rotZ < itk::Math::pi * 2; rotZ += itk::Math::pi * 0.2)

Callers 1

mitkGeometry3DTestFunction · 0.85

Calls 11

CastToMitkImageFunction · 0.85
SetIndexMethod · 0.80
SetDirectionMethod · 0.80
GetMatrixMethod · 0.80
GetGeometryMethod · 0.80
NewFunction · 0.50
SetSizeMethod · 0.45
SetSpacingMethod · 0.45
SetIdentityMethod · 0.45
GetSpacingMethod · 0.45

Tested by

no test coverage detected