void GetGridGeometryFromNode(const mitk::DataNode* regNode, mitk::Geometry3D::Pointer& gridDesc, unsigned int& gridFrequ) { int internalFrequ = 1; if(!regNode->GetIntProperty(mitk::nodeProp_RegVisGridFrequence,internalFrequ)) { mitkThrow() << "Cannot configure node correctly. Node property "<<mitk::nodeProp_RegVisGridFrequence<<" is not correctly defined."; } mitk::Vector3DProperty* valueProp = NULL; mitk::Vector3D size; mitk::Vector3D spacing; if (regNode->GetProperty(valueProp, mitk::nodeProp_RegVisFOVSize)) { size = valueProp->GetValue(); } else { mitkThrow() << "Cannot configure node correctly. Node property "<<mitk::nodeProp_RegVisFOVSize<<" is not correctly defined."; } if (regNode->GetProperty(valueProp, mitk::nodeProp_RegVisFOVSpacing)) { spacing = valueProp->GetValue(); } else { mitkThrow() << "Cannot configure node correctly. Node property "<<mitk::nodeProp_RegVisFOVSpacing<<" is not correctly defined."; } mitk::Point3dProperty* originProp = NULL; mitk::Point3D origin; if (regNode->GetProperty(originProp, mitk::nodeProp_RegVisFOVOrigin)) { origin = originProp->GetValue(); } else { mitkThrow() << "Cannot configure node correctly. Node property "<<mitk::nodeProp_RegVisFOVOrigin<<" is not correctly defined."; } gridDesc = mitk::Geometry3D::New(); mitk::Geometry3D::BoundsArrayType bounds = gridDesc->GetBounds(); bounds[0] = 0; bounds[1] = size[0]/spacing[0]; bounds[2] = 0; bounds[3] = size[1]/spacing[1]; bounds[4] = 0; bounds[5] = size[2]/spacing[2]; gridDesc->SetBounds(bounds); gridDesc->SetSpacing(spacing); gridDesc->SetOrigin(origin); gridFrequ = internalFrequ; }
void Equal_DifferentBoundingBox_ReturnsFalse() { //create different bounds to make the comparison false mitk::ScalarType bounds[ ] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; m_AnotherGeometry3D->SetBounds(bounds); MITK_ASSERT_NOT_EQUAL( m_Geometry3D, m_AnotherGeometry3D, "Bounds are different. Result should be false."); }
void Equal_DifferentOrigin_ReturnsFalse() { mitk::Point3D origin; origin[0] = 0.0; origin[1] = 0.0; origin[2] = 1.0 + 2*mitk::eps; m_AnotherGeometry3D->SetOrigin(origin); MITK_ASSERT_NOT_EQUAL( m_Geometry3D, m_AnotherGeometry3D, "Origin was modified. Result should be false."); }
void Equal_DifferentSpacing_ReturnsFalse() { mitk::Vector3D differentSpacing; differentSpacing[0] = 1.0; differentSpacing[1] = 1.0 + 2*mitk::eps; differentSpacing[2] = 1.0; m_AnotherGeometry3D->SetSpacing(differentSpacing); MITK_ASSERT_NOT_EQUAL( m_Geometry3D, m_AnotherGeometry3D, "Spacing was modified. Result should be false."); }
void Equal_DifferentIndexToWorldTransform_ReturnsFalse() { //Create another index to world transform and make it different somehow mitk::AffineTransform3D::Pointer differentIndexToWorldTransform = mitk::AffineTransform3D::New(); mitk::AffineTransform3D::MatrixType differentMatrix; differentMatrix.SetIdentity(); differentMatrix(1,1) = 2; differentIndexToWorldTransform->SetMatrix( differentMatrix ); m_AnotherGeometry3D->SetIndexToWorldTransform(differentIndexToWorldTransform); MITK_ASSERT_NOT_EQUAL( m_Geometry3D, m_AnotherGeometry3D, "IndexToWorldTransform was modified. Result should be false."); }
void Equal_DifferentImageGeometry_ReturnsFalse() { m_AnotherGeometry3D->SetImageGeometry(true); MITK_ASSERT_NOT_EQUAL( m_Geometry3D, m_AnotherGeometry3D, "One Geometry is image, the other is not. Result should be false."); }
/** * @brief Setup Always call this method before each Test-case to ensure correct and new intialization of the used members for a new test case. (If the members are not used in a test, the method does not need to be called). */ void setUp() override { m_Geometry3D = mitk::Geometry3D::New(); m_Geometry3D->Initialize(); m_AnotherGeometry3D = m_Geometry3D->Clone(); }
int compareGeometry(const mitk::TimeGeometry & timeGeometry, const mitk::ScalarType& width, const mitk::ScalarType& height, const mitk::ScalarType& numSlices, const mitk::ScalarType& widthInMM, const mitk::ScalarType& heightInMM, const mitk::ScalarType& thicknessInMM, const mitk::Point3D& cornerpoint0, const mitk::Vector3D& right, const mitk::Vector3D& bottom, const mitk::Vector3D& normal) { //Probleme durch umstellung von Time-SlicedGeometry auf TimeGeometry? //Eventuell gibt es keine Entsprechung mehr. const mitk::Geometry3D::Pointer geometry= timeGeometry.GetGeometryForTimeStep(0); std::cout << "Testing width, height and thickness (in units): "; if((mitk::Equal(geometry->GetExtent(0),width)==false) || (mitk::Equal(geometry->GetExtent(1),height)==false) || (mitk::Equal(geometry->GetExtent(2),numSlices)==false) ) { std::cout<<"[FAILED]"<<std::endl; return EXIT_FAILURE; } std::cout<<"[PASSED]"<<std::endl; std::cout << "Testing width, height and thickness (in mm): "; if((mitk::Equal(geometry->GetExtentInMM(0),widthInMM)==false) || (mitk::Equal(geometry->GetExtentInMM(1),heightInMM)==false) || (mitk::Equal(geometry->GetExtentInMM(2),thicknessInMM)==false) ) { std::cout<<"[FAILED]"<<std::endl; return EXIT_FAILURE; } std::cout<<"[PASSED]"<<std::endl; std::cout << "Testing GetAxisVector(): "; std::cout << "dir=0 "; mitk::Vector3D dv; dv=right; dv.Normalize(); dv*=widthInMM; if((mitk::Equal(geometry->GetAxisVector(0), dv)==false)) { std::cout<<"[FAILED]"<<std::endl; return EXIT_FAILURE; } std::cout<<"[PASSED]"; std::cout << ", dir=1 "; dv=bottom; dv.Normalize(); dv*=heightInMM; if((mitk::Equal(geometry->GetAxisVector(1), dv)==false)) { std::cout<<"[FAILED]"<<std::endl; return EXIT_FAILURE; } std::cout<<"[PASSED]"; std::cout << ", dir=2 "; dv=normal; dv.Normalize(); dv*=thicknessInMM; if((mitk::Equal(geometry->GetAxisVector(2), dv)==false)) { std::cout<<"[FAILED]"<<std::endl; return EXIT_FAILURE; } std::cout<<"[PASSED]"<<std::endl; std::cout << "Testing offset: "; if((mitk::Equal(geometry->GetCornerPoint(0),cornerpoint0, (double) vnl_math::float_eps)==false)) { std::cout<<"[FAILED]"<<std::endl; return EXIT_FAILURE; } std::cout<<"[PASSED]"<<std::endl; return EXIT_SUCCESS; }