diff --git a/Core/Code/Testing/mitkTypeConversionTest.cpp b/Core/Code/Testing/mitkTypeConversionTest.cpp index 43167954ab..fe9beb637a 100644 --- a/Core/Code/Testing/mitkTypeConversionTest.cpp +++ b/Core/Code/Testing/mitkTypeConversionTest.cpp @@ -1,134 +1,134 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkTestingMacros.h" #include "mitkVector.h" #include "itkPoint.h" #include "vtkPoints.h" #include "vtkSmartPointer.h" #include "vnl/vnl_vector_ref.h" #include using namespace mitk; -static mitk::Point3D point3D; -static itk::Point itkPoint3D; +static mitk::Point3D point3D; +static itk::Point itkPoint3D; static vtkSmartPointer a_vtkPoints = vtkSmartPointer::New(); -//static vnl_vector_fixed vnl_vector; +static const ScalarType originalValues[] = {1.0, 2.0, 3.0}; +static const ScalarType copiedValues[] = {4.0, 5.0, 6.0}; static void Setup(void) { - const ScalarType mitkValues[]= {1.0, 2.0, 3.0}; /* the values for the mitk point */ - const double othersValues[] = {4.0, 5.0, 6.0}; /* the values for all other data representations */ - - point3D = mitkValues; - itkPoint3D = othersValues; - a_vtkPoints->Initialize(); - a_vtkPoints->InsertNextPoint(othersValues); - - - //vnl_vector.copy_in(othersValues2); } static void Test_Mitk2Itk_PointCompatibility() { Setup(); - const itk::Point copiedPoint = point3D; - MITK_TEST_CONDITION( - Equal(copiedPoint[0], point3D[0]) - && Equal(copiedPoint[1], point3D[1]) - && Equal(copiedPoint[2], point3D[2]), "mitk point assigned to itk point") + itkPoint3D = originalValues; + point3D = copiedValues; + + itkPoint3D = point3D; + + MITK_TEST_CONDITION(itkPoint3D == point3D, "mitk point assigned to itk point") + MITK_TEST_CONDITION(itkPoint3D == copiedValues, "correct values were assigned") } static void Test_Itk2Mitk_PointCompatibility() { Setup(); - const mitk::Point3D copiedPoint = itkPoint3D; + point3D = originalValues; + itkPoint3D = copiedValues; + + point3D = itkPoint3D; - MITK_TEST_CONDITION( - Equal(copiedPoint[0], itkPoint3D[0]) - && Equal(copiedPoint[1], itkPoint3D[1]) - && Equal(copiedPoint[2], itkPoint3D[2]), "itk point assigned to mitk point") + MITK_TEST_CONDITION(point3D == itkPoint3D, "itk point assigned to mitk point") + MITK_TEST_CONDITION(point3D == copiedValues, "correct values were assigned") } static void Test_Vtk2Mitk_PointCompatibility() { Setup(); + point3D = originalValues; + a_vtkPoints->InsertNextPoint(copiedValues); + double vtkPoint[3]; a_vtkPoints->GetPoint(0, vtkPoint); - //mitk::Point3D copiedPoint = vtkPoint; + point3D = vtkPoint; - MITK_TEST_CONDITION(false, "this test is passed if there is no compile error in this method when not commented out :)") + MITK_TEST_CONDITION(point3D == vtkPoint, "vtkPoint assigned to mitk point") + MITK_TEST_CONDITION(point3D == copiedValues, "correct values were assigned") } static void Test_Vnl2Mitk_PointCompatibility() { Setup(); - Point3D copiedPoint; + point3D = originalValues; + vnl_vector_fixed vnlVectorFixed(copiedValues); // copiedPoint = vnl2mitk(vnl_vector); //MITK_TEST_CONDITION( // Equal(copiedPoint[0], static_cast(vnl_vector[0])) // && Equal(copiedPoint[1], static_cast(vnl_vector[1])) // && Equal(copiedPoint[2], static_cast(vnl_vector[2])), "vnl point assigned to mitk point") } static void Test_Mitk2Vnl_PointCompatibility() { Setup(); //vnl_vector_fixed copiedPoint; // copiedPoint = mitk2vnl(point3D); //MITK_TEST_CONDITION( // Equal(static_cast(copiedPoint[0]), point3D[0]) // && Equal(static_cast(copiedPoint[1]), point3D[1]) // && Equal(static_cast(copiedPoint[2]), point3D[2]), "mitk point assigned to vnl point") } + /** - * Test the conversions from and to mitk types - */ +* Test the conversions from and to mitk types +*/ int mitkTypeConversionTest(int /*argc*/ , char* /*argv*/[]) { // always start with this! MITK_TEST_BEGIN("TypeConversionTest") Test_Mitk2Itk_PointCompatibility(); Test_Itk2Mitk_PointCompatibility(); Test_Vtk2Mitk_PointCompatibility(); Test_Vnl2Mitk_PointCompatibility(); Test_Mitk2Vnl_PointCompatibility(); MITK_TEST_END() }