diff --git a/Core/Code/Testing/files.cmake b/Core/Code/Testing/files.cmake index 77e6ab78a7..bf188c7b01 100644 --- a/Core/Code/Testing/files.cmake +++ b/Core/Code/Testing/files.cmake @@ -1,201 +1,203 @@ # tests with no extra command line parameter set(MODULE_TESTS # IMPORTANT: If you plan to deactivate / comment out a test please write a bug number to the commented out line of code. # # Example: #mitkMyTest #this test is commented out because of bug 12345 # # It is important that the bug is open and that the test will be activated again before the bug is closed. This assures that # no test is forgotten after it was commented out. If there is no bug for your current problem, please add a new one and # mark it as critical. ################## DISABLED TESTS ################################################# #mitkAbstractTransformGeometryTest.cpp #seems as tested class mitkExternAbstractTransformGeometry doesnt exist any more #mitkStateMachineContainerTest.cpp #rewrite test, indirect since no longer exported Bug 14529 #mitkRegistrationBaseTest.cpp #tested class mitkRegistrationBase doesn't exist any more #mitkSegmentationInterpolationTest.cpp #file doesn't exist! #mitkPipelineSmartPointerCorrectnessTest.cpp #file doesn't exist! #mitkITKThreadingTest.cpp #test outdated because itk::Semaphore was removed from ITK #mitkAbstractTransformPlaneGeometryTest.cpp #mitkVtkAbstractTransformPlaneGeometry doesn't exist any more #mitkTestUtilSharedLibrary.cpp #Linker problem with this test... #mitkTextOverlay2DSymbolsRenderingTest.cpp #Implementation of the tested feature is not finished yet. Ask Christoph or see bug 15104 for details. ################# RUNNING TESTS ################################################### mitkAccessByItkTest.cpp mitkCoreObjectFactoryTest.cpp mitkMaterialTest.cpp mitkActionTest.cpp mitkDispatcherTest.cpp mitkEnumerationPropertyTest.cpp mitkEventTest.cpp mitkFocusManagerTest.cpp mitkGenericPropertyTest.cpp mitkGeometry2DTest.cpp mitkGeometry3DTest.cpp mitkGeometry3DEqualTest.cpp mitkGeometryDataToSurfaceFilterTest.cpp mitkGlobalInteractionTest.cpp mitkImageEqualTest.cpp mitkImageDataItemTest.cpp mitkImageGeneratorTest.cpp mitkIOUtilTest.cpp mitkBaseDataTest.cpp mitkImportItkImageTest.cpp mitkGrabItkImageMemoryTest.cpp mitkInstantiateAccessFunctionTest.cpp mitkInteractorTest.cpp mitkLevelWindowTest.cpp mitkMessageTest.cpp mitkPixelTypeTest.cpp mitkPlaneGeometryTest.cpp + mitkPointSetTest.cpp mitkPointSetEqualTest.cpp mitkPointSetFileIOTest.cpp - mitkPointSetTest.cpp + mitkPointSetOnEmptyTest.cpp mitkPointSetWriterTest.cpp mitkPointSetReaderTest.cpp mitkPointSetInteractorTest.cpp + mitkPointSetPointOperationsTest.cpp mitkPropertyTest.cpp mitkPropertyListTest.cpp mitkSlicedGeometry3DTest.cpp mitkSliceNavigationControllerTest.cpp mitkStateMachineTest.cpp mitkStateTest.cpp mitkSurfaceTest.cpp mitkSurfaceEqualTest.cpp mitkSurfaceToSurfaceFilterTest.cpp mitkTimeGeometryTest.cpp mitkTransitionTest.cpp mitkUndoControllerTest.cpp mitkVtkWidgetRenderingTest.cpp mitkVerboseLimitedLinearUndoTest.cpp mitkWeakPointerTest.cpp mitkTransferFunctionTest.cpp mitkStepperTest.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 mitkPropertyAliasesTest.cpp mitkPropertyDescriptionsTest.cpp mitkPropertyExtensionsTest.cpp mitkPropertyFiltersTest.cpp mitkTinyXMLTest.cpp mitkRawImageFileReaderTest.cpp mitkInteractionEventTest.cpp mitkLookupTableTest.cpp mitkSTLFileReaderTest.cpp mitkSurfaceToImageFilterTest.cpp mitkImageToSurfaceFilterTest.cpp mitkEqualTest.cpp mitkLineTest.cpp ) if(MITK_ENABLE_RENDERING_TESTING) #since mitkInteractionTestHelper is currently creating a vtkRenderWindow set(MODULE_TESTS ${MODULE_TESTS} mitkPointSetDataInteractorTest.cpp ) endif() # 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 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 mitkImageVtkMapper2DLookupTableTest.cpp mitkSurfaceVtkMapper3DTest mitkSurfaceVtkMapper3DTexturedSphereTest.cpp mitkSurfaceGLMapper2DColorTest.cpp mitkSurfaceGLMapper2DOpacityTest.cpp mitkVolumeCalculatorTest.cpp mitkLevelWindowManagerTest.cpp mitkPointSetVtkMapper2DTest.cpp mitkPointSetVtkMapper2DImageTest.cpp mitkPointSetVtkMapper2DGlyphTypeTest.cpp mitkPointSetVtkMapper2DTransformedPointsTest.cpp mitkLabelOverlay3DRendering2DTest.cpp mitkLabelOverlay3DRendering3DTest.cpp mitkTextOverlay2DRenderingTest.cpp mitkTextOverlay2DLayouterRenderingTest.cpp mitkTextOverlay3DRendering2DTest.cpp mitkTextOverlay3DRendering3DTest.cpp mitkTextOverlay3DColorRenderingTest.cpp mitkVTKRenderWindowSizeTest.cpp mitkMultiComponentImageDataComparisonFilterTest.cpp mitkImageToItkTest.cpp mitkImageSliceSelectorTest.cpp mitkSurfaceDepthPeelingTest.cpp mitkSurfaceDepthSortingTest.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/mitkPointSetOnEmptyTest.cpp b/Core/Code/Testing/mitkPointSetOnEmptyTest.cpp new file mode 100644 index 0000000000..4377d9544f --- /dev/null +++ b/Core/Code/Testing/mitkPointSetOnEmptyTest.cpp @@ -0,0 +1,244 @@ +/* + * mitkPointSetTestOnEmpty.cpp + * + * Created on: Apr 23, 2014 + * Author: wirkert + */ +/** + * TestSuite for PointSet which tests properties on an empty PointSet + */ + +#include "mitkTestingMacros.h" +#include "mitkTestFixture.h" + + +#include +#include +#include +#include + +#include + +class mitkPointSetOnEmptyTestSuite : public mitk::TestFixture +{ + + CPPUNIT_TEST_SUITE(mitkPointSetOnEmptyTestSuite); + + MITK_TEST(TestInstantiation); + MITK_TEST(TestIsEmpty); + MITK_TEST(TestGetITKPointSet); + MITK_TEST(TestGetSizeIsZero); + MITK_TEST(TestAddPointDirectly); + MITK_TEST(TestPointSetClone); + MITK_TEST(TestPointDataContainerCorrectAfterPointSetManipulation); + + CPPUNIT_TEST_SUITE_END(); + +private: + + mitk::PointSet::Pointer pointSet; + + void TestPointContainerPointDataContainer(mitk::PointSet* ps) + { + mitk::PointSet::PointsContainer* pc = ps->GetPointSet()->GetPoints(); + mitk::PointSet::PointDataContainer* pd = ps->GetPointSet()->GetPointData(); + CPPUNIT_ASSERT_EQUAL_MESSAGE("PointContainer and PointDataContainer have same size", + true, pc->Size() == pd->Size()); + mitk::PointSet::PointsContainer::ConstIterator pIt = pc->Begin(); + mitk::PointSet::PointDataContainer::ConstIterator dIt = pd->Begin(); + bool failed = false; + for (; pIt != pc->End(); ++pIt, ++dIt) + if (pIt->Index() != dIt->Index()) + { + failed = true; + break; + } + CPPUNIT_ASSERT_EQUAL_MESSAGE("Indices in PointContainer and PointDataContainer are equal", + false, failed); + } + +public: + + void setUp() + { + //Create PointSet + pointSet = mitk::PointSet::New(); + } + + void tearDown() + { + pointSet = NULL; + } + + void TestInstantiation() + { + CPPUNIT_ASSERT_EQUAL_MESSAGE("Testing instantiation", + true, pointSet.IsNotNull()); + } + + void TestGetITKPointSet() + { + //try to get the itkPointSet + mitk::PointSet::DataType::Pointer itkdata = NULL; + itkdata = pointSet->GetPointSet(); + CPPUNIT_ASSERT_EQUAL_MESSAGE("try to get the itkPointSet from a newly created PointSet", + true, itkdata.IsNotNull()); + } + + void TestGetSizeIsZero() + { + //fresh PointSet has to be empty! + CPPUNIT_ASSERT_EQUAL_MESSAGE("check if the PointSet size is 0 ", + true, pointSet->GetSize() == 0); + } + + void TestIsEmpty() + { + CPPUNIT_ASSERT_EQUAL_MESSAGE("check if the PointSet is empty", + true, pointSet->IsEmptyTimeStep(0)); + } + + void TestAddPointDirectly() + { + //add a point directly + int id=0; + mitk::Point3D point; + mitk::FillVector3D(point, 1.0, 2.0, 3.0); + ++id; + pointSet->GetPointSet()->GetPoints()->InsertElement(id, point); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("check if added points exists", + true, pointSet->GetSize()==1 ||pointSet->IndexExists(id)); + + mitk::Point3D tempPoint; + + tempPoint.Fill(0); + tempPoint = pointSet->GetPoint(id); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("check if added point contains real value", + true, point == tempPoint); + } + + void TestPointSetClone(void) + { + pointSet->Expand(3); + mitk::Point3D new0, new1, new2; + new0.Fill(0); + new1.Fill(1); + new2.Fill(2); + pointSet->InsertPoint(5,new0, mitk::PTCORNER,0); + pointSet->InsertPoint(112,new1,0); + pointSet->InsertPoint(2,new2,0); + pointSet->InsertPoint(2,new0,1); + pointSet->InsertPoint(1,new1,1); + pointSet->InsertPoint(0,new2,1); + pointSet->InsertPoint(0,new0,2); + pointSet->InsertPoint(2,new1,2); + pointSet->InsertPoint(1,new2,2); + + MITK_TEST_OUTPUT( << "... pointset ts: " << pointSet->GetTimeSteps() ) + mitk::PointSet::Pointer clonePS = pointSet->Clone(); + MITK_TEST_OUTPUT( << "... clone pointset ts: " << clonePS->GetTimeSteps() ) + + for (unsigned int t=0; t< pointSet->GetTimeSteps(); t++) + { + MITK_TEST_OUTPUT( << "testing timestep: " << t ) + CPPUNIT_ASSERT_EQUAL_MESSAGE("Clone has same size", + true, pointSet->GetSize(t) == clonePS->GetSize(t)); + + // test for equal point coordinates + for (mitk::PointSet::PointsConstIterator i = pointSet->Begin(), j = clonePS->Begin(); + i != pointSet->End() && j != clonePS->End(); ++i, ++j) + { + CPPUNIT_ASSERT_EQUAL_MESSAGE("Cloned PS and PS have same points", + true, i.Index() == j.Index() && mitk::Equal(i.Value(),j.Value())); + } + + // test for equal point data + mitk::PointSet::PointDataContainer* pointDataCont = pointSet->GetPointSet(t)->GetPointData(); + mitk::PointSet::PointDataContainer* clonePointDataCont = clonePS->GetPointSet(t)->GetPointData(); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Valid point data container", + true, pointDataCont && clonePointDataCont); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Cloned point data container has same size", + true, pointDataCont->Size() == clonePointDataCont->Size()); + for (mitk::PointSet::PointDataConstIterator i = pointDataCont->Begin(), j = clonePointDataCont->Begin(); + i != pointDataCont->End() && j != clonePointDataCont->End(); ++i, ++j) + { + CPPUNIT_ASSERT_EQUAL_MESSAGE("Cloned PS and PS have same point data", + true, i.Index() == j.Index() && i.Value() == j.Value()); + } + } + + CPPUNIT_ASSERT_EQUAL_MESSAGE("check if the PointSet is not empty", + false, clonePS->IsEmptyTimeStep(0)); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("Testing cloned point set's size!", + true, clonePS->GetPointSetSeriesSize() == pointSet->GetPointSetSeriesSize()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Testing that the clone is not the source PS!", + true, clonePS.GetPointer() != pointSet.GetPointer()); + CPPUNIT_ASSERT_EQUAL_MESSAGE( "Testing if the geometry is cloned correctly!", + true, clonePS->GetGeometry()->GetCenter() == pointSet->GetGeometry()->GetCenter()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Testing if the property list is cloned correctly!", + true, clonePS->GetPropertyList()->GetMap()->size() == pointSet->GetPropertyList()->GetMap()->size()); + // Also testing, that clone is independent from original + mitk::Point3D p, p2; + p.Fill(42); + p2.Fill(84); + clonePS->InsertPoint(0,p); + pointSet->InsertPoint(0,p2); + p = clonePS->GetPoint(0); + p2 = pointSet->GetPoint(0); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Testing that the clone is independent from source!", + true, p != p2); + + } + + + void TestPointDataContainerCorrectAfterPointSetManipulation(void) + { + /* call everything that might modify PointContainer and PointDataContainer */ + MITK_TEST_OUTPUT(<< "Test InsertPoint(), SetPoint() and SwapPointPosition()"); + mitk::PointSet::PointType point; + mitk::FillVector3D(point, 2.2, 3.3, -4.4); + pointSet->InsertPoint(17, point); + pointSet->SetPoint(4, point); + pointSet->SetPoint(7, point); + pointSet->SetPoint(2, point); + pointSet->SwapPointPosition(7, true); + pointSet->SwapPointPosition(3, true); + pointSet->SwapPointPosition(2, false); + TestPointContainerPointDataContainer(pointSet); + + MITK_TEST_OUTPUT(<< "Test OpREMOVE"); + mitk::PointOperation op1(mitk::OpREMOVE, mitk::Point3D(), 2); // existing index + pointSet->ExecuteOperation(&op1); + mitk::PointOperation op1b(mitk::OpREMOVE, mitk::Point3D(), 112); // non existing index + pointSet->ExecuteOperation(&op1b); + TestPointContainerPointDataContainer(pointSet); + + MITK_TEST_OUTPUT(<< "Test OpMove"); + mitk::PointOperation op2(mitk::OpMOVE, mitk::Point3D(), 4); // existing index + pointSet->ExecuteOperation(&op2); + mitk::PointOperation op3(mitk::OpMOVE, mitk::Point3D(), 34); // non existing index + pointSet->ExecuteOperation(&op3); + TestPointContainerPointDataContainer(pointSet); + + MITK_TEST_OUTPUT(<< "Test OpINSERT"); + mitk::PointOperation op4(mitk::OpINSERT, mitk::Point3D(), 38); // non existing index + pointSet->ExecuteOperation(&op4); + mitk::PointOperation op5(mitk::OpINSERT, mitk::Point3D(), 17); // existing index + pointSet->ExecuteOperation(&op5); + TestPointContainerPointDataContainer(pointSet); + } + + + + +}; + +MITK_TEST_SUITE_REGISTRATION(mitkPointSetOnEmpty) + + + + + diff --git a/Core/Code/Testing/mitkPointSetPointOperationsTest.cpp b/Core/Code/Testing/mitkPointSetPointOperationsTest.cpp new file mode 100644 index 0000000000..6516ce348c --- /dev/null +++ b/Core/Code/Testing/mitkPointSetPointOperationsTest.cpp @@ -0,0 +1,291 @@ +/* + * mitkPoinSetPointOperationsTest.cpp + * + * Created on: Apr 23, 2014 + * Author: wirkert + */ + + +#include "mitkTestingMacros.h" +#include "mitkTestFixture.h" + + +#include +#include +#include +#include + +#include + + +/** + * TestSuite for all PointSet manipulations done by PointOperations + */ +class mitkPointSetPointOperationsTestSuite : public mitk::TestFixture +{ + CPPUNIT_TEST_SUITE(mitkPointSetPointOperationsTestSuite); + + MITK_TEST(TestCreateOperationAndAddPoint); + MITK_TEST(TestPointOperationOpMove); + MITK_TEST(TestPointOperationOpRemove); + MITK_TEST(TestPointOperationOpSelectPoint); + MITK_TEST(TestOpDeselectPoint); + MITK_TEST(TestOpMovePointUp); + MITK_TEST(TestOpMovePointDown); + MITK_TEST(TestOpMovePointUpOnFirstPoint); + + CPPUNIT_TEST_SUITE_END(); + +private: + + mitk::PointSet::Pointer pointSet; + mitk::PointOperation* doOp; + +public: + + void setUp() + { + //Create PointSet + pointSet = mitk::PointSet::New(); + + // add some points + mitk::Point3D point2, point3, point4; + point2.Fill(3); + point3.Fill(4); + point4.Fill(5); + pointSet->InsertPoint(2,point2); + pointSet->InsertPoint(3,point3); + pointSet->InsertPoint(4,point4); + } + + void tearDown() + { + pointSet = NULL; + delete doOp; + } + + void TestCreateOperationAndAddPoint() + { + int id = 0; + mitk::Point3D point; + point.Fill(1); + + doOp = new mitk::PointOperation(mitk::OpINSERT, point, id); + + pointSet->ExecuteOperation(doOp); + CPPUNIT_ASSERT_EQUAL_MESSAGE("check if added points exists", + true, pointSet->GetSize()==4 && pointSet->IndexExists(id)); + + + mitk::Point3D tempPoint; + tempPoint.Fill(0); + + tempPoint = pointSet->GetPoint(id); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("check if added point contains real value", + true, point == tempPoint); + } + + + void TestPointOperationOpMove() + { + //check opMOVE ExecuteOperation + int id=1; + mitk::Point3D point1; + mitk::Point3D tempPoint; + point1.Fill(2); + + doOp = new mitk::PointOperation(mitk::OpMOVE, point1, id); + + pointSet->ExecuteOperation(doOp); + tempPoint = pointSet->GetPoint(id); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("check PointOperation OpMove ", + true, tempPoint == point1); + + /* + if (tempPoint != point1) + { + std::cout<<"[FAILED]"<GetPoint(id); + + doOp = new mitk::PointOperation(mitk::OpREMOVE, point, id); + + pointSet->ExecuteOperation(doOp); + tempPoint = pointSet->GetPoint(id); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("check PointOperation OpREMOVE ", + false, pointSet->IndexExists(id) ); + + /* + if(pointSet->IndexExists(id)) + { + std::cout<<"[FAILED]"<ExecuteOperation(doOp); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("check PointOperation OpSELECTPOINT ", + true, pointSet->GetSelectInfo(3)); + + /* + if (!pointSet->GetSelectInfo(4)) + { + std::cout<<"[FAILED]"<ExecuteOperation(doOp); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("check PointOperation OpDESELECTPOINT ", + false, pointSet->GetSelectInfo(4)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("check GetNumeberOfSelected ", + true, pointSet->GetNumberOfSelected() == 0 ); + + /* + if (pointSet->GetSelectInfo(4)) + { + std::cout<<"[FAILED]"<GetNumberOfSelected() != 0) + { + std::cout<<"[FAILED]"<GetPoint(id); + + doOp = new mitk::PointOperation(mitk::OpMOVEPOINTUP, point4, id); + + pointSet->ExecuteOperation(doOp); + tempPoint = pointSet->GetPoint(id-1); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("check PointOperation OpMOVEPOINTUP ", + true, tempPoint == point); + + /* + if (tempPoint != point) + { + std::cout<<"[FAILED]"<GetPoint(id); + doOp = new mitk::PointOperation(mitk::OpMOVEPOINTDOWN, point2, id); + pointSet->ExecuteOperation(doOp); + tempPoint = pointSet->GetPoint(id+1); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("check PointOperation OpMOVEPOINTDOWN ", + true, tempPoint == point); + + /* + if (tempPoint != point) + { + std::cout<<"[FAILED]"<GetPoint(1); + mitk::PointSet::PointType p2 = pointSet->GetPoint(2); + + doOp = new mitk::PointOperation(mitk::OpMOVEPOINTUP, p1, 1); + + pointSet->ExecuteOperation(doOp); + + + mitk::PointSet::PointType newP1 = pointSet->GetPoint(1); + mitk::PointSet::PointType newP2 = pointSet->GetPoint(2); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("check PointOperation OpMOVEPOINTUP for point id 1: ", + true, ((newP1 == p1) && (newP2 == p2))); + + /* + if (((newP1 == p1) && (newP2 == p2)) == false) + { + std::cout<<"[FAILED]"< #include #include #include #include -class mitkPointSetTestClass { public: -static void TestGetITKPointSet(mitk::PointSet *pointSet) -{ - //try to get the itkPointSet - mitk::PointSet::DataType::Pointer itkdata = NULL; - itkdata = pointSet->GetPointSet(); - MITK_TEST_CONDITION( itkdata.IsNotNull(), "try to get the itkPointSet from a newly created PointSet" ) -} -static void TestGetSizeIsZero(mitk::PointSet *pointSet) +/** + * TestSuite for PointSet stuff not only operating on an empty PointSet + */ +class mitkPointSetTestSuite : public mitk::TestFixture { - //fresh PointSet has to be empty! - MITK_TEST_CONDITION( pointSet->GetSize() == 0, "check if the PointSet size is 0 " ) -} + CPPUNIT_TEST_SUITE(mitkPointSetTestSuite); -static void TestIsEmpty(mitk::PointSet *pointSet) -{ - MITK_TEST_CONDITION(pointSet->IsEmptyTimeStep(0), "check if the PointSet is empty" ) -} + MITK_TEST(TestIsNotEmpty); + MITK_TEST(TestSetSelectInfo); + MITK_TEST(TestGetNumberOfSelected); + MITK_TEST(TestSearchSelectedPoint); + MITK_TEST(TestGetPointIfExists); + MITK_TEST(TestSwapPointPositionUpwards); + MITK_TEST(TestSwapPointPositionUpwardsNotPossible); + MITK_TEST(TestSwapPointPositionDownwards); + MITK_TEST(TestSwapPointPositionDownwardsNotPossible); + MITK_TEST(TestCreateHoleInThePointIDs); + MITK_TEST(TestInsertPointWithPointSpecification); -static void TestCreateOperationAndAddPoint(mitk::PointSet *pointSet) -{ - int id = 0; - mitk::Point3D point; - point.Fill(1); + CPPUNIT_TEST_SUITE_END(); - mitk::PointOperation* doOp = new mitk::PointOperation(mitk::OpINSERT, point, id); - pointSet->ExecuteOperation(doOp); - MITK_TEST_CONDITION( pointSet->GetSize()==1 && pointSet->IndexExists(id), "check if added points exists" ) +private: - delete doOp; + mitk::PointSet::Pointer pointSet; + static const mitk::PointSet::PointIdentifier selectedPointId = 2; - mitk::Point3D tempPoint; - tempPoint.Fill(0); - - tempPoint = pointSet->GetPoint(id); - - MITK_TEST_CONDITION( point == tempPoint, "check if added point contains real value" ) -} - - -static void TestAddSecondPoint(mitk::PointSet *pointSet) -{ - //add a point directly - int id=0; - mitk::Point3D point; - mitk::FillVector3D(point, 1.0, 2.0, 3.0); - ++id; - pointSet->GetPointSet()->GetPoints()->InsertElement(id, point); +public: - MITK_TEST_CONDITION( pointSet->GetSize()==2 ||pointSet->IndexExists(id), "check if added points exists" ) - - mitk::Point3D tempPoint; + void setUp() + { + //Create PointSet + pointSet = mitk::PointSet::New(); + + // add some points + mitk::Point3D point2, point3, point4; + point2.Fill(3); + point3.Fill(4); + point4.Fill(5); + pointSet->InsertPoint(2,point2); + pointSet->InsertPoint(3,point3); + pointSet->InsertPoint(4,point4); + + mitk::Point3D point1; + mitk::FillVector3D(point1, 1.0, 2.0, 3.0); + pointSet->InsertPoint(1, point1); + + mitk::Point3D point0; + point0.Fill(1); + pointSet->InsertPoint(0, point0); + + // select point with id 2 + pointSet->SetSelectInfo(2, true); + } - tempPoint.Fill(0); - tempPoint = pointSet->GetPoint(id); - MITK_TEST_CONDITION( point == tempPoint, "check if added point contains real value" ) -} + void tearDown() + { + pointSet = NULL; + } -static void TestIsNotEmpty(mitk::PointSet *pointSet) -{ - //PointSet can not be empty! - MITK_TEST_CONDITION( !pointSet->IsEmptyTimeStep(0), "check if the PointSet is not empty " ) + void TestIsNotEmpty() + { + //PointSet can not be empty! + CPPUNIT_ASSERT_EQUAL_MESSAGE( "check if the PointSet is not empty ", + true, !pointSet->IsEmptyTimeStep(0) ); - /* + /* std::cout << "check if the PointSet is not empty "; if (pointSet->IsEmpty(0)) { std::cout<<"[FAILED]"<GetPoint(1); - pointSet->SwapPointPosition(1, true); - tempPoint = pointSet->GetPoint(0); - - MITK_TEST_CONDITION( point == tempPoint, "check SwapPointPosition upwards" ) - - /* - if(point != tempPoint) - { - std::cout<<"[FAILED]"<SwapPointPosition(0, true)==false, "check SwapPointPosition upwards not possible" ) - - /* - if(pointSet->SwapPointPosition(0, true)) - { - std::cout<<"[FAILED]"<GetPoint(0); - pointSet->SwapPointPosition(0, false); - tempPoint = pointSet->GetPoint(1); - - MITK_TEST_CONDITION( point == tempPoint, "check SwapPointPosition down" ) - - /* - if(point != tempPoint) - { - std::cout<<"[FAILED]"<SetPoint(id, point); - + */ + } - //Check SwapPointPosition downwards not possible - MITK_TEST_CONDITION(!pointSet2->SwapPointPosition(id, false), "check SwapPointPosition downwards not possible" ) + void TestSetSelectInfo() + { + //check SetSelectInfo + pointSet->SetSelectInfo(4, true); + CPPUNIT_ASSERT_EQUAL_MESSAGE("check SetSelectInfo", + true, pointSet->GetSelectInfo(4)); /* - if(pointSet->SwapPointPosition(1, false)) - { - std::cout<<"[FAILED]"<ExecuteOperation(doOp); - tempPoint = pointSet->GetPoint(id); + if (!pointSet->GetSelectInfo(2)) + { + std::cout<<"[FAILED]"<SearchSelectedPoint() == (int) selectedPointId); + + /* + if( pointSet->SearchSelectedPoint() != 4) + { + std::cout<<"[FAILED]"<GetPoint(id); - mitk::PointOperation* doOp = new mitk::PointOperation(mitk::OpREMOVE, point, id); - pointSet->ExecuteOperation(doOp); - tempPoint = pointSet->GetPoint(id); + // check GetNumeberOfSelected + CPPUNIT_ASSERT_EQUAL_MESSAGE("check GetNumeberOfSelected ", + true, pointSet->GetNumberOfSelected() == 1); + + /* + if(pointSet->GetNumberOfSelected() != 1) + { + std::cout<<"[FAILED]"<IndexExists(id) , "check PointOperation OpREMOVE " ) - delete doOp; - /* - if(pointSet->IndexExists(id)) + void TestGetPointIfExists() { - std::cout<<"[FAILED]"<ExecuteOperation(doOp); + pointSet->GetPointIfExists(4, &tmpPoint); - MITK_TEST_CONDITION(pointSet->GetSelectInfo(4) , "check PointOperation OpSELECTPOINT " ) - delete doOp; - /* - if (!pointSet->GetSelectInfo(4)) - { - std::cout<<"[FAILED]"<GetNumberOfSelected() == 1 , "check GetNumeberOfSelected " ) - /* - if(pointSet->GetNumberOfSelected() != 1) - { - std::cout<<"[FAILED]"<GetPoint(1); + pointSet->SwapPointPosition(1, true); + tempPoint = pointSet->GetPoint(0); -static void TestSearchSelectedPoint(mitk::PointSet *pointSet) -{ - // check SearchSelectedPoint - MITK_TEST_CONDITION(pointSet->SearchSelectedPoint() == 4 , "check SearchSelectedPoint " ) + CPPUNIT_ASSERT_EQUAL_MESSAGE("check SwapPointPosition upwards", + true, point == tempPoint); /* - if( pointSet->SearchSelectedPoint() != 4) - { - std::cout<<"[FAILED]"<ExecuteOperation(doOp); - - MITK_TEST_CONDITION(!pointSet->GetSelectInfo(4) , "check PointOperation OpDESELECTPOINT " ) - MITK_TEST_CONDITION(pointSet->GetNumberOfSelected() == 0 , "check GetNumeberOfSelected " ) - delete doOp; - /* - if (pointSet->GetSelectInfo(4)) - { - std::cout<<"[FAILED]"<GetNumberOfSelected() != 0) + void TestSwapPointPositionUpwardsNotPossible() { - std::cout<<"[FAILED]"<SwapPointPosition(0, true)); -static void TestOpMovePointUp(mitk::PointSet *pointSet) + /* +if(pointSet->SwapPointPosition(0, true)) { - //check OpMOVEPOINTUP ExecuteOperation - int id = 4; - mitk::Point3D point4; - mitk::Point3D point; - mitk::Point3D tempPoint; - - point = pointSet->GetPoint(id); - mitk::PointOperation* doOp = new mitk::PointOperation(mitk::OpMOVEPOINTUP, point4, id); - pointSet->ExecuteOperation(doOp); - tempPoint = pointSet->GetPoint(id-1); - - MITK_TEST_CONDITION(tempPoint == point , "check PointOperation OpMOVEPOINTUP " ) - delete doOp; - /* - if (tempPoint != point) - { - std::cout<<"[FAILED]"<GetPoint(id); - mitk::PointOperation* doOp = new mitk::PointOperation(mitk::OpMOVEPOINTDOWN, point2, id); - pointSet->ExecuteOperation(doOp); - tempPoint = pointSet->GetPoint(id+1); - - MITK_TEST_CONDITION(tempPoint == point , "check PointOperation OpMOVEPOINTDOWN " ) - delete doOp; - /* - if (tempPoint != point) + void TestSwapPointPositionDownwards() { - std::cout<<"[FAILED]"<GetPoint(0); + pointSet->SwapPointPosition(0, false); + tempPoint = pointSet->GetPoint(1); -static void TestSetSelectInfo(mitk::PointSet *pointSet) -{ - //check SetSelectInfo - pointSet->SetSelectInfo(2, true); + CPPUNIT_ASSERT_EQUAL_MESSAGE("check SwapPointPosition down", + true, point == tempPoint); - MITK_TEST_CONDITION(pointSet->GetSelectInfo(2) , "check SetSelectInfo" ) /* - if (!pointSet->GetSelectInfo(2)) - { - std::cout<<"[FAILED]"<SetPoint(5, point5, mitk::PTEDGE ); - tempPoint = pointSet->GetPoint(5); + void TestSwapPointPositionDownwardsNotPossible() + { + mitk::PointSet::Pointer pointSet2 = mitk::PointSet::New(); - MITK_TEST_CONDITION(tempPoint == point5, "check InsertPoint with PointSpecification" ) - /* - if (tempPoint != point5) - { - std::cout<<"[FAILED]"<SetPoint(id, point); -static void TestGetPointIfExists(mitk::PointSet *pointSet) -{ - //check GetPointIfExists - mitk::Point3D point5; - mitk::Point3D tempPoint; - point5.Fill(7); - mitk::PointSet::PointType tmpPoint; - pointSet->GetPointIfExists(5, &tmpPoint); + //Check SwapPointPosition downwards not possible + CPPUNIT_ASSERT_EQUAL_MESSAGE("check SwapPointPosition downwards not possible", + false, pointSet2->SwapPointPosition(id, false)); - MITK_TEST_CONDITION(tmpPoint == point5, "check GetPointIfExists: " ) /* - if (tmpPoint != point5) - { - std::cout<<"[FAILED]"<SwapPointPosition(1, false)) { - // create a hole in the point IDs - mitk::Point3D point; - mitk::PointSet::PointType p10, p11, p12; - p10.Fill(10.0); - p11.Fill(11.0); - p12.Fill(12.0); - pointSet->InsertPoint(10, p10); - pointSet->InsertPoint(11, p11); - pointSet->InsertPoint(12, p12); - - MITK_TEST_CONDITION((pointSet->IndexExists(10) == true) || (pointSet->IndexExists(11) == true) || (pointSet->IndexExists(12) == true), "add points with id 10, 11, 12: " ) +std::cout<<"[FAILED]"<ExecuteOperation(doOp); - MITK_TEST_CONDITION(!pointSet->IndexExists(id), "remove point id 11: ") + void TestCreateHoleInThePointIDs() + { + // create a hole in the point IDs + mitk::Point3D point; + mitk::PointSet::PointType p10, p11, p12; + p10.Fill(10.0); + p11.Fill(11.0); + p12.Fill(12.0); + pointSet->InsertPoint(10, p10); + pointSet->InsertPoint(11, p11); + pointSet->InsertPoint(12, p12); + + CPPUNIT_ASSERT_EQUAL_MESSAGE("add points with id 10, 11, 12: ", + true, (pointSet->IndexExists(10) == true) || (pointSet->IndexExists(11) == true) || (pointSet->IndexExists(12) == true)); + + //check OpREMOVE ExecuteOperation + int id = 11; + mitk::PointOperation* doOp = new mitk::PointOperation(mitk::OpREMOVE, point, id); + pointSet->ExecuteOperation(doOp); + + CPPUNIT_ASSERT_EQUAL_MESSAGE( "remove point id 11: ", + false, pointSet->IndexExists(id)); /* - if(pointSet->IndexExists(id)) - { - std::cout<<"[FAILED]"<IndexExists(id)) + { + std::cout<<"[FAILED]"<ExecuteOperation(doOp); delete doOp; - //check OpMOVEPOINTUP ExecuteOperation - doOp = new mitk::PointOperation(mitk::OpMOVEPOINTUP, p12, 12); - pointSet->ExecuteOperation(doOp); - delete doOp; - - mitk::PointSet::PointType newP10 = pointSet->GetPoint(10); - mitk::PointSet::PointType newP12 = pointSet->GetPoint(12); - - MITK_TEST_CONDITION(((newP10 == p12) && (newP12 == p10)) == true, "check PointOperation OpMOVEPOINTUP for point id 12:" ) + //check OpMOVEPOINTUP ExecuteOperation + doOp = new mitk::PointOperation(mitk::OpMOVEPOINTUP, p12, 12); + pointSet->ExecuteOperation(doOp); + delete doOp; - //check OpMOVEPOINTDOWN ExecuteOperation - doOp = new mitk::PointOperation(mitk::OpMOVEPOINTDOWN, p10, 10); - pointSet->ExecuteOperation(doOp); - delete doOp; - newP10 = pointSet->GetPoint(10); - newP12 = pointSet->GetPoint(12); + mitk::PointSet::PointType newP10 = pointSet->GetPoint(10); + mitk::PointSet::PointType newP12 = pointSet->GetPoint(12); - MITK_TEST_CONDITION(((newP10 == p10) && (newP12 == p12)) == true, "check PointOperation OpMOVEPOINTDOWN for point id 10: ") -} + CPPUNIT_ASSERT_EQUAL_MESSAGE("check PointOperation OpMOVEPOINTUP for point id 12:", + true, ((newP10 == p12) && (newP12 == p10))); + //check OpMOVEPOINTDOWN ExecuteOperation + doOp = new mitk::PointOperation(mitk::OpMOVEPOINTDOWN, p10, 10); + pointSet->ExecuteOperation(doOp); + delete doOp; + newP10 = pointSet->GetPoint(10); + newP12 = pointSet->GetPoint(12); -static void TestOpMovePointUpOnFirstPoint(mitk::PointSet *pointSet) -{ - //check OpMOVEPOINTUP on first point ExecuteOperation + CPPUNIT_ASSERT_EQUAL_MESSAGE("check PointOperation OpMOVEPOINTDOWN for point id 10: ", + true, ((newP10 == p10) && (newP12 == p12))); + } - mitk::PointSet::PointType p1 = pointSet->GetPoint(1); - mitk::PointSet::PointType p2 = pointSet->GetPoint(2); - mitk::PointOperation* doOp = new mitk::PointOperation(mitk::OpMOVEPOINTUP, p1, 1); - pointSet->ExecuteOperation(doOp); - delete doOp; - mitk::PointSet::PointType newP1 = pointSet->GetPoint(1); - mitk::PointSet::PointType newP2 = pointSet->GetPoint(2); + void TestInsertPointWithPointSpecification() + { + //check InsertPoint with PointSpecification + mitk::Point3D point5; + mitk::Point3D tempPoint; + point5.Fill(7); - MITK_TEST_CONDITION(((newP1 == p1) && (newP2 == p2)) == true, "check PointOperation OpMOVEPOINTUP for point id 1: ") + pointSet->SetPoint(5, point5, mitk::PTEDGE ); + tempPoint = pointSet->GetPoint(5); + CPPUNIT_ASSERT_EQUAL_MESSAGE("check InsertPoint with PointSpecification" , + true, tempPoint == point5); /* - if (((newP1 == p1) && (newP2 == p2)) == false) - { - std::cout<<"[FAILED]"<GetPointSet()->GetPoints(); - mitk::PointSet::PointDataContainer* pd = ps->GetPointSet()->GetPointData(); - MITK_TEST_CONDITION_REQUIRED(pc->Size() == pd->Size(), "PointContainer and PointDataContainer have same size"); - mitk::PointSet::PointsContainer::ConstIterator pIt = pc->Begin(); - mitk::PointSet::PointDataContainer::ConstIterator dIt = pd->Begin(); - bool failed = false; - for (; pIt != pc->End(); ++pIt, ++dIt) - if (pIt->Index() != dIt->Index()) - { - failed = true; - break; - } - MITK_TEST_CONDITION(failed == false, "Indices in PointContainer and PointDataContainer are equal"); -} -}; - + if (tempPoint != point5) + { + std::cout<<"[FAILED]"<InsertPoint(2,point2); - pointSet->InsertPoint(3,point3); - pointSet->InsertPoint(4,point4); - - mitkPointSetTestClass::TestAddSecondPoint(pointSet); - mitkPointSetTestClass::TestIsNotEmpty(pointSet); - mitkPointSetTestClass::TestSwapPointPositionUpwards(pointSet); - mitkPointSetTestClass::TestSwapPointPositionUpwardsNotPossible(pointSet); - mitkPointSetTestClass::TestSwapPointPositionDownwards(pointSet); - mitkPointSetTestClass::TestSwapPointPositionDownwardsNotPossible(pointSet); - mitkPointSetTestClass::TestPointOperationOpMove(pointSet); - mitkPointSetTestClass::TestPointOperationOpRemove(pointSet); - mitkPointSetTestClass::TestPointOperationOpSelectPoint(pointSet); - mitkPointSetTestClass::TestGetNumberOfSelected(pointSet); - mitkPointSetTestClass::TestSearchSelectedPoint(pointSet); - mitkPointSetTestClass::TestOpDeselectPoint(pointSet); - mitkPointSetTestClass::TestOpMovePointUp(pointSet); - mitkPointSetTestClass::TestOpMovePointDown(pointSet); - mitkPointSetTestClass::TestSetSelectInfo(pointSet); - mitkPointSetTestClass::TestInsertPointWithPointSpecification(pointSet); - mitkPointSetTestClass::TestGetPointIfExists(pointSet); - mitkPointSetTestClass::TestCreateHoleInThePointIDs(pointSet); - mitkPointSetTestClass::TestOpMovePointUpOnFirstPoint(pointSet); - - MITK_TEST_OUTPUT(<< "Test InsertPoint(), SetPoint() and SwapPointPosition()"); - mitk::PointSet::PointType point; - mitk::FillVector3D(point, 2.2, 3.3, -4.4); - /* call everything that might modify PointContainer and PointDataContainer */ - pointSet->InsertPoint(17, point); - pointSet->SetPoint(4, point); - pointSet->SetPoint(7, point); - pointSet->SetPoint(2, point); - pointSet->SwapPointPosition(7, true); - pointSet->SwapPointPosition(3, true); - pointSet->SwapPointPosition(2, false); - mitkPointSetTestClass::TestPointContainerPointDataContainer(pointSet); - - MITK_TEST_OUTPUT(<< "Test OpREMOVE"); - mitk::PointOperation op1(mitk::OpREMOVE, mitk::Point3D(), 2); // existing index - pointSet->ExecuteOperation(&op1); - mitk::PointOperation op1b(mitk::OpREMOVE, mitk::Point3D(), 112); // non existing index - pointSet->ExecuteOperation(&op1b); - mitkPointSetTestClass::TestPointContainerPointDataContainer(pointSet); - - MITK_TEST_OUTPUT(<< "Test OpMove"); - mitk::PointOperation op2(mitk::OpMOVE, mitk::Point3D(), 4); // existing index - pointSet->ExecuteOperation(&op2); - mitk::PointOperation op3(mitk::OpMOVE, mitk::Point3D(), 34); // non existing index - pointSet->ExecuteOperation(&op3); - mitkPointSetTestClass::TestPointContainerPointDataContainer(pointSet); - - MITK_TEST_OUTPUT(<< "Test OpINSERT"); - mitk::PointOperation op4(mitk::OpINSERT, mitk::Point3D(), 38); // non existing index - pointSet->ExecuteOperation(&op4); - mitk::PointOperation op5(mitk::OpINSERT, mitk::Point3D(), 17); // existing index - pointSet->ExecuteOperation(&op5); - mitkPointSetTestClass::TestPointContainerPointDataContainer(pointSet); - - - - pointSet = mitk::PointSet::New(); - pointSet->Expand(3); - mitk::Point3D new0, new1, new2; - new0.Fill(0); - new1.Fill(1); - new2.Fill(2); - pointSet->InsertPoint(5,new0, mitk::PTCORNER,0); - pointSet->InsertPoint(112,new1,0); - pointSet->InsertPoint(2,new2,0); - pointSet->InsertPoint(2,new0,1); - pointSet->InsertPoint(1,new1,1); - pointSet->InsertPoint(0,new2,1); - pointSet->InsertPoint(0,new0,2); - pointSet->InsertPoint(2,new1,2); - pointSet->InsertPoint(1,new2,2); - - MITK_TEST_OUTPUT( << "... pointset ts: " << pointSet->GetTimeSteps() ) - mitk::PointSet::Pointer clonePS = pointSet->Clone(); - MITK_TEST_OUTPUT( << "... clone pointset ts: " << clonePS->GetTimeSteps() ) - - for (unsigned int t=0; t< pointSet->GetTimeSteps(); t++) - { - MITK_TEST_OUTPUT( << "testing timestep: " << t ) - MITK_TEST_CONDITION_REQUIRED(pointSet->GetSize(t) == clonePS->GetSize(t), "Clone has same size") - // test for equal point coordinates - for (mitk::PointSet::PointsConstIterator i = pointSet->Begin(), j = clonePS->Begin(); - i != pointSet->End() && j != clonePS->End(); ++i, ++j) - { - MITK_TEST_CONDITION_REQUIRED(i.Index() == j.Index() && mitk::Equal(i.Value(),j.Value()), "Cloned PS and PS have same points") - } - // test for equal point data - mitk::PointSet::PointDataContainer* pointDataCont = pointSet->GetPointSet(t)->GetPointData(); - mitk::PointSet::PointDataContainer* clonePointDataCont = clonePS->GetPointSet(t)->GetPointData(); - MITK_TEST_CONDITION_REQUIRED(pointDataCont && clonePointDataCont, "Valid point data container") - MITK_TEST_CONDITION_REQUIRED(pointDataCont->Size() == clonePointDataCont->Size(), "Cloned point data container has same size") - for (mitk::PointSet::PointDataConstIterator i = pointDataCont->Begin(), j = clonePointDataCont->Begin(); - i != pointDataCont->End() && j != clonePointDataCont->End(); ++i, ++j) - { - MITK_TEST_CONDITION_REQUIRED(i.Index() == j.Index() && i.Value() == j.Value(), "Cloned PS and PS have same point data") - } - } - mitkPointSetTestClass::TestIsNotEmpty(clonePS); - MITK_TEST_CONDITION_REQUIRED(clonePS->GetPointSetSeriesSize() == pointSet->GetPointSetSeriesSize(), "Testing cloned point set's size!"); - MITK_TEST_CONDITION_REQUIRED(clonePS.GetPointer() != pointSet.GetPointer(), "Testing that the clone is not the source PS!"); - MITK_TEST_CONDITION_REQUIRED(clonePS->GetGeometry()->GetCenter() == pointSet->GetGeometry()->GetCenter() , "Testing if the geometry is cloned correctly!"); - MITK_TEST_CONDITION_REQUIRED(clonePS->GetPropertyList()->GetMap()->size() == pointSet->GetPropertyList()->GetMap()->size() , "Testing if the property list is cloned correctly!"); - // Also testing, that clone is independent from original - mitk::Point3D p, p2; - p.Fill(42); - p2.Fill(84); - clonePS->InsertPoint(0,p); - pointSet->InsertPoint(0,p2); - p = clonePS->GetPoint(0); - p2 = pointSet->GetPoint(0); - MITK_TEST_CONDITION_REQUIRED(p != p2, "Testing that the clone is independent from source!"); - MITK_TEST_END(); -}