diff --git a/Core/Code/Testing/files.cmake b/Core/Code/Testing/files.cmake index af16140c09..36d733ca02 100644 --- a/Core/Code/Testing/files.cmake +++ b/Core/Code/Testing/files.cmake @@ -1,154 +1,156 @@ # tests with no extra command line parameter set(MODULE_TESTS mitkAccessByItkTest.cpp mitkCoreObjectFactoryTest.cpp mitkMaterialTest.cpp mitkActionTest.cpp mitkDispatcherTest.cpp mitkEnumerationPropertyTest.cpp mitkEventTest.cpp mitkFocusManagerTest.cpp mitkGenericPropertyTest.cpp mitkGeometry3DTest.cpp mitkGeometryDataToSurfaceFilterTest.cpp mitkGlobalInteractionTest.cpp mitkImageDataItemTest.cpp #mitkImageMapper2DTest.cpp mitkImageGeneratorTest.cpp mitkBaseDataTest.cpp #mitkImageToItkTest.cpp mitkImportItkImageTest.cpp mitkGrabItkImageMemoryTest.cpp mitkInstantiateAccessFunctionTest.cpp mitkInteractorTest.cpp #mitkITKThreadingTest.cpp mitkLevelWindowTest.cpp mitkMessageTest.cpp #mitkPipelineSmartPointerCorrectnessTest.cpp mitkPixelTypeTest.cpp mitkPlaneGeometryTest.cpp mitkPointSetFileIOTest.cpp mitkPointSetTest.cpp mitkPointSetWriterTest.cpp mitkPointSetReaderTest.cpp mitkPointSetInteractorTest.cpp mitkPropertyTest.cpp mitkPropertyListTest.cpp #mitkRegistrationBaseTest.cpp #mitkSegmentationInterpolationTest.cpp mitkSlicedGeometry3DTest.cpp mitkSliceNavigationControllerTest.cpp mitkStateMachineTest.cpp ##mitkStateMachineContainerTest.cpp ## rewrite test, indirect since no longer exported Bug 14529 mitkStateTest.cpp mitkSurfaceTest.cpp mitkSurfaceToSurfaceFilterTest.cpp mitkTimeSlicedGeometryTest.cpp mitkTransitionTest.cpp mitkUndoControllerTest.cpp mitkVtkWidgetRenderingTest.cpp mitkVerboseLimitedLinearUndoTest.cpp mitkWeakPointerTest.cpp mitkTransferFunctionTest.cpp #mitkAbstractTransformGeometryTest.cpp mitkStepperTest.cpp itkTotalVariationDenoisingImageFilterTest.cpp mitkRenderingManagerTest.cpp vtkMitkThickSlicesFilterTest.cpp mitkNodePredicateSourceTest.cpp mitkVectorTest.cpp mitkClippedSurfaceBoundsCalculatorTest.cpp mitkExceptionTest.cpp mitkExtractSliceFilterTest.cpp mitkLogTest.cpp mitkImageDimensionConverterTest.cpp mitkLoggingAdapterTest.cpp mitkUIDGeneratorTest.cpp mitkShaderRepositoryTest.cpp mitkPlanePositionManagerTest.cpp mitkAffineTransformBaseTest.cpp - mitkTypeConversionTest.cpp + mitkTypePointConversionTest.cpp + mitkTypeVectorConversionTest.cpp + mitkTypeMatrixConversionTest.cpp mitkTypeOperationTest.cpp ) # test with image filename as an extra command line parameter set(MODULE_IMAGE_TESTS mitkImageTimeSelectorTest.cpp #only runs on images mitkImageAccessorTest.cpp #only runs on images mitkDataNodeFactoryTest.cpp #runs on all types of data ) set(MODULE_SURFACE_TESTS mitkSurfaceVtkWriterTest.cpp #only runs on surfaces mitkDataNodeFactoryTest.cpp #runs on all types of data ) # list of images for which the tests are run set(MODULE_TESTIMAGES US4DCyl.nrrd Pic3D.nrrd Pic2DplusT.nrrd BallBinary30x30x30.nrrd Png2D-bw.png ) set(MODULE_TESTSURFACES binary.stl ball.stl ) set(MODULE_CUSTOM_TESTS #mitkLabeledImageToSurfaceFilterTest.cpp #mitkExternalToolsTest.cpp mitkDataStorageTest.cpp mitkDataNodeTest.cpp mitkDicomSeriesReaderTest.cpp mitkDICOMLocaleTest.cpp mitkEventMapperTest.cpp mitkEventConfigTest.cpp mitkNodeDependentPointSetInteractorTest.cpp mitkStateMachineFactoryTest.cpp mitkPointSetLocaleTest.cpp mitkImageTest.cpp mitkImageWriterTest.cpp mitkImageVtkMapper2DTest.cpp mitkImageVtkMapper2DLevelWindowTest.cpp mitkImageVtkMapper2DOpacityTest.cpp mitkImageVtkMapper2DResliceInterpolationPropertyTest.cpp mitkImageVtkMapper2DColorTest.cpp mitkImageVtkMapper2DSwivelTest.cpp mitkImageVtkMapper2DTransferFunctionTest.cpp mitkIOUtilTest.cpp mitkSurfaceVtkMapper3DTest mitkSurfaceVtkMapper3DTexturedSphereTest.cpp mitkSurfaceGLMapper2DColorTest.cpp mitkSurfaceGLMapper2DOpacityTest.cpp mitkVolumeCalculatorTest.cpp mitkLevelWindowManagerTest.cpp mitkPointSetVtkMapper2DTest.cpp mitkPointSetVtkMapper2DImageTest.cpp mitkPointSetVtkMapper2DGlyphTypeTest.cpp ) set(MODULE_RESOURCE_FILES Interactions/AddAndRemovePoints.xml Interactions/globalConfig.xml Interactions/StatemachineTest.xml Interactions/StatemachineConfigTest.xml ) # Create an artificial module initializing class for # the usServiceListenerTest.cpp usFunctionGenerateExecutableInit(testdriver_init_file IDENTIFIER ${MODULE_NAME}TestDriver ) # Embed the resources set(testdriver_resources ) usFunctionEmbedResources(testdriver_resources EXECUTABLE_NAME ${MODULE_NAME}TestDriver ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Resources FILES ${MODULE_RESOURCE_FILES} ) set(TEST_CPP_FILES ${testdriver_init_file} ${testdriver_resources}) diff --git a/Core/Code/Testing/mitkTypeMatrixConversionTest.cpp b/Core/Code/Testing/mitkTypeMatrixConversionTest.cpp new file mode 100644 index 0000000000..0873f342f5 --- /dev/null +++ b/Core/Code/Testing/mitkTypeMatrixConversionTest.cpp @@ -0,0 +1,31 @@ +/*=================================================================== + +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" + +/** +* Test the conversions from and to mitk matrix types +*/ +int mitkTypeMatrixConversionTest(int /*argc*/ , char* /*argv*/[]) +{ + // always start with this! + MITK_TEST_BEGIN("MatrixConversionTest") + + + MITK_TEST_END() + +} diff --git a/Core/Code/Testing/mitkTypeConversionTest.cpp b/Core/Code/Testing/mitkTypePointConversionTest.cpp similarity index 72% rename from Core/Code/Testing/mitkTypeConversionTest.cpp rename to Core/Code/Testing/mitkTypePointConversionTest.cpp index c519ce823c..258eb19997 100644 --- a/Core/Code/Testing/mitkTypeConversionTest.cpp +++ b/Core/Code/Testing/mitkTypePointConversionTest.cpp @@ -1,207 +1,162 @@ /*=================================================================== 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 "mitkTypes.h" +#include "mitkTypeBasics.h" +#include "mitkTypes.h" // for Equal method +#include "mitkPoint.h" #include "itkPoint.h" #include "vtkPoints.h" #include "vtkSmartPointer.h" -#include "vnl/vnl_vector_ref.h" #include using namespace mitk; static vtkSmartPointer a_vtkPoints = vtkSmartPointer::New(); static const ScalarType originalValues[] = {1.0, 2.0, 3.0}; static const ScalarType valuesToCopy[] = {4.0, 5.0, 6.0}; static void Setup(void) { a_vtkPoints->Initialize(); } static void Test_Mitk2Itk_PointCompatibility() { Setup(); itk::Point itkPoint3D = originalValues; mitk::Point3D point3D = valuesToCopy; itkPoint3D = point3D; MITK_TEST_CONDITION(itkPoint3D == point3D, "mitk point assigned to itk point") MITK_TEST_CONDITION(itkPoint3D == valuesToCopy, "correct values were assigned") } static void Test_Itk2Mitk_PointCompatibility() { Setup(); mitk::Point3D point3D = originalValues; itk::Point itkPoint3D = valuesToCopy; point3D = itkPoint3D; MITK_TEST_CONDITION(point3D == itkPoint3D, "itk point assigned to mitk point") MITK_TEST_CONDITION(point3D == valuesToCopy, "correct values were assigned") } static void Test_Vtk2Mitk_PointCompatibility() { Setup(); mitk::Point3D point3D = originalValues; a_vtkPoints->InsertNextPoint(valuesToCopy); double vtkPoint[3]; a_vtkPoints->GetPoint(0, vtkPoint); point3D = vtkPoint; MITK_TEST_CONDITION(point3D == vtkPoint, "vtkPoint assigned to mitk point") MITK_TEST_CONDITION(point3D == valuesToCopy, "correct values were assigned") } static void Test_Mitk2Vtk_PointCompatibility() { Setup(); double vtkPoint[3]; mitk::Point3D point3D = valuesToCopy; //a_vtkPoints->InsertNextPoint(point3D.GetAsArray()); // a_vtkPoints->GetPoint(0, vtkPoint); MITK_TEST_CONDITION(point3D == vtkPoint, "MITK point assigned to VTK point") MITK_TEST_CONDITION(Equal(vtkPoint[0], valuesToCopy[0]) && Equal(vtkPoint[1], valuesToCopy[1]) && Equal(vtkPoint[2], valuesToCopy[2]), "correct values were assigned") } static void Test_Mitk2Pod_PointCompatibility() { ScalarType podPoint[] = {1.0, 2.0, 3.0}; mitk::Point3D point3D = valuesToCopy; point3D.CopyToArray(podPoint); MITK_TEST_CONDITION(point3D == podPoint, "MITK point assigned to POD point") MITK_TEST_CONDITION(Equal(podPoint[0], valuesToCopy[0]) && Equal(podPoint[1], valuesToCopy[1]) && Equal(podPoint[2], valuesToCopy[2]), "correct values were assigned") } static void Test_Pod2Mitk_PointCompatibility() { mitk::Point3D point3D = originalValues; ScalarType podPoint[] = {4.0, 5.0, 6.0}; point3D = podPoint; MITK_TEST_CONDITION(point3D == podPoint, "POD point assigned to MITK point") MITK_TEST_CONDITION(point3D == valuesToCopy, "correct values were assigned") } -template< class T, unsigned int NVectorDimension> -itk::Vector toItk(const vnl_vector_fixed& vnlVectorFixed) -{ - return toItk(vnlVectorFixed.as_vector()); -} - - -template< class T, unsigned int NVectorDimension> -itk::Vector toItk(const vnl_vector& vnlVector) -{ - itk::Vector vector; - vector.SetVnlVector(vnlVector); - return vector; -} - - -static void Test_Vnl2Mitk_VectorFixedCompatibility() -{ - Setup(); - - mitk::Vector3D vector3D = originalValues; - vnl_vector_fixed vnlVectorFixed(valuesToCopy); - - vector3D = toItk(vnlVectorFixed); - - MITK_TEST_CONDITION( vector3D.GetVnlVector() == vnlVectorFixed, "vnl_vector_fixed assigned to mitk vector") - MITK_TEST_CONDITION( vector3D == valuesToCopy, "correct values were assigned" ) -} - -static void Test_Vnl2Mitk_VectorCompatibility() -{ - Setup(); - - mitk::Vector3D vector3D = originalValues; - vnl_vector vnlVector(3); - vnlVector.set(valuesToCopy); - - vector3D = toItk(vnlVector); - - MITK_TEST_CONDITION( vector3D.GetVnlVector() == vnlVector, "vnl_vector assigned to mitk vector") - MITK_TEST_CONDITION( vector3D == valuesToCopy, "correct values were assigned" ) -} - 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 point types */ -int mitkTypeConversionTest(int /*argc*/ , char* /*argv*/[]) +int mitkTypePointConversionTest(int /*argc*/ , char* /*argv*/[]) { // always start with this! - MITK_TEST_BEGIN("TypeConversionTest") + MITK_TEST_BEGIN("PointConversionTest") Test_Mitk2Itk_PointCompatibility(); Test_Itk2Mitk_PointCompatibility(); Test_Vtk2Mitk_PointCompatibility(); Test_Mitk2Vtk_PointCompatibility(); - Test_Vnl2Mitk_VectorFixedCompatibility(); - Test_Vnl2Mitk_VectorCompatibility(); - Test_Mitk2Vnl_PointCompatibility(); Test_Mitk2Pod_PointCompatibility(); Test_Pod2Mitk_PointCompatibility(); MITK_TEST_END() } diff --git a/Core/Code/Testing/mitkTypeVectorConversionTest.cpp b/Core/Code/Testing/mitkTypeVectorConversionTest.cpp new file mode 100644 index 0000000000..635b021ce2 --- /dev/null +++ b/Core/Code/Testing/mitkTypeVectorConversionTest.cpp @@ -0,0 +1,88 @@ +/*=================================================================== + +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 "mitkTypeBasics.h" +#include "mitkVector.h" +#include "itkVector.h" +#include +#include + +#include + +using namespace mitk; + + +static const ScalarType originalValues[] = {1.0, 2.0, 3.0}; +static const ScalarType valuesToCopy[] = {4.0, 5.0, 6.0}; + + + +template< class T, unsigned int NVectorDimension> +itk::Vector toItk(const vnl_vector_fixed& vnlVectorFixed) +{ + return toItk(vnlVectorFixed.as_vector()); +} + + +template< class T, unsigned int NVectorDimension> +itk::Vector toItk(const vnl_vector& vnlVector) +{ + itk::Vector vector; + vector.SetVnlVector(vnlVector); + return vector; +} + + +static void Test_Vnl2Mitk_VectorFixedCompatibility() +{ + + mitk::Vector3D vector3D = originalValues; + vnl_vector_fixed vnlVectorFixed(valuesToCopy); + + vector3D = toItk(vnlVectorFixed); + + MITK_TEST_CONDITION( vector3D.GetVnlVector() == vnlVectorFixed, "vnl_vector_fixed assigned to mitk vector") + MITK_TEST_CONDITION( vector3D == valuesToCopy, "correct values were assigned" ) +} + +static void Test_Vnl2Mitk_VectorCompatibility() +{ + + mitk::Vector3D vector3D = originalValues; + vnl_vector vnlVector(3); + vnlVector.set(valuesToCopy); + + vector3D = toItk(vnlVector); + + MITK_TEST_CONDITION( vector3D.GetVnlVector() == vnlVector, "vnl_vector assigned to mitk vector") + MITK_TEST_CONDITION( vector3D == valuesToCopy, "correct values were assigned" ) +} + +/** +* Test the conversions from and to the mitk vector type +*/ +int mitkTypeVectorConversionTest(int /*argc*/ , char* /*argv*/[]) +{ + // always start with this! + MITK_TEST_BEGIN("VectorConversionTest") + + Test_Vnl2Mitk_VectorFixedCompatibility(); + Test_Vnl2Mitk_VectorCompatibility(); + + MITK_TEST_END() + +}