diff --git a/Core/Code/Algorithms/mitkImageCaster.cpp b/Core/Code/Algorithms/mitkImageCaster.cpp index 934c01e6e9..611e5e22e4 100644 --- a/Core/Code/Algorithms/mitkImageCaster.cpp +++ b/Core/Code/Algorithms/mitkImageCaster.cpp @@ -1,59 +1,59 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2010-06-18 20:12:43 +0200 (Fr, 18 Jun 2010) $ Version: $Revision: 23881 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkImageCaster.h" #include "mitkImageAccessByItk.h" vtkRenderer* mitk::RendererAccess::m_3DRenderer = 0; void mitk::RendererAccess::Set3DRenderer(vtkRenderer* renwin4) { m_3DRenderer = renwin4; } vtkRenderer* mitk::RendererAccess::Get3DRenderer() { return m_3DRenderer; } +void mitk::Caster::Cast(mitk::BaseData*, mitk::Surface*) +{ +} + void mitk::ImageCaster::CastBaseData(mitk::BaseData* const mitkBaseData, itk::SmartPointer& mitkoutputimage){ try { mitkoutputimage = dynamic_cast(mitkBaseData); } catch(...) { return; } } -void mitk::Caster::Cast(mitk::BaseData* mitkBaseData, mitk::Surface* surface){ - surface = dynamic_cast(mitkBaseData); -} - #define DefineMitkImageCasterMethods(r, data, type) \ void mitk::ImageCaster::CastToItkImage(const mitk::Image* mitkImage, itk::SmartPointer >& itkOutputImage) { \ mitk::CastToItkImage >(mitkImage, itkOutputImage); \ } \ void mitk::ImageCaster::CastToMitkImage(const itk::Image* itkImage, itk::SmartPointer& mitkOutputImage) { \ mitk::CastToMitkImage >(itkImage, mitkOutputImage); \ } MITK_PP_SEQ_FOR_EACH(DefineMitkImageCasterMethods, _, MITK_ACCESSBYITK_TYPES_DIMN_SEQ(2)) MITK_PP_SEQ_FOR_EACH(DefineMitkImageCasterMethods, _, MITK_ACCESSBYITK_TYPES_DIMN_SEQ(3)) diff --git a/Core/Code/Testing/mitkNodeDependentPointSetInteractorTest.cpp b/Core/Code/Testing/mitkNodeDependentPointSetInteractorTest.cpp index ec7336f2b5..edc9284ff4 100644 --- a/Core/Code/Testing/mitkNodeDependentPointSetInteractorTest.cpp +++ b/Core/Code/Testing/mitkNodeDependentPointSetInteractorTest.cpp @@ -1,204 +1,204 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2010-05-03 12:55:29 +0200 (Mo, 03 Mai 2010) $ Version: $Revision: 22655 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkNodeDepententPointSetInteractor.h" #include "mitkPointSet.h" #include "mitkPositionEvent.h" #include "mitkVtkPropRenderer.h" #include "mitkStateEvent.h" #include "mitkInteractionConst.h" #include "mitkGlobalInteraction.h" #include "mitkPointOperation.h" #include "mitkTestingMacros.h" #include "mitkStandaloneDataStorage.h" #include "mitkDataNodeFactory.h" #include "mitkStandardFileLocations.h" #include "mitkNodePredicateDataType.h" void SendPositionEvent(mitk::BaseRenderer* sender, int type, int button, int buttonState, int key, const mitk::Point2D& displPosition, const mitk::Point3D& worldPosition) { mitk::Event *posEvent = new mitk::PositionEvent(sender, type, button, buttonState, key, displPosition, worldPosition); mitk::GlobalInteraction::GetInstance()->GetEventMapper()->MapEvent(posEvent); delete posEvent; } //test related to tutorial Step5.cpp int mitkNodeDependentPointSetInteractorTest(int argc, char* argv[]) { MITK_TEST_BEGIN("NodeDependentPointSetInteractor"); // Global interaction must(!) be initialized if used mitk::GlobalInteraction::GetInstance()->Initialize("global"); // Create a DataStorage mitk::StandaloneDataStorage::Pointer ds = mitk::StandaloneDataStorage::New(); MITK_TEST_CONDITION_REQUIRED(ds.IsNotNull(),"Instantiating DataStorage"); //read two images and store to datastorage //these two images are used as node the interactors depend on. If the visibility property of one node if false, the //associated interactor may not change the data mitk::DataNode::Pointer node1, node2; mitk::DataNodeFactory::Pointer nodeReader = mitk::DataNodeFactory::New(); MITK_TEST_CONDITION_REQUIRED(argc >= 3, "Test if a files to load has been specified"); try { //file 1 const std::string filename1 = argv[1]; nodeReader->SetFileName(filename1); nodeReader->Update(); node1 = nodeReader->GetOutput(); ds->Add(node1); //file 2 const std::string filename2 = argv[2]; nodeReader->SetFileName(filename2); nodeReader->Update(); node2 = nodeReader->GetOutput(); ds->Add(node2); } catch(...) { MITK_TEST_FAILED_MSG(<< "Could not read file for testing"); - return NULL; + return EXIT_FAILURE; } //check for the two images mitk::NodePredicateDataType::Pointer predicate(mitk::NodePredicateDataType::New("Image")); mitk::DataStorage::SetOfObjects::ConstPointer allImagesInDS = ds->GetSubset(predicate); MITK_TEST_CONDITION_REQUIRED(allImagesInDS->Size()==2,"load images to data storage"); // Create PointSet and a node for it mitk::PointSet::Pointer pointSet1 = mitk::PointSet::New(); mitk::DataNode::Pointer pointSetNode1 = mitk::DataNode::New(); pointSetNode1->AddProperty( "unselectedcolor", mitk::ColorProperty::New(0.0f, 1.0f, 0.0f)); pointSetNode1->SetData(pointSet1); mitk::NodeDepententPointSetInteractor::Pointer interactor1 = mitk::NodeDepententPointSetInteractor::New("pointsetinteractor", pointSetNode1, node1); MITK_TEST_CONDITION_REQUIRED(interactor1.IsNotNull(),"Instanciating NodeDependentPointSetInteractor"); // Add the node to the tree ds->Add(pointSetNode1); mitk::GlobalInteraction::GetInstance()->AddInteractor(interactor1); mitk::PointSet::Pointer pointSet2 = mitk::PointSet::New(); mitk::DataNode::Pointer pointSetNode2 = mitk::DataNode::New(); pointSetNode2->AddProperty( "unselectedcolor", mitk::ColorProperty::New(0.0f, 0.0f, 1.0f)); pointSetNode2->SetData(pointSet2); mitk::NodeDepententPointSetInteractor::Pointer interactor2 = mitk::NodeDepententPointSetInteractor::New("pointsetinteractor", pointSetNode2, node2); MITK_TEST_CONDITION_REQUIRED(interactor2.IsNotNull(),"Instanciating NodeDependentPointSetInteractor"); // Add the node to the tree ds->Add(pointSetNode2); mitk::GlobalInteraction::GetInstance()->AddInteractor(interactor2); //check for the two pointsets mitk::NodePredicateDataType::Pointer predicatePS(mitk::NodePredicateDataType::New("PointSet")); mitk::DataStorage::SetOfObjects::ConstPointer allImagesInDSPS = ds->GetSubset(predicatePS); MITK_TEST_CONDITION_REQUIRED(allImagesInDSPS->Size()==2,"create associated pointsets to data storage"); //create two RenderWindows mitk::RenderingManager::Pointer myRenderingManager = mitk::RenderingManager::New(); vtkRenderWindow* vtkRenWin1 = vtkRenderWindow::New(); mitk::VtkPropRenderer::Pointer br1 = mitk::VtkPropRenderer::New("testingBR", vtkRenWin1, myRenderingManager); mitk::BaseRenderer::AddInstance(vtkRenWin1,br1); myRenderingManager->AddRenderWindow(vtkRenWin1); mitk::BaseRenderer::Pointer renderer1 = mitk::BaseRenderer::GetInstance(vtkRenWin1); vtkRenderWindow* vtkRenWin2 = vtkRenderWindow::New(); mitk::VtkPropRenderer::Pointer br2 = mitk::VtkPropRenderer::New("testingBR", vtkRenWin2, myRenderingManager); mitk::BaseRenderer::AddInstance(vtkRenWin2,br2); myRenderingManager->AddRenderWindow(vtkRenWin2); mitk::BaseRenderer::Pointer renderer2 = mitk::BaseRenderer::GetInstance(vtkRenWin2); //set properties for renderWindow 1 and 2 //1: node1->SetBoolProperty("visible", true, renderer1); node2->SetBoolProperty("visible", false, renderer1); //2: node1->SetBoolProperty("visible", false, renderer2); node2->SetBoolProperty("visible", true, renderer2); //*************************************************** //now start to test if only an event send from renderwindow 1 can interact with interactor 1 and vice versa MITK_TEST_CONDITION_REQUIRED(pointSet1->GetPointSet()->GetNumberOfPoints()==0,"Checking empty pointset 1"); MITK_TEST_CONDITION_REQUIRED(pointSet2->GetPointSet()->GetNumberOfPoints()==0,"Checking empty pointset 2."); //sending an event to interactor1 mitk::Point3D pos3D; mitk::Point2D pos2D; pos3D[0]= 10.0; pos3D[1]= 20.0; pos3D[2]= 30.0; pos2D[0]= 100; pos2D[0]= 200; //add to pointset 1 SendPositionEvent(renderer1, mitk::Type_MouseButtonPress, mitk::BS_LeftButton, mitk::BS_ShiftButton, mitk::Key_none, pos2D, pos3D); MITK_TEST_CONDITION_REQUIRED(pointSet1->GetPointSet()->GetNumberOfPoints()==1,"1 Checking addition of point to pointset 1"); MITK_TEST_CONDITION_REQUIRED(pointSet2->GetPointSet()->GetNumberOfPoints()==0,"2 Checking empty pointset 2"); //add to pointset 2 SendPositionEvent(renderer2, mitk::Type_MouseButtonPress, mitk::BS_LeftButton, mitk::BS_ShiftButton, mitk::Key_none, pos2D, pos3D); MITK_TEST_CONDITION_REQUIRED(pointSet1->GetPointSet()->GetNumberOfPoints()==1,"3 Checking untouched state of pointset 1"); MITK_TEST_CONDITION_REQUIRED(pointSet2->GetPointSet()->GetNumberOfPoints()==1,"4 Checking addition of point to pointset 2"); //add to pointset 2 SendPositionEvent(renderer2, mitk::Type_MouseButtonPress, mitk::BS_LeftButton, mitk::BS_ShiftButton, mitk::Key_none, pos2D, pos3D); MITK_TEST_CONDITION_REQUIRED(pointSet1->GetPointSet()->GetNumberOfPoints()==1,"5 Checking untouched state of pointset 1"); MITK_TEST_CONDITION_REQUIRED(pointSet2->GetPointSet()->GetNumberOfPoints()==2,"6 Checking addition of point to pointset 2"); //add to pointset 2 SendPositionEvent(renderer2, mitk::Type_MouseButtonPress, mitk::BS_LeftButton, mitk::BS_ShiftButton, mitk::Key_none, pos2D, pos3D); MITK_TEST_CONDITION_REQUIRED(pointSet1->GetPointSet()->GetNumberOfPoints()==1,"7 Checking untouched state of pointset 1"); MITK_TEST_CONDITION_REQUIRED(pointSet2->GetPointSet()->GetNumberOfPoints()==3,"8 Checking addition of point to pointset 2"); //add to pointset 1 SendPositionEvent(renderer1, mitk::Type_MouseButtonPress, mitk::BS_LeftButton, mitk::BS_ShiftButton, mitk::Key_none, pos2D, pos3D); MITK_TEST_CONDITION_REQUIRED(pointSet1->GetPointSet()->GetNumberOfPoints()==2,"9 Checking addition of point to pointset 1"); MITK_TEST_CONDITION_REQUIRED(pointSet2->GetPointSet()->GetNumberOfPoints()==3,"10 Checking untouched state of pointset 2"); //trying to delete points mitk::Event* delEvent1 = new mitk::Event(renderer1, mitk::Type_KeyPress, mitk::BS_NoButton, mitk::BS_NoButton, mitk::Key_Delete); mitk::Event* delEvent2 = new mitk::Event(renderer2, mitk::Type_KeyPress, mitk::BS_NoButton, mitk::BS_NoButton, mitk::Key_Delete); mitk::GlobalInteraction::GetInstance()->GetEventMapper()->MapEvent(delEvent2); MITK_TEST_CONDITION_REQUIRED(pointSet1->GetPointSet()->GetNumberOfPoints()==2,"11 Checking untouched state of pointset 1"); MITK_TEST_CONDITION_REQUIRED(pointSet2->GetPointSet()->GetNumberOfPoints()==2,"12 Checking detected point in pointset 2"); mitk::GlobalInteraction::GetInstance()->GetEventMapper()->MapEvent(delEvent1); MITK_TEST_CONDITION_REQUIRED(pointSet1->GetPointSet()->GetNumberOfPoints()==1,"11 Checking deleted point in pointset 1"); MITK_TEST_CONDITION_REQUIRED(pointSet2->GetPointSet()->GetNumberOfPoints()==2,"12 Checking untouched state of pointset 2"); mitk::GlobalInteraction::GetInstance()->GetEventMapper()->MapEvent(delEvent2); MITK_TEST_CONDITION_REQUIRED(pointSet1->GetPointSet()->GetNumberOfPoints()==1,"13 Checking untouched state of pointset 1"); MITK_TEST_CONDITION_REQUIRED(pointSet2->GetPointSet()->GetNumberOfPoints()==1,"14 Checking detected point in pointset 2"); mitk::GlobalInteraction::GetInstance()->RemoveInteractor(interactor1); mitk::GlobalInteraction::GetInstance()->RemoveInteractor(interactor2); delete delEvent1; delete delEvent2; myRenderingManager->RemoveRenderWindow(vtkRenWin1); myRenderingManager->RemoveRenderWindow(vtkRenWin2); vtkRenWin1->Delete(); vtkRenWin2->Delete(); //destroy RenderingManager myRenderingManager = NULL; MITK_TEST_END() } diff --git a/Core/Code/Testing/mitkPlaneGeometryTest.cpp b/Core/Code/Testing/mitkPlaneGeometryTest.cpp index 998af4e4d8..821e08f059 100644 --- a/Core/Code/Testing/mitkPlaneGeometryTest.cpp +++ b/Core/Code/Testing/mitkPlaneGeometryTest.cpp @@ -1,1011 +1,1009 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkPlaneGeometry.h" #include "mitkRotationOperation.h" #include "mitkInteractionConst.h" #include "mitkLine.h" #include "mitkTestingMacros.h" #include #include #include int mappingTests2D(const mitk::PlaneGeometry* planegeometry, const mitk::ScalarType& width, const mitk::ScalarType& height, const mitk::ScalarType& widthInMM, const mitk::ScalarType& heightInMM, const mitk::Point3D& origin, const mitk::Vector3D& right, const mitk::Vector3D& bottom) { std::cout << "Testing mapping Map(pt2d_mm(x=widthInMM/2.3,y=heightInMM/2.5), pt3d_mm) and compare with expected: "; mitk::Point2D pt2d_mm; mitk::Point3D pt3d_mm, expected_pt3d_mm; pt2d_mm[0] = widthInMM/2.3; pt2d_mm[1] = heightInMM/2.5; expected_pt3d_mm = origin+right*(pt2d_mm[0]/right.GetNorm())+bottom*(pt2d_mm[1]/bottom.GetNorm()); planegeometry->Map(pt2d_mm, pt3d_mm); if(mitk::Equal(pt3d_mm, expected_pt3d_mm) == false) { std::cout<<"[FAILED]"<Map(pt3d_mm, testpt2d_mm); if(mitk::Equal(pt2d_mm, testpt2d_mm) == false) { std::cout<<"[FAILED]"<IndexToWorld(pt2d_units, testpt2d_mm); if(mitk::Equal(pt2d_mm, testpt2d_mm) == false) { std::cout<<"[FAILED]"<WorldToIndex(pt2d_mm, testpt2d_units); if(mitk::Equal(pt2d_units, testpt2d_units) == false) { std::cout<<"[FAILED]"<InitializeStandardPlane(right, down, &spacing); /* std::cout << "Testing width, height and thickness (in units): "; if((mitk::Equal(planegeometry->GetExtent(0),width)==false) || (mitk::Equal(planegeometry->GetExtent(1),height)==false) || (mitk::Equal(planegeometry->GetExtent(2),1)==false) ) { std::cout<<"[FAILED]"<GetExtentInMM(0),widthInMM)==false) || (mitk::Equal(planegeometry->GetExtentInMM(1),heightInMM)==false) || (mitk::Equal(planegeometry->GetExtentInMM(2),thicknessInMM)==false) ) { std::cout<<"[FAILED]"< 0. * */ int TestIntersectionPoint() { //init plane with its parameter mitk::PlaneGeometry::Pointer myPlaneGeometry = mitk::PlaneGeometry::New(); mitk::Point3D origin; origin[0] = 0.0; origin[1] = 2.0; origin[2] = 0.0; mitk::Vector3D normal; normal[0] = 0.0; normal[1] = 1.0; normal[2] = 0.0; myPlaneGeometry->InitializePlane(origin,normal); //generate points and line for intersection testing //point distance of given line > 1 mitk::Point3D pointP1; pointP1[0] = 2.0; pointP1[1] = 1.0; pointP1[2] = 0.0; mitk::Point3D pointP2; pointP2[0] = 2.0; pointP2[1] = 4.0; pointP2[2] = 0.0; mitk::Vector3D lineDirection; lineDirection[0] = pointP2[0] - pointP1[0]; lineDirection[1] = pointP2[1] - pointP1[1]; lineDirection[2] = pointP2[2] - pointP1[2]; mitk::Line3D xingline( pointP1, lineDirection ); mitk::Point3D calcXingPoint; myPlaneGeometry->IntersectionPoint(xingline, calcXingPoint); //point distance of given line < 1 mitk::Point3D pointP3; pointP3[0] = 2.0; pointP3[1] = 2.2; pointP3[2] = 0.0; mitk::Point3D pointP4; pointP4[0] = 2.0; pointP4[1] = 1.7; pointP4[2] = 0.0; mitk::Vector3D lineDirection2; lineDirection2[0] = pointP4[0] - pointP3[0]; lineDirection2[1] = pointP4[1] - pointP3[1]; lineDirection2[2] = pointP4[2] - pointP3[2]; mitk::Line3D xingline2( pointP3, lineDirection2 ); mitk::Point3D calcXingPoint2; myPlaneGeometry->IntersectionPoint( xingline2, calcXingPoint2 ); //intersection points must be the same if (calcXingPoint == calcXingPoint2) { return EXIT_SUCCESS; } else { return EXIT_FAILURE; } } /** * @brief This method tests method ProjectPointOntoPlane. * * See also bug #3409. */ int TestProjectPointOntoPlane() { mitk::PlaneGeometry::Pointer myPlaneGeometry = mitk::PlaneGeometry::New(); //create normal mitk::Vector3D normal; normal[0] = 0.0; normal[1] = 0.0; normal[2] = 1.0; //create origin mitk::Point3D origin; origin[0] = -27.582859; origin[1] = 50; origin[2] = 200.27742; //initialize plane geometry myPlaneGeometry->InitializePlane(origin,normal); //output to descripe the test std::cout << "Testing PlaneGeometry according to bug #3409" << std::endl; std::cout << "Our normal is: " << normal << std::endl; std::cout << "So ALL projected points should have exactly the same z-value!" << std::endl; //create a number of points mitk::Point3D myPoints[5]; myPoints[0][0] = -27.582859; myPoints[0][1] = 50.00; myPoints[0][2] = 200.27742; myPoints[1][0] = -26.58662; myPoints[1][1] = 50.00; myPoints[1][2] = 200.19026; myPoints[2][0] = -26.58662; myPoints[2][1] = 50.00; myPoints[2][2] = 200.33124; myPoints[3][0] = 104.58662; myPoints[3][1] = 452.12313; myPoints[3][2] = 866.41236; myPoints[4][0] = -207.58662; myPoints[4][1] = 312.00; myPoints[4][2] = -300.12346; //project points onto plane mitk::Point3D myProjectedPoints[5]; for ( unsigned int i = 0; i < 5; ++i ) { myProjectedPoints[i] = myPlaneGeometry->ProjectPointOntoPlane( myPoints[i] ); } //compare z-values with z-value of plane (should be equal) bool allPointsOnPlane = true; for ( unsigned int i = 0; i < 5; ++i ) { if ( fabs(myProjectedPoints[i][2] - origin[2]) > mitk::sqrteps ) { allPointsOnPlane = false; } } if (!allPointsOnPlane) { std::cout<<"[FAILED]"<InitializeStandardPlane(right.Get_vnl_vector(), bottom.Get_vnl_vector()); std::cout << "Testing width, height and thickness (in units): "; if((mitk::Equal(planegeometry->GetExtent(0),width)==false) || (mitk::Equal(planegeometry->GetExtent(1),height)==false) || (mitk::Equal(planegeometry->GetExtent(2),1)==false) ) { std::cout<<"[FAILED]"<GetExtentInMM(0),widthInMM)==false) || (mitk::Equal(planegeometry->GetExtentInMM(1),heightInMM)==false) || (mitk::Equal(planegeometry->GetExtentInMM(2),thicknessInMM)==false) ) { std::cout<<"[FAILED]"<GetAxisVector(0), right)==false) || (mitk::Equal(planegeometry->GetAxisVector(1), bottom)==false) || (mitk::Equal(planegeometry->GetAxisVector(2), normal)==false)) { std::cout<<"[FAILED]"<InitializeStandardPlane(right.Get_vnl_vector(), bottom.Get_vnl_vector(), &spacing); std::cout << "Testing width, height and thickness (in units): "; if((mitk::Equal(planegeometry->GetExtent(0),width)==false) || (mitk::Equal(planegeometry->GetExtent(1),height)==false) || (mitk::Equal(planegeometry->GetExtent(2),1)==false) ) { std::cout<<"[FAILED]"<GetExtentInMM(0),widthInMM)==false) || (mitk::Equal(planegeometry->GetExtentInMM(1),heightInMM)==false) || (mitk::Equal(planegeometry->GetExtentInMM(2),thicknessInMM)==false) ) { std::cout<<"[FAILED]"<GetAxisVector(0), right)==false) || (mitk::Equal(planegeometry->GetAxisVector(1), bottom)==false) || (mitk::Equal(planegeometry->GetAxisVector(2), normal)==false)) { std::cout<<"[FAILED]"<SetExtentInMM(2, thicknessInMM); if(mitk::Equal(planegeometry->GetExtentInMM(2),thicknessInMM)==false) { std::cout<<"[FAILED]"<GetAxisVector(2), normal)==false) { std::cout<<"[FAILED]"<SetOrigin(origin); if(mitk::Equal(planegeometry->GetOrigin(), origin)==false) { std::cout<<"[FAILED]"<GetAxisVector(0), right)==false) || (mitk::Equal(planegeometry->GetAxisVector(1), bottom)==false) || (mitk::Equal(planegeometry->GetAxisVector(2), normal)==false)) { std::cout<<"[FAILED]"<GetIndexToWorldTransform()->GetMatrix().GetVnlMatrix(); mitk::VnlVector axis(3); mitk::FillVector3D(axis, 1.0, 1.0, 1.0); axis.normalize(); vnl_quaternion rotation(axis, 0.223); vnlmatrix = rotation.rotation_matrix_transpose()*vnlmatrix; mitk::Matrix3D matrix; matrix = vnlmatrix; transform->SetMatrix(matrix); transform->SetOffset(planegeometry->GetIndexToWorldTransform()->GetOffset()); right.Set_vnl_vector( rotation.rotation_matrix_transpose()*right.Get_vnl_vector() ); bottom.Set_vnl_vector(rotation.rotation_matrix_transpose()*bottom.Get_vnl_vector()); normal.Set_vnl_vector(rotation.rotation_matrix_transpose()*normal.Get_vnl_vector()); planegeometry->SetIndexToWorldTransform(transform); //The origin changed,because m_Origin=m_IndexToWorldTransform->GetOffset()+GetAxisVector(2)*0.5 //and the AxisVector changes due to the rotation. In other words: the rotation was done around //the corner of the box, not around the planes origin. Now change it to a rotation around //the origin, simply by re-setting the origin to the original one: planegeometry->SetOrigin(origin); mitk::Point3D cornerpoint0 = planegeometry->GetCornerPoint(0); std::cout << "Testing whether SetIndexToWorldTransform kept origin: "; if(mitk::Equal(planegeometry->GetOrigin(), origin)==false) { std::cout<<"[FAILED]"<WorldToIndex(point, dummy); planegeometry->IndexToWorld(dummy, dummy); MITK_TEST_CONDITION_REQUIRED(dummy == point, ""); std::cout<<"[PASSED]"<GetExtentInMM(0),widthInMM)==false) || (mitk::Equal(planegeometry->GetExtentInMM(1),heightInMM)==false) || (mitk::Equal(planegeometry->GetExtentInMM(2),thicknessInMM)==false) ) { std::cout<<"[FAILED]"<GetAxisVector(0), right)==false) || (mitk::Equal(planegeometry->GetAxisVector(1), bottom)==false) || (mitk::Equal(planegeometry->GetAxisVector(2), normal)==false)) { std::cout<<"[FAILED]"<GetExtentInMM(direction) of rotated version: "; if((mitk::Equal(planegeometry->GetAxisVector(0).GetNorm(),planegeometry->GetExtentInMM(0))==false) || (mitk::Equal(planegeometry->GetAxisVector(1).GetNorm(),planegeometry->GetExtentInMM(1))==false) || (mitk::Equal(planegeometry->GetAxisVector(2).GetNorm(),planegeometry->GetExtentInMM(2))==false) ) { std::cout<<"[FAILED]"<SetSizeInUnits(width, height); std::cout << "Testing width, height and thickness (in units): "; if((mitk::Equal(planegeometry->GetExtent(0),width)==false) || (mitk::Equal(planegeometry->GetExtent(1),height)==false) || (mitk::Equal(planegeometry->GetExtent(2),1)==false) ) { std::cout<<"[FAILED]"<GetExtentInMM(0), widthInMM) || !mitk::Equal(planegeometry->GetExtentInMM(1), heightInMM) || !mitk::Equal(planegeometry->GetExtentInMM(2), thicknessInMM)) { std::cout<<"[FAILED]"<GetAxisVector(0), right)==false) || (mitk::Equal(planegeometry->GetAxisVector(1), bottom)==false) || (mitk::Equal(planegeometry->GetAxisVector(2), normal)==false)) { std::cout<<"[FAILED]"<GetExtentInMM(direction) of rotated version: "; if((mitk::Equal(planegeometry->GetAxisVector(0).GetNorm(),planegeometry->GetExtentInMM(0))==false) || (mitk::Equal(planegeometry->GetAxisVector(1).GetNorm(),planegeometry->GetExtentInMM(1))==false) || (mitk::Equal(planegeometry->GetAxisVector(2).GetNorm(),planegeometry->GetExtentInMM(2))==false) ) { std::cout<<"[FAILED]"<(planegeometry->Clone().GetPointer()); if((clonedplanegeometry.IsNull()) || (clonedplanegeometry->GetReferenceCount()!=1)) { std::cout<<"[FAILED]"<GetOrigin(), origin)==false) { std::cout<<"[FAILED]"<GetExtent(0),width)==false) || (mitk::Equal(clonedplanegeometry->GetExtent(1),height)==false) || (mitk::Equal(clonedplanegeometry->GetExtent(2),1)==false) ) { std::cout<<"[FAILED]"<GetExtentInMM(0), widthInMM) || !mitk::Equal(clonedplanegeometry->GetExtentInMM(1), heightInMM) || !mitk::Equal(clonedplanegeometry->GetExtentInMM(2), thicknessInMM)) { std::cout<<"[FAILED]"<GetAxisVector(0), right)==false) || (mitk::Equal(clonedplanegeometry->GetAxisVector(1), bottom)==false) || (mitk::Equal(clonedplanegeometry->GetAxisVector(2), normal)==false)) { std::cout<<"[FAILED]"<(planegeometry->Clone().GetPointer()); if((clonedplanegeometry2.IsNull()) || (clonedplanegeometry2->GetReferenceCount()!=1)) { std::cout<<"[FAILED]"<IsOnPlane(planegeometry), true) ==false) { std::cout<<"[FAILED]"<IsOnPlane(origin), true)==false) { std::cout<<"[FAILED]"< rotation2(newaxis, 0.0); mitk::Vector3D clonednormal = clonedplanegeometry2->GetNormal(); mitk::Point3D clonedorigin = clonedplanegeometry2->GetOrigin(); mitk::RotationOperation* planerot = new mitk::RotationOperation( mitk::OpROTATE, origin, clonedplanegeometry2->GetAxisVector( 0 ), 180.0 ); clonedplanegeometry2->ExecuteOperation( planerot ); std::cout << "Testing whether the flipped plane is still the original plane: "; if( mitk::Equal( clonedplanegeometry2->IsOnPlane(planegeometry), true )==false ) { std::cout<<"[FAILED]"<SetOrigin( clonedorigin ); std::cout << "Testing if the translated (cloned, flipped) plane is parallel to its origin plane: "; if( mitk::Equal( clonedplanegeometry2->IsParallel(planegeometry), true )==false ) { std::cout<<"[FAILED]"<GetAxisVector( 0 ), 0.5 ); clonedplanegeometry2->ExecuteOperation( planerot ); std::cout << "Testing if a non-paralell plane gets recognized as not paralell [rotation +0.5 degree] : "; if( mitk::Equal( clonedplanegeometry2->IsParallel(planegeometry), false )==false ) { std::cout<<"[FAILED]"<GetAxisVector( 0 ), -1.0 ); clonedplanegeometry2->ExecuteOperation( planerot ); std::cout << "Testing if a non-paralell plane gets recognized as not paralell [rotation -0.5 degree] : "; if( mitk::Equal( clonedplanegeometry2->IsParallel(planegeometry), false )==false ) { std::cout<<"[FAILED]"<GetAxisVector( 0 ), 360.5 ); clonedplanegeometry2->ExecuteOperation( planerot ); std::cout << "Testing if a non-paralell plane gets recognized as not paralell [rotation 360 degree] : "; if( mitk::Equal( clonedplanegeometry2->IsParallel(planegeometry), true )==false ) { std::cout<<"[FAILED]"<InitializeStandardPlane(clonedplanegeometry); std::cout << "Testing origin of transversally initialized version: "; if(mitk::Equal(planegeometry->GetOrigin(), origin)==false) { std::cout<<"[FAILED]"<GetCornerPoint(0), cornerpoint0)==false) { std::cout<<"[FAILED]"<GetExtent(0), width) || !mitk::Equal(planegeometry->GetExtent(1), height) || !mitk::Equal(planegeometry->GetExtent(2), 1)) { std::cout<<"[FAILED]"<GetExtentInMM(0), widthInMM) || !mitk::Equal(planegeometry->GetExtentInMM(1), heightInMM) || !mitk::Equal(planegeometry->GetExtentInMM(2), thicknessInMM)) { std::cout<<"[FAILED]"<GetAxisVector(0), right)==false) || (mitk::Equal(planegeometry->GetAxisVector(1), bottom)==false) || (mitk::Equal(planegeometry->GetAxisVector(2), normal)==false)) { std::cout<<"[FAILED]"<InitializeStandardPlane(clonedplanegeometry, mitk::PlaneGeometry::Frontal); newright = right; newbottom = normal; newbottom.Normalize(); newbottom *= thicknessInMM; newthicknessInMM = heightInMM/height*1.0/*extent in normal direction is 1*/; newnormal = -bottom; newnormal.Normalize(); newnormal *= newthicknessInMM; std::cout << "Testing GetCornerPoint(0) of frontally initialized version: "; if(mitk::Equal(planegeometry->GetCornerPoint(0), cornerpoint0)==false) { std::cout<<"[FAILED]"<GetOrigin(); std::cout << "Testing width, height and thickness (in units) of frontally initialized version: "; if(!mitk::Equal(planegeometry->GetExtent(0), width) || !mitk::Equal(planegeometry->GetExtent(1), 1) || !mitk::Equal(planegeometry->GetExtent(2), 1)) { std::cout<<"[FAILED]"<GetExtentInMM(0), widthInMM) || !mitk::Equal(planegeometry->GetExtentInMM(1), thicknessInMM) || !mitk::Equal(planegeometry->GetExtentInMM(2), newthicknessInMM)) { std::cout<<"[FAILED]"<GetAxisVector(0), newright)==false) || (mitk::Equal(planegeometry->GetAxisVector(1), newbottom)==false) || (mitk::Equal(planegeometry->GetAxisVector(2), newnormal)==false)) { std::cout<<"[FAILED]"<SetSizeInUnits(planegeometry->GetExtentInMM(0), planegeometry->GetExtentInMM(1)); std::cout << "Testing origin of unit spaced, frontally initialized version: "; if(mitk::Equal(planegeometry->GetOrigin(), origin)==false) { std::cout<<"[FAILED]"<GetExtent(0), widthInMM) || !mitk::Equal(planegeometry->GetExtent(1), thicknessInMM) || !mitk::Equal(planegeometry->GetExtent(2), 1)) { std::cout<<"[FAILED]"<GetExtentInMM(0), widthInMM) || !mitk::Equal(planegeometry->GetExtentInMM(1), thicknessInMM) || !mitk::Equal(planegeometry->GetExtentInMM(2), newthicknessInMM)) { std::cout<<"[FAILED]"<GetAxisVector(0), newright)==false) || (mitk::Equal(planegeometry->GetAxisVector(1), newbottom)==false) || (mitk::Equal(planegeometry->GetAxisVector(2), newnormal)==false)) { std::cout<<"[FAILED]"<SetExtentInMM(2, 1.0); newnormal.Normalize(); std::cout << "Testing origin of unit spaced, frontally initialized version: "; if(mitk::Equal(planegeometry->GetOrigin(), origin)==false) { std::cout<<"[FAILED]"<GetExtent(0), widthInMM) || !mitk::Equal(planegeometry->GetExtent(1), thicknessInMM) || !mitk::Equal(planegeometry->GetExtent(2), 1)) { std::cout<<"[FAILED]"<GetExtentInMM(0), widthInMM) || !mitk::Equal(planegeometry->GetExtentInMM(1), thicknessInMM) || !mitk::Equal(planegeometry->GetExtentInMM(2), 1.0)) { std::cout<<"[FAILED]"<GetAxisVector(0), newright)==false) || (mitk::Equal(planegeometry->GetAxisVector(1), newbottom)==false) || (mitk::Equal(planegeometry->GetAxisVector(2), newnormal)==false)) { std::cout<<"[FAILED]"<InitializeStandardPlane(clonedplanegeometry, mitk::PlaneGeometry::Sagittal); newright = bottom; newthicknessInMM = widthInMM/width*1.0/*extent in normal direction is 1*/; newnormal = right; newnormal.Normalize(); newnormal *= newthicknessInMM; std::cout << "Testing GetCornerPoint(0) of sagitally initialized version: "; if(mitk::Equal(planegeometry->GetCornerPoint(0), cornerpoint0)==false) { std::cout<<"[FAILED]"<GetOrigin(); std::cout << "Testing width, height and thickness (in units) of sagitally initialized version: "; if(!mitk::Equal(planegeometry->GetExtent(0), height) || !mitk::Equal(planegeometry->GetExtent(1), 1) || !mitk::Equal(planegeometry->GetExtent(2), 1)) { std::cout<<"[FAILED]"<GetExtentInMM(0), heightInMM) || !mitk::Equal(planegeometry->GetExtentInMM(1), thicknessInMM) || !mitk::Equal(planegeometry->GetExtentInMM(2), newthicknessInMM)) { std::cout<<"[FAILED]"<GetAxisVector(0), newright)==false) || (mitk::Equal(planegeometry->GetAxisVector(1), newbottom)==false) || (mitk::Equal(planegeometry->GetAxisVector(2), newnormal)==false)) { std::cout<<"[FAILED]"<GetOrigin(); std::cout << "Testing backside initialization: InitializeStandardPlane(clonedplanegeometry, planeorientation = Transversal, zPosition = 0, frontside=false, rotated=true): " <InitializeStandardPlane(clonedplanegeometry, mitk::PlaneGeometry::Transversal, 0, false, true); mitk::Point3D backsideorigin; backsideorigin=origin+clonedplanegeometry->GetAxisVector(1);//+clonedplanegeometry->GetAxisVector(2); std::cout << "Testing origin of backsidedly, transversally initialized version: "; if(mitk::Equal(planegeometry->GetOrigin(), backsideorigin)==false) { std::cout<<"[FAILED]"<GetAxisVector(1);//+clonedplanegeometry->GetAxisVector(2); if(mitk::Equal(planegeometry->GetCornerPoint(0), backsidecornerpoint0)==false) { std::cout<<"[FAILED]"<GetExtent(0), width) || !mitk::Equal(planegeometry->GetExtent(1), height) || !mitk::Equal(planegeometry->GetExtent(2), 1)) { std::cout<<"[FAILED]"<GetExtentInMM(0), widthInMM) || !mitk::Equal(planegeometry->GetExtentInMM(1), heightInMM) || !mitk::Equal(planegeometry->GetExtentInMM(2), thicknessInMM)) { std::cout<<"[FAILED]"<GetAxisVector(0), right)==false) || (mitk::Equal(planegeometry->GetAxisVector(1), -bottom)==false) || (mitk::Equal(planegeometry->GetAxisVector(2), -normal)==false)) { std::cout<<"[FAILED]"< #include "mitkGetModuleContext.h" std::vector m_Geometries; std::vector m_SliceIndices; mitk::PlanePositionManagerService* m_Service; int SetUpBeforeTest() { //Getting Service mitk::ServiceReference serviceRef = mitk::GetModuleContext()->GetServiceReference(); m_Service = dynamic_cast(mitk::GetModuleContext()->GetService(serviceRef)); if (m_Service == 0) return EXIT_FAILURE; //Creating different Geometries m_Geometries.reserve(100); mitk::PlaneGeometry::PlaneOrientation views[] = {mitk::PlaneGeometry::Transversal, mitk::PlaneGeometry::Sagittal, mitk::PlaneGeometry::Frontal}; for (unsigned int i = 0; i < 100; ++i) { mitk::PlaneGeometry::Pointer plane = mitk::PlaneGeometry::New(); mitk::ScalarType width = 256+(0.01*i); mitk::ScalarType height = 256+(0.002*i); mitk::Vector3D right; mitk::Vector3D down; right[0] = 1; right[1] = i; right[2] = 0.5; down[0] = i*0.02; down[1] = 1; down[2] = i*0.03; mitk::Vector3D spacing; mitk::FillVector3D(spacing, 1.0*0.02*i, 1.0*0.15*i, 1.0); mitk::Vector3D rightVector; mitk::FillVector3D(rightVector, 0.02*(i+1), 0+(0.05*i), 1.0); mitk::Vector3D downVector; mitk::FillVector3D(downVector, 1, 3-0.01*i, 0.0345*i); vnl_vector normal = vnl_cross_3d(rightVector.GetVnlVector(), downVector.GetVnlVector()); normal.normalize(); normal *= 1.5; mitk::Vector3D origin; origin.Fill(1); origin[0] = 12 + 0.03*i; mitk::AffineTransform3D::Pointer transform = mitk::AffineTransform3D::New(); mitk::Matrix3D matrix; matrix.GetVnlMatrix().set_column(0, rightVector.GetVnlVector()); matrix.GetVnlMatrix().set_column(1, downVector.GetVnlVector()); matrix.GetVnlMatrix().set_column(2, normal); transform->SetMatrix(matrix); transform->SetOffset(origin); plane->InitializeStandardPlane(width, height, transform, views[i%3], i, true, false); m_Geometries.push_back(plane); } return EXIT_SUCCESS; } int testAddPlanePosition() { MITK_TEST_OUTPUT(<<"Starting Test: ######### A d d P l a n e P o s i t i o n #########"); MITK_TEST_CONDITION(m_Service != NULL, "Testing getting of PlanePositionManagerService"); unsigned int currentID(m_Service->AddNewPlanePosition(m_Geometries.at(0),0)); bool error = ((m_Service->GetNumberOfPlanePositions() != 1)||(currentID != 0)); if(error) { MITK_TEST_CONDITION(m_Service->GetNumberOfPlanePositions() == 1,"Checking for correct number of planepositions"); MITK_TEST_CONDITION(currentID == 0, "Testing for correct ID"); return EXIT_FAILURE; } //Adding new planes for(unsigned int i = 1; i < m_Geometries.size(); ++i) { unsigned int newID = m_Service->AddNewPlanePosition(m_Geometries.at(i),i); error = ((m_Service->GetNumberOfPlanePositions() != i+1)||(newID != (currentID+1))); if (error) { MITK_TEST_CONDITION(m_Service->GetNumberOfPlanePositions() == i+1,"Checking for correct number of planepositions"); MITK_TEST_CONDITION(newID == (currentID+1), "Testing for correct ID"); MITK_TEST_OUTPUT(<<"New: "<GetNumberOfPlanePositions(); //Adding existing planes -> nothing should change for(unsigned int i = 0; i < (m_Geometries.size()-1)*0.5; ++i) { unsigned int newID = m_Service->AddNewPlanePosition(m_Geometries.at(i*2),i*2); error = ((m_Service->GetNumberOfPlanePositions() != numberOfPlanePos)||(newID != i*2)); if (error) { MITK_TEST_CONDITION( m_Service->GetNumberOfPlanePositions() == numberOfPlanePos, "Checking for correct number of planepositions"); MITK_TEST_CONDITION(newID == i*2, "Testing for correct ID"); return EXIT_FAILURE; } } return EXIT_SUCCESS; } int testGetPlanePosition() { mitk::PlaneGeometry* plane; mitk::RestorePlanePositionOperation* op; bool error(true); MITK_TEST_OUTPUT(<<"Starting Test: ######### G e t P l a n e P o s i t i o n #########"); //Testing for existing planepositions for (unsigned int i = 0; i < m_Geometries.size(); ++i) { plane = m_Geometries.at(i); - mitk::PlaneGeometry* test = m_Geometries.at(i); test; op = m_Service->GetPlanePosition(i); error = ( !mitk::Equal(op->GetHeight(),plane->GetExtent(1)) || !mitk::Equal(op->GetWidth(),plane->GetExtent(0)) || !mitk::Equal(op->GetSpacing(),plane->GetSpacing()) || !mitk::Equal(op->GetTransform()->GetOffset(),plane->GetIndexToWorldTransform()->GetOffset()) || !mitk::Equal(op->GetDirectionVector().Get_vnl_vector(),plane->GetIndexToWorldTransform()->GetMatrix().GetVnlMatrix().get_column(2).normalize()) || !mitk::MatrixEqualElementWise(op->GetTransform()->GetMatrix(), plane->GetIndexToWorldTransform()->GetMatrix()) ); if( error ) { MITK_TEST_OUTPUT(<<"Iteration: "<GetHeight(),plane->GetExtent(1)) && mitk::Equal(op->GetWidth(),plane->GetExtent(0)), "Checking for correct extent"); MITK_TEST_CONDITION( mitk::Equal(op->GetSpacing(),plane->GetSpacing()), "Checking for correct spacing"); MITK_TEST_CONDITION( mitk::Equal(op->GetTransform()->GetOffset(),plane->GetIndexToWorldTransform()->GetOffset()), "Checking for correct offset"); MITK_INFO<<"Op: "<GetDirectionVector()<<" plane: "<GetIndexToWorldTransform()->GetMatrix().GetVnlMatrix().get_column(2)<<"\n"; MITK_TEST_CONDITION( mitk::Equal(op->GetDirectionVector().Get_vnl_vector(),plane->GetIndexToWorldTransform()->GetMatrix().GetVnlMatrix().get_column(2)), "Checking for correct direction"); MITK_TEST_CONDITION( mitk::MatrixEqualElementWise(op->GetTransform()->GetMatrix(), plane->GetIndexToWorldTransform()->GetMatrix()), "Checking for correct matrix"); return EXIT_FAILURE; } } //Testing for not existing planepositions error = ( m_Service->GetPlanePosition(100000000) != 0 || m_Service->GetPlanePosition(-1) != 0 ); if (error) { MITK_TEST_CONDITION(m_Service->GetPlanePosition(100000000) == 0, "Trying to get non existing pos"); MITK_TEST_CONDITION(m_Service->GetPlanePosition(-1) == 0, "Trying to get non existing pos"); return EXIT_FAILURE; } return EXIT_SUCCESS; } int testRemovePlanePosition() { MITK_TEST_OUTPUT(<<"Starting Test: ######### R e m o v e P l a n e P o s i t i o n #########"); unsigned int size = m_Service->GetNumberOfPlanePositions(); bool removed (true); //Testing for invalid IDs removed = m_Service->RemovePlanePosition( -1 ); removed = m_Service->RemovePlanePosition( 1000000 ); unsigned int size2 = m_Service->GetNumberOfPlanePositions(); if (removed) { MITK_TEST_CONDITION(removed == false, "Testing remove not existing planepositions"); MITK_TEST_CONDITION(size == size2, "Testing remove not existing planepositions"); return EXIT_FAILURE; } //Testing for valid IDs for (unsigned int i = 0; i < m_Geometries.size()*0.5; i++) { removed = m_Service->RemovePlanePosition( i ); unsigned int size2 = m_Service->GetNumberOfPlanePositions(); removed = (size2 == (size-(i+1))); if (!removed) { MITK_TEST_CONDITION(removed == true, "Testing remove existing planepositions"); MITK_TEST_CONDITION(size == (size-i+1), "Testing remove existing planepositions"); return EXIT_FAILURE; } } return EXIT_SUCCESS; } int testRemoveAll() { MITK_TEST_OUTPUT(<<"Starting Test: ######### R e m o v e A l l #########"); unsigned int numPos = m_Service->GetNumberOfPlanePositions(); MITK_INFO<RemoveAllPlanePositions(); bool error (true); error = (m_Service->GetNumberOfPlanePositions() != 0 || m_Service->GetPlanePosition(60) != 0); if (error) { MITK_TEST_CONDITION(m_Service->GetNumberOfPlanePositions() == 0, "Testing remove all pos"); MITK_TEST_CONDITION(m_Service->GetPlanePosition(60) == 0, "Testing remove all pos"); return EXIT_FAILURE; } return EXIT_SUCCESS; } int mitkPlanePositionManagerTest(int, char* []) { MITK_TEST_OUTPUT(<<"Starting Test PlanePositionManager"); SetUpBeforeTest(); int result; MITK_TEST_CONDITION_REQUIRED( (result = testAddPlanePosition()) == EXIT_SUCCESS, ""); MITK_TEST_CONDITION_REQUIRED( (result = testGetPlanePosition()) == EXIT_SUCCESS, ""); MITK_TEST_CONDITION_REQUIRED( (result = testRemovePlanePosition()) == EXIT_SUCCESS, ""); MITK_TEST_CONDITION_REQUIRED( (result = testRemoveAll()) == EXIT_SUCCESS, ""); return EXIT_SUCCESS; } diff --git a/Core/Code/Testing/mitkPointSetReaderTest.cpp b/Core/Code/Testing/mitkPointSetReaderTest.cpp index 7dfbb00288..aa524cf44e 100644 --- a/Core/Code/Testing/mitkPointSetReaderTest.cpp +++ b/Core/Code/Testing/mitkPointSetReaderTest.cpp @@ -1,65 +1,66 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision: 7837 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkPointSet.h" #include "mitkPointSetReader.h" #include "mitkTestingMacros.h" /** * Test for the class "mitkPointSetReader". * * argc and argv are the command line parameters which were passed to * the ADD_TEST command in the CMakeLists.txt file. For the automatic * tests, argv is either empty for the simple tests or contains the filename * of a test data set for the tests (see CMakeLists.txt). */ -int mitkPointSetReaderTest(int argc , char* argv[]) +int mitkPointSetReaderTest(int argc , char** argv) { // always start with this! MITK_TEST_BEGIN("PointSetReader") + MITK_TEST_CONDITION_REQUIRED(argc == 2,"Testing invocation") // let's create an object of our class mitk::PointSetReader::Pointer myPointSetReader = mitk::PointSetReader::New(); MITK_TEST_CONDITION_REQUIRED(myPointSetReader.IsNotNull(),"Testing instantiation") // testing set / get name with invalid data std::string testName = "test1"; myPointSetReader->SetFileName( testName ); MITK_TEST_CONDITION_REQUIRED( myPointSetReader->GetFileName()== testName, "Testing set / get file name methods!"); // testing file reading with invalid data MITK_TEST_CONDITION_REQUIRED( !myPointSetReader->CanReadFile(testName,"",""), "Testing CanReadFile() method with invalid input file name!"); myPointSetReader->Update(); MITK_TEST_CONDITION_REQUIRED( !myPointSetReader->GetSuccess(), "Testing GetSuccess() with invalid input file name!"); // testing file reading with invalid data myPointSetReader->SetFileName(argv[1]); MITK_TEST_CONDITION_REQUIRED( myPointSetReader->CanReadFile(argv[1], "", ""), "Testing CanReadFile() method with valid input file name!"); myPointSetReader->Modified(); myPointSetReader->Update(); MITK_TEST_CONDITION_REQUIRED( myPointSetReader->GetSuccess(), "Testing GetSuccess() with valid input file name!"); // evaluate if the read point set is correct mitk::PointSet::Pointer resultPS = myPointSetReader->GetOutput(); MITK_TEST_CONDITION_REQUIRED( resultPS.IsNotNull(), "Testing output generation!"); MITK_TEST_CONDITION_REQUIRED( resultPS->GetTimeSteps() == 14, "Testing output time step generation!"); // CAVE: Only valid with the specified test data! MITK_TEST_CONDITION_REQUIRED( resultPS->GetPointSet(resultPS->GetTimeSteps()-1)->GetNumberOfPoints() == 0, "Testing output time step generation with empty time step!"); // CAVE: Only valid with the specified test data! // always end with this! MITK_TEST_END() } diff --git a/Core/Code/Testing/mitkSliceNavigationControllerTest.cpp b/Core/Code/Testing/mitkSliceNavigationControllerTest.cpp index 46d8f9f525..441f8af53c 100644 --- a/Core/Code/Testing/mitkSliceNavigationControllerTest.cpp +++ b/Core/Code/Testing/mitkSliceNavigationControllerTest.cpp @@ -1,420 +1,417 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkSliceNavigationController.h" #include "mitkPlaneGeometry.h" #include "mitkSlicedGeometry3D.h" #include "mitkTimeSlicedGeometry.h" #include "mitkRotationOperation.h" #include "mitkInteractionConst.h" #include "mitkPlanePositionManager.h" #include "mitkTestingMacros.h" #include "mitkGetModuleContext.h" #include #include #include bool operator==(const mitk::Geometry3D & left, const mitk::Geometry3D & right) { mitk::BoundingBox::BoundsArrayType leftbounds, rightbounds; leftbounds =left.GetBounds(); rightbounds=right.GetBounds(); unsigned int i; for(i=0;i<6;++i) if(mitk::Equal(leftbounds[i],rightbounds[i])==false) return false; const mitk::Geometry3D::TransformType::MatrixType & leftmatrix = left.GetIndexToWorldTransform()->GetMatrix(); const mitk::Geometry3D::TransformType::MatrixType & rightmatrix = right.GetIndexToWorldTransform()->GetMatrix(); unsigned int j; for(i=0;i<3;++i) { const mitk::Geometry3D::TransformType::MatrixType::ValueType* leftvector = leftmatrix[i]; const mitk::Geometry3D::TransformType::MatrixType::ValueType* rightvector = rightmatrix[i]; for(j=0;j<3;++j) if(mitk::Equal(leftvector[i],rightvector[i])==false) return false; } const mitk::Geometry3D::TransformType::OffsetType & leftoffset = left.GetIndexToWorldTransform()->GetOffset(); const mitk::Geometry3D::TransformType::OffsetType & rightoffset = right.GetIndexToWorldTransform()->GetOffset(); for(i=0;i<3;++i) if(mitk::Equal(leftoffset[i],rightoffset[i])==false) return false; return true; } int compareGeometry(const mitk::Geometry3D & geometry, 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) { 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]"<GetCornerPoint(0), cornerpoint0)==false) { std::cout<<"[FAILED]"<SetInputWorldGeometry(geometry); std::cout<<"[PASSED]"<SetViewDirection(mitk::SliceNavigationController::Transversal); std::cout<<"[PASSED]"<Update(); std::cout<<"[PASSED]"<GetCreatedWorldGeometry(), width, height, numSlices, widthInMM, heightInMM, thicknessInMM*numSlices, transversalcornerpoint0, right, bottom*(-1.0), normal*(-1.0)); if(result!=EXIT_SUCCESS) { std::cout<<"[FAILED]"<SetViewDirection(mitk::SliceNavigationController::Frontal); std::cout<<"[PASSED]"<Update(); std::cout<<"[PASSED]"<GetAxisVector(1)*(+0.5/geometry->GetExtent(1)); result = compareGeometry(*sliceCtrl->GetCreatedWorldGeometry(), width, numSlices, height, widthInMM, thicknessInMM*numSlices, heightInMM, frontalcornerpoint0, right, normal, bottom); if(result!=EXIT_SUCCESS) { std::cout<<"[FAILED]"<SetViewDirection(mitk::SliceNavigationController::Sagittal); std::cout<<"[PASSED]"<Update(); std::cout<<"[PASSED]"<GetAxisVector(0)*(+0.5/geometry->GetExtent(0)); result = compareGeometry(*sliceCtrl->GetCreatedWorldGeometry(), height, numSlices, width, heightInMM, thicknessInMM*numSlices, widthInMM, sagittalcornerpoint0, bottom, normal, right); if(result!=EXIT_SUCCESS) { std::cout<<"[FAILED]"<InitializeStandardPlane(right.Get_vnl_vector(), bottom.Get_vnl_vector(), &spacing); planegeometry->SetOrigin(origin); //Create SlicedGeometry3D out of planeGeometry mitk::SlicedGeometry3D::Pointer slicedgeometry1 = mitk::SlicedGeometry3D::New(); unsigned int numSlices = 300; slicedgeometry1->InitializeEvenlySpaced(planegeometry, thicknessInMM, numSlices, false); //Create another slicedgeo which will be rotated mitk::SlicedGeometry3D::Pointer slicedgeometry2 = mitk::SlicedGeometry3D::New(); slicedgeometry2->InitializeEvenlySpaced(planegeometry, thicknessInMM, numSlices, false); //Create geo3D as reference mitk::Geometry3D::Pointer geometry = mitk::Geometry3D::New(); geometry->SetBounds(slicedgeometry1->GetBounds()); geometry->SetIndexToWorldTransform(slicedgeometry1->GetIndexToWorldTransform()); //Initialize planes for (int i=0; i < (int)numSlices; i++) { mitk::PlaneGeometry::Pointer geo2d = mitk::PlaneGeometry::New(); geo2d->Initialize(); geo2d->SetReferenceGeometry(geometry); slicedgeometry1->SetGeometry2D(geo2d,i); } for (int i=0; i < (int)numSlices; i++) { mitk::PlaneGeometry::Pointer geo2d = mitk::PlaneGeometry::New(); geo2d->Initialize(); geo2d->SetReferenceGeometry(geometry); slicedgeometry2->SetGeometry2D(geo2d,i); } slicedgeometry1->SetReferenceGeometry(geometry); slicedgeometry2->SetReferenceGeometry(geometry); //Create SNC mitk::SliceNavigationController::Pointer sliceCtrl1 = mitk::SliceNavigationController::New(); sliceCtrl1->SetInputWorldGeometry(slicedgeometry1); sliceCtrl1->Update(); mitk::SliceNavigationController::Pointer sliceCtrl2 = mitk::SliceNavigationController::New(); sliceCtrl2->SetInputWorldGeometry(slicedgeometry2); sliceCtrl2->Update(); slicedgeometry1->SetSliceNavigationController(sliceCtrl1); slicedgeometry2->SetSliceNavigationController(sliceCtrl2); //Rotate slicedgeo2 double angle = 63.84; mitk::Vector3D rotationVector; mitk::FillVector3D( rotationVector, 0.5, 0.95, 0.23 ); mitk::Point3D center = slicedgeometry2->GetCenter(); mitk::RotationOperation* op = new mitk::RotationOperation( mitk::OpROTATE, center, rotationVector, angle ); slicedgeometry2->ExecuteOperation(op); sliceCtrl2->Update(); mitk::ServiceReference serviceRef = mitk::GetModuleContext()->GetServiceReference(); mitk::PlanePositionManagerService* service = dynamic_cast(mitk::GetModuleContext()->GetService(serviceRef)); service->AddNewPlanePosition(slicedgeometry2->GetGeometry2D(0), 178); sliceCtrl1->ExecuteOperation(service->GetPlanePosition(0)); sliceCtrl1->Update(); mitk::Geometry2D* planeRotated = slicedgeometry2->GetGeometry2D(178); mitk::Geometry2D* planeRestored = dynamic_cast< const mitk::SlicedGeometry3D*>(sliceCtrl1->GetCurrentGeometry3D())->GetGeometry2D(178); bool error = ( !mitk::MatrixEqualElementWise(planeRotated->GetIndexToWorldTransform()->GetMatrix(), planeRestored->GetIndexToWorldTransform()->GetMatrix()) || !mitk::Equal(planeRotated->GetOrigin(), planeRestored->GetOrigin()) || !mitk::Equal(planeRotated->GetSpacing(), planeRestored->GetSpacing()) || !mitk::Equal(slicedgeometry2->GetDirectionVector(), dynamic_cast< const mitk::SlicedGeometry3D*>(sliceCtrl1->GetCurrentGeometry3D())->GetDirectionVector()) || !mitk::Equal(slicedgeometry2->GetSlices(), dynamic_cast< const mitk::SlicedGeometry3D*>(sliceCtrl1->GetCurrentGeometry3D())->GetSlices()) || !mitk::MatrixEqualElementWise(slicedgeometry2->GetIndexToWorldTransform()->GetMatrix(), dynamic_cast< const mitk::SlicedGeometry3D*>(sliceCtrl1->GetCurrentGeometry3D())->GetIndexToWorldTransform()->GetMatrix()) ); if (error) { MITK_TEST_CONDITION(mitk::MatrixEqualElementWise(planeRotated->GetIndexToWorldTransform()->GetMatrix(), planeRestored->GetIndexToWorldTransform()->GetMatrix()),"Testing for IndexToWorld"); MITK_INFO<<"Rotated: \n"<GetIndexToWorldTransform()->GetMatrix()<<" Restored: \n"<GetIndexToWorldTransform()->GetMatrix(); MITK_TEST_CONDITION(mitk::Equal(planeRotated->GetOrigin(), planeRestored->GetOrigin()),"Testing for origin"); MITK_INFO<<"Rotated: \n"<GetOrigin()<<" Restored: \n"<GetOrigin(); MITK_TEST_CONDITION(mitk::Equal(planeRotated->GetSpacing(), planeRestored->GetSpacing()),"Testing for spacing"); MITK_INFO<<"Rotated: \n"<GetSpacing()<<" Restored: \n"<GetSpacing(); MITK_TEST_CONDITION(mitk::Equal(slicedgeometry2->GetDirectionVector(), dynamic_cast< const mitk::SlicedGeometry3D*>(sliceCtrl1->GetCurrentGeometry3D())->GetDirectionVector()),"Testing for directionvector"); MITK_INFO<<"Rotated: \n"<GetDirectionVector()<<" Restored: \n"<(sliceCtrl1->GetCurrentGeometry3D())->GetDirectionVector(); MITK_TEST_CONDITION(mitk::Equal(slicedgeometry2->GetSlices(), dynamic_cast< const mitk::SlicedGeometry3D*>(sliceCtrl1->GetCurrentGeometry3D())->GetSlices()),"Testing for numslices"); MITK_INFO<<"Rotated: \n"<GetSlices()<<" Restored: \n"<(sliceCtrl1->GetCurrentGeometry3D())->GetSlices(); MITK_TEST_CONDITION(mitk::MatrixEqualElementWise(slicedgeometry2->GetIndexToWorldTransform()->GetMatrix(), dynamic_cast< const mitk::SlicedGeometry3D*>(sliceCtrl1->GetCurrentGeometry3D())->GetIndexToWorldTransform()->GetMatrix()),"Testing for IndexToWorld"); MITK_INFO<<"Rotated: \n"<GetIndexToWorldTransform()->GetMatrix()<<" Restored: \n"<(sliceCtrl1->GetCurrentGeometry3D())->GetIndexToWorldTransform()->GetMatrix(); return EXIT_FAILURE; } return EXIT_SUCCESS; } int mitkSliceNavigationControllerTest(int /*argc*/, char* /*argv*/[]) { int result=EXIT_FAILURE; std::cout << "Creating and initializing a PlaneGeometry: "; mitk::PlaneGeometry::Pointer planegeometry = mitk::PlaneGeometry::New(); mitk::Point3D origin; mitk::Vector3D right, bottom, normal; mitk::ScalarType width, height; mitk::ScalarType widthInMM, heightInMM, thicknessInMM; width = 100; widthInMM = width; height = 200; heightInMM = height; thicknessInMM = 1.5; // mitk::FillVector3D(origin, 0, 0, thicknessInMM*0.5); mitk::FillVector3D(origin, 4.5, 7.3, 11.2); mitk::FillVector3D(right, widthInMM, 0, 0); mitk::FillVector3D(bottom, 0, heightInMM, 0); mitk::FillVector3D(normal, 0, 0, thicknessInMM); mitk::Vector3D spacing; normal.Normalize(); normal *= thicknessInMM; mitk::FillVector3D(spacing, 1.0, 1.0, thicknessInMM); planegeometry->InitializeStandardPlane(right.Get_vnl_vector(), bottom.Get_vnl_vector(), &spacing); planegeometry->SetOrigin(origin); std::cout<<"[PASSED]"<InitializeEvenlySpaced(planegeometry, thicknessInMM, numSlices, false); std::cout<<"[PASSED]"<SetBounds(slicedgeometry->GetBounds()); geometry->SetIndexToWorldTransform(slicedgeometry->GetIndexToWorldTransform()); std::cout<<"[PASSED]"<GetCornerPoint(0); result=testGeometry(geometry, width, height, numSlices, widthInMM, heightInMM, thicknessInMM, cornerpoint0, right, bottom, normal); if(result!=EXIT_SUCCESS) return result; - - - mitk::BoundingBox::BoundsArrayType bounds = geometry->GetBounds(); mitk::AffineTransform3D::Pointer transform = mitk::AffineTransform3D::New(); transform->SetMatrix(geometry->GetIndexToWorldTransform()->GetMatrix()); mitk::BoundingBox::Pointer boundingbox = geometry->CalculateBoundingBoxRelativeToTransform(transform); geometry->SetBounds(boundingbox->GetBounds()); cornerpoint0 = geometry->GetCornerPoint(0); result=testGeometry(geometry, width, height, numSlices, widthInMM, heightInMM, thicknessInMM, cornerpoint0, right, bottom, normal); if(result!=EXIT_SUCCESS) return result; std::cout << "Changing the IndexToWorldTransform of the geometry to a rotated version by SetIndexToWorldTransform() (keep cornerpoint0): "; transform = mitk::AffineTransform3D::New(); mitk::AffineTransform3D::MatrixType::InternalMatrixType vnlmatrix; vnlmatrix = planegeometry->GetIndexToWorldTransform()->GetMatrix().GetVnlMatrix(); mitk::VnlVector axis(3); mitk::FillVector3D(axis, 1.0, 1.0, 1.0); axis.normalize(); vnl_quaternion rotation(axis, 0.223); vnlmatrix = rotation.rotation_matrix_transpose()*vnlmatrix; mitk::Matrix3D matrix; matrix = vnlmatrix; transform->SetMatrix(matrix); transform->SetOffset(cornerpoint0.GetVectorFromOrigin()); right.Set_vnl_vector( rotation.rotation_matrix_transpose()*right.Get_vnl_vector() ); bottom.Set_vnl_vector(rotation.rotation_matrix_transpose()*bottom.Get_vnl_vector()); normal.Set_vnl_vector(rotation.rotation_matrix_transpose()*normal.Get_vnl_vector()); geometry->SetIndexToWorldTransform(transform); std::cout<<"[PASSED]"<GetCornerPoint(0); result = testGeometry(geometry, width, height, numSlices, widthInMM, heightInMM, thicknessInMM, cornerpoint0, right, bottom, normal); if(result!=EXIT_SUCCESS) return result; //Testing Execute RestorePlanePositionOperation result = testRestorePlanePostionOperation(); if(result!=EXIT_SUCCESS) return result; std::cout<<"[TEST DONE]"< #include #include #include #include #include "pic2vtk.h" mitk::ExtractDirectedPlaneImageFilter::ExtractDirectedPlaneImageFilter() : m_WorldGeometry(NULL) { m_Reslicer = vtkImageReslice::New(); m_TargetTimestep = 0; m_InPlaneResampleExtentByGeometry = false; } mitk::ExtractDirectedPlaneImageFilter::~ExtractDirectedPlaneImageFilter() { m_WorldGeometry = NULL; m_Reslicer->Delete(); } void mitk::ExtractDirectedPlaneImageFilter::GenerateData() { // A world geometry must be set... if ( m_WorldGeometry == NULL ) { itkWarningMacro(<<"No world geometry has been set. Returning."); return; } Image *input = const_cast< ImageToImageFilter::InputImageType* >( this->GetInput() ); input->Update(); if ( input == NULL ) { itkWarningMacro(<<"No input set."); return; } const TimeSlicedGeometry *inputTimeGeometry = input->GetTimeSlicedGeometry(); if ( ( inputTimeGeometry == NULL ) || ( inputTimeGeometry->GetTimeSteps() == 0 ) ) { itkWarningMacro(<<"Error reading input image geometry."); return; } // Get the target timestep; if none is set, use the lowest given. unsigned int timestep = 0; if ( ! m_TargetTimestep ) { ScalarType time = m_WorldGeometry->GetTimeBounds()[0]; if ( time > ScalarTypeNumericTraits::NonpositiveMin() ) { timestep = inputTimeGeometry->MSToTimeStep( time ); } } else timestep = m_TargetTimestep; if ( inputTimeGeometry->IsValidTime( timestep ) == false ) { itkWarningMacro(<<"This is not a valid timestep: "<IsVolumeSet( timestep ) ) { itkWarningMacro(<<"No volume data existent at given timestep "<GetLargestPossibleRegion(); requestedRegion.SetIndex( 3, timestep ); requestedRegion.SetSize( 3, 1 ); requestedRegion.SetSize( 4, 1 ); input->SetRequestedRegion( &requestedRegion ); input->Update(); vtkImageData* inputData = input->GetVtkImageData( timestep ); if ( inputData == NULL ) { itkWarningMacro(<<"Could not extract vtk image data for given timestep"<GetSpacing( spacing ); // how big the area is in physical coordinates: widthInMM x heightInMM pixels mitk::ScalarType widthInMM, heightInMM; // where we want to sample Point3D origin; Vector3D right, bottom, normal; Vector3D rightInIndex, bottomInIndex; assert( input->GetTimeSlicedGeometry() == inputTimeGeometry ); // take transform of input image into account Geometry3D* inputGeometry = inputTimeGeometry->GetGeometry3D( timestep ); if ( inputGeometry == NULL ) { itkWarningMacro(<<"There is no Geometry3D at given timestep "<( m_WorldGeometry ) != NULL ) { const PlaneGeometry *planeGeometry = static_cast< const PlaneGeometry * >( m_WorldGeometry ); origin = planeGeometry->GetOrigin(); right = planeGeometry->GetAxisVector( 0 ); bottom = planeGeometry->GetAxisVector( 1 ); normal = planeGeometry->GetNormal(); if ( m_InPlaneResampleExtentByGeometry ) { // Resampling grid corresponds to the current world geometry. This // means that the spacing of the output 2D image depends on the // currently selected world geometry, and *not* on the image itself. extent[0] = m_WorldGeometry->GetExtent( 0 ); extent[1] = m_WorldGeometry->GetExtent( 1 ); } else { // Resampling grid corresponds to the input geometry. This means that // the spacing of the output 2D image is directly derived from the // associated input image, regardless of the currently selected world // geometry. inputGeometry->WorldToIndex( right, rightInIndex ); inputGeometry->WorldToIndex( bottom, bottomInIndex ); extent[0] = rightInIndex.GetNorm(); extent[1] = bottomInIndex.GetNorm(); } // Get the extent of the current world geometry and calculate resampling // spacing therefrom. widthInMM = m_WorldGeometry->GetExtentInMM( 0 ); heightInMM = m_WorldGeometry->GetExtentInMM( 1 ); mmPerPixel[0] = widthInMM / extent[0]; mmPerPixel[1] = heightInMM / extent[1]; right.Normalize(); bottom.Normalize(); normal.Normalize(); //origin += right * ( mmPerPixel[0] * 0.5 ); //origin += bottom * ( mmPerPixel[1] * 0.5 ); //widthInMM -= mmPerPixel[0]; //heightInMM -= mmPerPixel[1]; // Use inverse transform of the input geometry for reslicing the 3D image m_Reslicer->SetResliceTransform( inputGeometry->GetVtkTransform()->GetLinearInverse() ); // Set background level to TRANSLUCENT (see Geometry2DDataVtkMapper3D) m_Reslicer->SetBackgroundLevel( -32768 ); // Check if a reference geometry does exist (as would usually be the case for // PlaneGeometry). // Note: this is currently not strictly required, but could facilitate // correct plane clipping. if ( m_WorldGeometry->GetReferenceGeometry() ) { // Calculate the actual bounds of the transformed plane clipped by the // dataset bounding box; this is required for drawing the texture at the // correct position during 3D mapping. boundsInitialized = this->CalculateClippedPlaneBounds( m_WorldGeometry->GetReferenceGeometry(), planeGeometry, bounds ); } } // Do we have an AbstractTransformGeometry? else if ( dynamic_cast< const AbstractTransformGeometry * >( m_WorldGeometry ) ) { const mitk::AbstractTransformGeometry* abstractGeometry = dynamic_cast< const AbstractTransformGeometry * >(m_WorldGeometry); extent[0] = abstractGeometry->GetParametricExtent(0); extent[1] = abstractGeometry->GetParametricExtent(1); widthInMM = abstractGeometry->GetParametricExtentInMM(0); heightInMM = abstractGeometry->GetParametricExtentInMM(1); mmPerPixel[0] = widthInMM / extent[0]; mmPerPixel[1] = heightInMM / extent[1]; origin = abstractGeometry->GetPlane()->GetOrigin(); right = abstractGeometry->GetPlane()->GetAxisVector(0); right.Normalize(); bottom = abstractGeometry->GetPlane()->GetAxisVector(1); bottom.Normalize(); normal = abstractGeometry->GetPlane()->GetNormal(); normal.Normalize(); // Use a combination of the InputGeometry *and* the possible non-rigid // AbstractTransformGeometry for reslicing the 3D Image vtkGeneralTransform *composedResliceTransform = vtkGeneralTransform::New(); composedResliceTransform->Identity(); composedResliceTransform->Concatenate( inputGeometry->GetVtkTransform()->GetLinearInverse() ); composedResliceTransform->Concatenate( abstractGeometry->GetVtkAbstractTransform() ); m_Reslicer->SetResliceTransform( composedResliceTransform ); // Set background level to BLACK instead of translucent, to avoid // boundary artifacts (see Geometry2DDataVtkMapper3D) m_Reslicer->SetBackgroundLevel( -1023 ); composedResliceTransform->Delete(); } else { itkWarningMacro(<<"World Geometry has to be a PlaneGeometry or an AbstractTransformGeometry."); return; } // Make sure that the image to be resliced has a certain minimum size. if ( (extent[0] <= 2) && (extent[1] <= 2) ) { itkWarningMacro(<<"Image is too small to be resliced..."); return; } vtkImageChangeInformation * unitSpacingImageFilter = vtkImageChangeInformation::New() ; unitSpacingImageFilter->SetOutputSpacing( 1.0, 1.0, 1.0 ); unitSpacingImageFilter->SetInput( inputData ); m_Reslicer->SetInput( unitSpacingImageFilter->GetOutput() ); unitSpacingImageFilter->Delete(); //m_Reslicer->SetInput( inputData ); m_Reslicer->SetOutputDimensionality( 2 ); m_Reslicer->SetOutputOrigin( 0.0, 0.0, 0.0 ); Vector2D pixelsPerMM; pixelsPerMM[0] = 1.0 / mmPerPixel[0]; pixelsPerMM[1] = 1.0 / mmPerPixel[1]; //calulate the originArray and the orientations for the reslice-filter double originArray[3]; itk2vtk( origin, originArray ); m_Reslicer->SetResliceAxesOrigin( originArray ); double cosines[9]; // direction of the X-axis of the sampled result vnl2vtk( right.Get_vnl_vector(), cosines ); // direction of the Y-axis of the sampled result vnl2vtk( bottom.Get_vnl_vector(), cosines + 3 ); // normal of the plane vnl2vtk( normal.Get_vnl_vector(), cosines + 6 ); m_Reslicer->SetResliceAxesDirectionCosines( cosines ); - // Determine output extent for reslicing - ScalarType size[2]; - size[0] = (bounds[1] - bounds[0]) / mmPerPixel[0]; - size[1] = (bounds[3] - bounds[2]) / mmPerPixel[1]; - int xMin, xMax, yMin, yMax; if ( boundsInitialized ) { xMin = static_cast< int >( bounds[0] / mmPerPixel[0] );//+ 0.5 ); xMax = static_cast< int >( bounds[1] / mmPerPixel[0] );//+ 0.5 ); yMin = static_cast< int >( bounds[2] / mmPerPixel[1] );//+ 0.5); yMax = static_cast< int >( bounds[3] / mmPerPixel[1] );//+ 0.5 ); } else { // If no reference geometry is available, we also don't know about the // maximum plane size; so the overlap is just ignored xMin = yMin = 0; xMax = static_cast< int >( extent[0] - pixelsPerMM[0] );//+ 0.5 ); yMax = static_cast< int >( extent[1] - pixelsPerMM[1] );//+ 0.5 ); } m_Reslicer->SetOutputSpacing( mmPerPixel[0], mmPerPixel[1], 1.0 ); // xMax and yMax are meant exclusive until now, whereas // SetOutputExtent wants an inclusive bound. Thus, we need // to subtract 1. m_Reslicer->SetOutputExtent( xMin, xMax-1, yMin, yMax-1, 0, 1 ); // Do the reslicing. Modified() is called to make sure that the reslicer is // executed even though the input geometry information did not change; this // is necessary when the input /em data, but not the /em geometry changes. m_Reslicer->Modified(); m_Reslicer->ReleaseDataFlagOn(); m_Reslicer->Update(); // 1. Check the result vtkImageData* reslicedImage = m_Reslicer->GetOutput(); //mitkIpPicDescriptor *pic = Pic2vtk::convert( reslicedImage ); if((reslicedImage == NULL) || (reslicedImage->GetDataDimension() < 1)) { itkWarningMacro(<<"Reslicer returned empty image"); return; } unsigned int dimensions[2]; dimensions[0] = (unsigned int)extent[0]; dimensions[1] = (unsigned int)extent[1]; Vector3D spacingVector; FillVector3D(spacingVector, mmPerPixel[0], mmPerPixel[1], 1.0); mitk::Image::Pointer resultImage = this->GetOutput(); resultImage->Initialize(input->GetPixelType(), 2, dimensions ); //resultImage->Initialize( pic ); resultImage->SetSpacing( spacingVector ); //resultImage->SetPicVolume( pic ); //mitkIpPicFree(pic); /*unsigned int dimensions[2]; dimensions[0] = (unsigned int)extent[0]; dimensions[1] = (unsigned int)extent[1]; Vector3D spacingVector; FillVector3D(spacingVector, mmPerPixel[0], mmPerPixel[1], 1.0); mitk::Image::Pointer resultImage = this->GetOutput(); resultImage->Initialize(m_Reslicer->GetOutput()); resultImage->Initialize(inputImage->GetPixelType(), 2, dimensions); resultImage->SetSpacing(spacingVector); resultImage->SetSlice(m_Reslicer->GetOutput());*/ } void mitk::ExtractDirectedPlaneImageFilter::GenerateOutputInformation() { Superclass::GenerateOutputInformation(); } bool mitk::ExtractDirectedPlaneImageFilter ::CalculateClippedPlaneBounds( const Geometry3D *boundingGeometry, const PlaneGeometry *planeGeometry, vtkFloatingPointType *bounds ) { // Clip the plane with the bounding geometry. To do so, the corner points // of the bounding box are transformed by the inverse transformation // matrix, and the transformed bounding box edges derived therefrom are // clipped with the plane z=0. The resulting min/max values are taken as // bounds for the image reslicer. const BoundingBox *boundingBox = boundingGeometry->GetBoundingBox(); BoundingBox::PointType bbMin = boundingBox->GetMinimum(); BoundingBox::PointType bbMax = boundingBox->GetMaximum(); - BoundingBox::PointType bbCenter = boundingBox->GetCenter(); vtkPoints *points = vtkPoints::New(); if(boundingGeometry->GetImageGeometry()) { points->InsertPoint( 0, bbMin[0]-0.5, bbMin[1]-0.5, bbMin[2]-0.5 ); points->InsertPoint( 1, bbMin[0]-0.5, bbMin[1]-0.5, bbMax[2]-0.5 ); points->InsertPoint( 2, bbMin[0]-0.5, bbMax[1]-0.5, bbMax[2]-0.5 ); points->InsertPoint( 3, bbMin[0]-0.5, bbMax[1]-0.5, bbMin[2]-0.5 ); points->InsertPoint( 4, bbMax[0]-0.5, bbMin[1]-0.5, bbMin[2]-0.5 ); points->InsertPoint( 5, bbMax[0]-0.5, bbMin[1]-0.5, bbMax[2]-0.5 ); points->InsertPoint( 6, bbMax[0]-0.5, bbMax[1]-0.5, bbMax[2]-0.5 ); points->InsertPoint( 7, bbMax[0]-0.5, bbMax[1]-0.5, bbMin[2]-0.5 ); } else { points->InsertPoint( 0, bbMin[0], bbMin[1], bbMin[2] ); points->InsertPoint( 1, bbMin[0], bbMin[1], bbMax[2] ); points->InsertPoint( 2, bbMin[0], bbMax[1], bbMax[2] ); points->InsertPoint( 3, bbMin[0], bbMax[1], bbMin[2] ); points->InsertPoint( 4, bbMax[0], bbMin[1], bbMin[2] ); points->InsertPoint( 5, bbMax[0], bbMin[1], bbMax[2] ); points->InsertPoint( 6, bbMax[0], bbMax[1], bbMax[2] ); points->InsertPoint( 7, bbMax[0], bbMax[1], bbMin[2] ); } vtkPoints *newPoints = vtkPoints::New(); vtkTransform *transform = vtkTransform::New(); transform->Identity(); transform->Concatenate( planeGeometry->GetVtkTransform()->GetLinearInverse() ); transform->Concatenate( boundingGeometry->GetVtkTransform() ); transform->TransformPoints( points, newPoints ); transform->Delete(); bounds[0] = bounds[2] = 10000000.0; bounds[1] = bounds[3] = -10000000.0; bounds[4] = bounds[5] = 0.0; this->LineIntersectZero( newPoints, 0, 1, bounds ); this->LineIntersectZero( newPoints, 1, 2, bounds ); this->LineIntersectZero( newPoints, 2, 3, bounds ); this->LineIntersectZero( newPoints, 3, 0, bounds ); this->LineIntersectZero( newPoints, 0, 4, bounds ); this->LineIntersectZero( newPoints, 1, 5, bounds ); this->LineIntersectZero( newPoints, 2, 6, bounds ); this->LineIntersectZero( newPoints, 3, 7, bounds ); this->LineIntersectZero( newPoints, 4, 5, bounds ); this->LineIntersectZero( newPoints, 5, 6, bounds ); this->LineIntersectZero( newPoints, 6, 7, bounds ); this->LineIntersectZero( newPoints, 7, 4, bounds ); // clean up vtk data points->Delete(); newPoints->Delete(); if ( (bounds[0] > 9999999.0) || (bounds[2] > 9999999.0) || (bounds[1] < -9999999.0) || (bounds[3] < -9999999.0) ) { return false; } else { // The resulting bounds must be adjusted by the plane spacing, since we // we have so far dealt with index coordinates const float *planeSpacing = planeGeometry->GetFloatSpacing(); bounds[0] *= planeSpacing[0]; bounds[1] *= planeSpacing[0]; bounds[2] *= planeSpacing[1]; bounds[3] *= planeSpacing[1]; bounds[4] *= planeSpacing[2]; bounds[5] *= planeSpacing[2]; return true; } } bool mitk::ExtractDirectedPlaneImageFilter ::LineIntersectZero( vtkPoints *points, int p1, int p2, vtkFloatingPointType *bounds ) { vtkFloatingPointType point1[3]; vtkFloatingPointType point2[3]; points->GetPoint( p1, point1 ); points->GetPoint( p2, point2 ); if ( (point1[2] * point2[2] <= 0.0) && (point1[2] != point2[2]) ) { double x, y; x = ( point1[0] * point2[2] - point1[2] * point2[0] ) / ( point2[2] - point1[2] ); y = ( point1[1] * point2[2] - point1[2] * point2[1] ) / ( point2[2] - point1[2] ); if ( x < bounds[0] ) { bounds[0] = x; } if ( x > bounds[1] ) { bounds[1] = x; } if ( y < bounds[2] ) { bounds[2] = y; } if ( y > bounds[3] ) { bounds[3] = y; } bounds[4] = bounds[5] = 0.0; return true; } return false; } diff --git a/Modules/IpPicSupport/CMakeLists.txt b/Modules/IpPicSupport/CMakeLists.txt index e5c6bd2447..88806513de 100644 --- a/Modules/IpPicSupport/CMakeLists.txt +++ b/Modules/IpPicSupport/CMakeLists.txt @@ -1,5 +1,7 @@ +mitkFunctionCheckCompilerFlags("-Wno-deprecated-declarations" CMAKE_CXX_FLAGS) + MITK_CREATE_MODULE( IpPicSupport DEPENDS Mitk LegacyAdaptors mitkIpPic ) ADD_SUBDIRECTORY(Testing) diff --git a/Modules/IpPicSupport/mitkIpPicGet.c b/Modules/IpPicSupport/mitkIpPicGet.c index 42528bd937..72031b26e6 100755 --- a/Modules/IpPicSupport/mitkIpPicGet.c +++ b/Modules/IpPicSupport/mitkIpPicGet.c @@ -1,645 +1,646 @@ /***************************************************************************** Copyright (c) 1993-2000, Div. Medical and Biological Informatics, Deutsches Krebsforschungszentrum, Heidelberg, Germany All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - All advertising materials mentioning features or use of this software must display the following acknowledgement: "This product includes software developed by the Div. Medical and Biological Informatics, Deutsches Krebsforschungszentrum, Heidelberg, Germany." - Neither the name of the Deutsches Krebsforschungszentrum nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE DIVISION MEDICAL AND BIOLOGICAL INFORMATICS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE DIVISION MEDICAL AND BIOLOGICAL INFORMATICS, THE DEUTSCHES KREBSFORSCHUNGSZENTRUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Send comments and/or bug reports to: mbi-software@dkfz-heidelberg.de *****************************************************************************/ /* * $RCSfile$ *-------------------------------------------------------------------- * DESCRIPTION * reads a PicFile from disk * * $Log$ * Revision 1.11 2006/09/18 13:55:50 nolden * FIX: removed define USE_ITKZLIB, crashes on windows * * Revision 1.10 2006/09/18 12:57:40 nolden * CHG: added USE_ITKZLIB define * * Revision 1.9 2006/09/15 17:29:57 nolden * CHG: simplified ipPic include for non-plugin builds * * Revision 1.8 2006/01/10 16:53:09 hasselberg * FIX: ANSI C conformance (required for MSVC7.0) * * Revision 1.7 2005/12/21 08:28:42 max * FIX: renamed ipSize_t to size_t, since ipSize_t is only available in the 64Bit branch op ipPic. * * Revision 1.6 2005/12/20 12:56:35 max * ENH: Added possibility to read beyond 2GB limit. * * Revision 1.5 2005/10/19 11:19:43 ivo * ENH: Chili ipPic compatibility * * Revision 1.4 2005/10/13 11:21:12 ivo * FIX: linker warning (unused var) * * Revision 1.3 2005/10/13 08:35:47 ivo * FIX: warnings * * Revision 1.2 2005/10/13 07:52:55 max * fixed warnings Algorithms/mitkImageFilters/mitkImageToSurfaceFilter.h Algorithms/mitkImageFilters/mitkManualSegmentationToSurfaceFilter.h Algorithms/mitkImageIO/mitkIpPicGet.c * * Revision 1.1 2005/10/12 19:08:51 ivo * ADD: substitute for mitkIpPicGet: original always deletes data pointer and re-allocs it using malloc, which is not compatible with mitk::ImageDataItem. * * Revision 1.16 2004/01/16 22:11:59 andre * big endian bug fix * * Revision 1.15 2002/11/13 17:53:00 ivo * new ipPic added. * * Revision 1.13 2002/02/27 09:02:56 andre * zlib changes * * Revision 1.12 2002/02/27 08:54:43 andre * zlib changes * * Revision 1.11 2000/05/04 12:52:37 ivo * inserted BSD style license * * Revision 1.10 2000/02/16 14:29:20 andre * *** empty log message *** * * Revision 1.9 1999/11/28 18:22:42 andre * *** empty log message *** * * Revision 1.8 1999/11/28 16:29:43 andre * *** empty log message *** * * Revision 1.7 1999/11/27 20:03:48 andre * *** empty log message *** * * Revision 1.6 1999/11/27 19:29:43 andre * *** empty log message *** * * Revision 1.5 1998/09/04 17:45:54 andre * *** empty log message *** * * Revision 1.4 1998/05/06 14:13:15 andre * added info->pixel_start_in_file * * Revision 1.3 1997/10/20 13:35:39 andre * *** empty log message *** * * Revision 1.2 1997/09/15 13:21:13 andre * switched to new what string format * * Revision 1.1.1.1 1997/09/06 19:09:59 andre * initial import * * Revision 0.1 1993/04/02 16:18:39 andre * now works on PC, SUN and DECstation * * Revision 0.0 1993/03/26 12:56:26 andre * Initial revision, NO error checking * * *-------------------------------------------------------------------- * COPYRIGHT (c) 1993 by DKFZ (Dept. MBI) Heidelberg, FRG */ #ifdef CHILIPLUGIN #include mitkIpPicDescriptor * MITKipPicGetTags( char *infile_name, mitkIpPicDescriptor *pic ) { return mitkIpPicGetTags(infile_name, pic); } _mitkIpPicTagsElement_t * _MITKipPicReadTags( _mitkIpPicTagsElement_t *head, mitkIpUInt4_t bytes_to_read, FILE *stream, char encryption_type ) { return _mitkIpPicReadTags(head, bytes_to_read, stream, encryption_type); } //mitkIpPicDescriptor * _MITKipPicOldGet( FILE *infile, mitkIpPicDescriptor *pic ) //{ // return _mitkIpPicOldGet(infile, pic); //} mitkIpPicDescriptor * MITKipPicGet( char *infile_name, mitkIpPicDescriptor *pic ) { if(pic != NULL) { mitkIpPicDescriptor * tmpPic; size_t sizePic, sizeTmpPic; tmpPic = mitkIpPicGet(infile_name, NULL); sizePic = _mitkIpPicSize(pic); sizeTmpPic = _mitkIpPicSize(tmpPic); if(sizePic != sizeTmpPic) { fprintf( stderr, "Critical: MITKipPicGet was given a pic with wrong size\n" ); return tmpPic; } memcpy(pic->data, tmpPic->data, sizePic); pic->info->tags_head = tmpPic->info->tags_head; tmpPic->info->tags_head = NULL; mitkIpPicFree(tmpPic); return pic; } else return mitkIpPicGet(infile_name, pic); } #else #include "mitkIpPic.h" #ifdef DOS #include "mitkIpPicOP.h" #else #include "mitkIpPicOldP.h" #endif char * MITKstrdup (const char * string) { char *memory; if (string==NULL) return NULL; if ( ( memory = (char*)malloc(strlen(string) + 1) ) ) return strcpy(memory,string); return NULL; } _mitkIpPicTagsElement_t * _MITKipPicReadTags( _mitkIpPicTagsElement_t *head, mitkIpUInt4_t bytes_to_read, FILE *stream, char encryption_type ); mitkIpPicDescriptor * _MITKipPicOldGet( FILE *infile, mitkIpPicDescriptor *pic ) { _mitkIpPicOldHeader old_pic; size_t elements; size_t size = 0; size_t number_of_elements; size_t bytes_per_element; size_t number_of_bytes; size_t block_size; size_t number_of_blocks; size_t remaining_bytes; size_t bytes_read; size_t block_nr; size_t ignored; mitkIpUInt1_t* data; if( pic == NULL ) pic = mitkIpPicNew(); else { size= _mitkIpPicSize(pic); if(pic->data == NULL) size = 0; } /* read infile */ ignored = mitkIpFReadLE( &(old_pic.dummy1), sizeof(mitkIpUInt4_t), 4, infile ); if( old_pic.conv <= 0 || old_pic.conv > 6 ) { old_pic.conv = 3; old_pic.rank = 2; } ignored = mitkIpFReadLE( &(old_pic.n1), sizeof(mitkIpUInt4_t), old_pic.rank, infile ); if( old_pic.rank == 3 && old_pic.n3 == 1 ) old_pic.rank = 2; ignored = mitkIpFReadLE( &(old_pic.type), sizeof(mitkIpUInt4_t), 3, infile ); if( old_pic.ntxt ) { fseek( infile, old_pic.ltxt, SEEK_CUR ); } elements = old_pic.n1 * old_pic.n2; if( old_pic.rank == 3 ) elements *= old_pic.n3; if((size == 0) || (size != _mitkIpPicSize(pic))) { if( pic->data != NULL ) { free( pic->data ); pic->data = NULL; } pic->data = malloc( _mitkIpPicSize(pic) ); } /* * data is read in blocks of size 'block_size' to prevent from * errors due to large file sizes (>=2GB) */ number_of_elements = elements; bytes_per_element = old_pic.type; number_of_bytes = number_of_elements * bytes_per_element; block_size = 1024*1024; /* Use 1 MB blocks. Make sure that block size is smaller than 2^31 */ number_of_blocks = number_of_bytes / block_size; remaining_bytes = number_of_bytes % block_size; bytes_read = 0; block_nr = 0; data = (mitkIpUInt1_t*) pic->data; for ( block_nr = 0 ; block_nr < number_of_blocks ; ++block_nr ) bytes_read += mitkIpPicFReadLE( data + ( block_nr * block_size ), 1, (unsigned int) block_size, infile ); bytes_read += mitkIpPicFReadLE( data + ( number_of_blocks * block_size ), 1, (unsigned int) remaining_bytes, infile ); if ( bytes_read != number_of_bytes ) fprintf( stderr, "Error while reading (ferror indicates %u), only %lu bytes were read! Eof indicator is %u.\n", ferror(infile), (long unsigned int)bytes_read, feof(infile) ); /* convert to the new pic3 format */ if( old_pic.type == 1 ) pic->type = mitkIpPicUInt; else pic->type = (mitkIpPicType_t)old_pic.conv; pic->bpe = old_pic.type*8; pic->dim = old_pic.rank; pic->n[0] = old_pic.n1; pic->n[1] = old_pic.n2; pic->n[2] = old_pic.n3; pic->n[3] = old_pic.n4; pic->n[4] = old_pic.n5; pic->n[5] = old_pic.n6; pic->n[6] = old_pic.n7; pic->n[7] = old_pic.n8; return( pic ); } mitkIpUInt4_t _MITKipPicTSVElements( mitkIpPicTSV_t *tsv ) { mitkIpUInt4_t i; mitkIpUInt4_t elements; if( tsv->dim == 0 ) return( 0 ); elements = tsv->n[0]; for( i = 1; i < tsv->dim; i++ ) elements *= tsv->n[i]; return( elements ); } _mitkIpPicTagsElement_t * _MITKipPicReadTags( _mitkIpPicTagsElement_t *head, mitkIpUInt4_t bytes_to_read, FILE *stream, char encryption_type ) { while( bytes_to_read > 0 ) { mitkIpPicTSV_t *tsv; mitkIpPicTag_t tag_name; mitkIpUInt4_t len; size_t ignored; /*printf( "bytes_to_read: %i\n", bytes_to_read ); */ tsv = malloc( sizeof(mitkIpPicTSV_t) ); ignored = mitkIpPicFRead( &tag_name, 1, sizeof(mitkIpPicTag_t), stream ); strncpy( tsv->tag, tag_name, _mitkIpPicTAGLEN ); tsv->tag[_mitkIpPicTAGLEN] = '\0'; ignored = mitkIpPicFReadLE( &len, sizeof(mitkIpUInt4_t), 1, stream ); ignored = mitkIpPicFReadLE( &(tsv->type), sizeof(mitkIpUInt4_t), 1, stream ); ignored = mitkIpPicFReadLE( &(tsv->bpe), sizeof(mitkIpUInt4_t), 1, stream ); ignored = mitkIpPicFReadLE( &(tsv->dim), sizeof(mitkIpUInt4_t), 1, stream ); ignored = mitkIpPicFReadLE( &(tsv->n), sizeof(mitkIpUInt4_t), tsv->dim, stream ); if( tsv->type == mitkIpPicTSV ) { tsv->value = NULL; tsv->value = _mitkIpPicReadTags( tsv->value, len - 3 * sizeof(mitkIpUInt4_t) - tsv->dim * sizeof(mitkIpUInt4_t), stream, encryption_type ); } else { mitkIpUInt4_t elements; elements = _MITKipPicTSVElements( tsv ); if( tsv->type == mitkIpPicASCII || tsv->type == mitkIpPicNonUniform ) tsv->bpe = 8; assert( elements * tsv->bpe / 8 == len - 3 * sizeof(mitkIpUInt4_t) - tsv->dim * sizeof(mitkIpUInt4_t) ); if( tsv->type == mitkIpPicASCII ) tsv->value = malloc( elements+1 * tsv->bpe / 8 ); else tsv->value = malloc( elements * tsv->bpe / 8 ); ignored = mitkIpPicFReadLE( tsv->value, tsv->bpe / 8, elements, stream ); if( tsv->type == mitkIpPicASCII ) ((char *)(tsv->value))[elements] = '\0'; if( encryption_type == 'e' && ( tsv->type == mitkIpPicASCII || tsv->type == mitkIpPicNonUniform ) ) { if( tsv->type == mitkIpPicNonUniform ) { sprintf( tsv->tag, "*** ENCRYPTED ***" ); tsv->tag[_mitkIpPicTAGLEN] = '\0'; } free( tsv->value ); tsv->value = MITKstrdup( "*** ENCRYPTED ***" ); tsv->n[0] = (mitkIpUInt4_t)strlen(tsv->value); tsv->type = mitkIpPicASCII; tsv->dim = 1; } } head = _mitkIpPicInsertTag( head, tsv ); bytes_to_read -= 32 /* name */ + sizeof(mitkIpUInt4_t) /* len */ + len; /* type + bpe + dim + n[] + data */ } return( head ); } mitkIpPicDescriptor * MITKipPicGetTags( char *infile_name, mitkIpPicDescriptor *pic ) { mitkIpPicFile_t infile; mitkIpPicTag_t tag_name; mitkIpUInt4_t dummy; mitkIpUInt4_t len; mitkIpUInt4_t dim; mitkIpUInt4_t n[_mitkIpPicNDIM]; mitkIpUInt4_t to_read; size_t ignored; infile = _mitkIpPicOpenPicFileIn( infile_name ); if( infile == NULL ) { /*ipPrintErr( "mitkIpPicGetTags: sorry, error opening infile\n" );*/ return( NULL ); } if( pic != NULL ) pic->info->write_protect = mitkIpFalse; /* read infile */ ignored = mitkIpPicFRead( &(tag_name[0]), 1, 4, infile ); if( strncmp( mitkIpPicVERSION, tag_name, 4 ) != 0 ) { if( infile != stdin ) mitkIpPicFClose( infile ); return( pic ); } if( pic == NULL ) pic = mitkIpPicNew(); ignored = mitkIpPicFRead( &(tag_name[4]), 1, sizeof(mitkIpPicTag_t)-4, infile ); /*strncpy( pic->info->version, tag_name, _mitkIpPicTAGLEN );*/ ignored = mitkIpPicFReadLE( &len, sizeof(mitkIpUInt4_t), 1, infile ); ignored = mitkIpPicFReadLE( &dummy, sizeof(mitkIpUInt4_t), 1, infile ); ignored = mitkIpPicFReadLE( &dummy, sizeof(mitkIpUInt4_t), 1, infile ); ignored = mitkIpPicFReadLE( &dim, sizeof(mitkIpUInt4_t), 1, infile ); ignored = mitkIpPicFReadLE( n, sizeof(mitkIpUInt4_t), dim, infile ); to_read = len - 3 * sizeof(mitkIpUInt4_t) - dim * sizeof(mitkIpUInt4_t); pic->info->tags_head = _MITKipPicReadTags( pic->info->tags_head, to_read, infile, mitkIpPicEncryptionType(pic) ); pic->info->pixel_start_in_file = mitkIpPicFTell( infile ); if( infile != stdin ) mitkIpPicFClose( infile ); return( pic ); } mitkIpPicDescriptor * MITKipPicGet( char *infile_name, mitkIpPicDescriptor *pic ) { mitkIpPicFile_t infile; mitkIpPicTag_t tag_name; mitkIpUInt4_t len; mitkIpUInt4_t to_read; size_t size; size_t number_of_elements; size_t bytes_per_element; size_t number_of_bytes; size_t block_size; size_t number_of_blocks; size_t remaining_bytes; size_t bytes_read; size_t block_nr; mitkIpUInt1_t* data; size_t ignored; infile = _mitkIpPicOpenPicFileIn( infile_name ); if( !infile ) { /*ipPrintErr( "mitkIpPicGet: sorry, error opening infile\n" );*/ return( NULL ); } /* read infile */ ignored = mitkIpPicFRead( tag_name, 1, 4, infile ); if( strncmp( "\037\213", tag_name, 2 ) == 0 ) { fprintf( stderr, "mitkIpPicGetHeader: sorry, can't read compressed file\n" ); return( NULL ); } else if( strncmp( mitkIpPicVERSION, tag_name, 4 ) != 0 ) { #ifndef CHILIPLUGIN if( pic == NULL ) pic = _MITKipPicOldGet( infile, NULL ); else _MITKipPicOldGet( infile, pic ); if( infile != stdin ) mitkIpPicFClose( infile ); #else return NULL; #endif return( pic ); } size = 0; if( pic == NULL ) pic = mitkIpPicNew(); else { size= _mitkIpPicSize(pic); if(pic->data == NULL) size = 0; } if( pic->info != NULL ) { _mitkIpPicFreeTags( pic->info->tags_head ); pic->info->tags_head = NULL; } ignored = mitkIpPicFRead( &(tag_name[4]), 1, sizeof(mitkIpPicTag_t)-4, infile ); strncpy( pic->info->version, tag_name, _mitkIpPicTAGLEN ); ignored = mitkIpPicFReadLE( &len, sizeof(mitkIpUInt4_t), 1, infile ); ignored = mitkIpPicFReadLE( &(pic->type), sizeof(mitkIpUInt4_t), 1, infile ); ignored = mitkIpPicFReadLE( &(pic->bpe), sizeof(mitkIpUInt4_t), 1, infile ); ignored = mitkIpPicFReadLE( &(pic->dim), sizeof(mitkIpUInt4_t), 1, infile ); ignored = mitkIpPicFReadLE( &(pic->n), sizeof(mitkIpUInt4_t), pic->dim, infile ); + (void *)ignored; to_read = len - 3 * sizeof(mitkIpUInt4_t) - pic->dim * sizeof(mitkIpUInt4_t); #if 0 mitkIpPicFSeek( infile, to_read, SEEK_CUR ); #else pic->info->tags_head = _MITKipPicReadTags( pic->info->tags_head, to_read, infile, mitkIpPicEncryptionType(pic) ); #endif pic->info->write_protect = mitkIpFalse; if((size == 0) || (size != _mitkIpPicSize(pic))) { if( pic->data != NULL ) { free( pic->data ); pic->data = NULL; } #ifdef WIN if ((pic->hdata = GlobalAlloc( GMEM_MOVEABLE, _mitkIpPicSize(pic) )) != 0) pic->data = GlobalLock( pic->hdata ); #else pic->data = malloc( _mitkIpPicSize(pic) ); #endif } pic->info->pixel_start_in_file = mitkIpPicFTell( infile ); /* * data is read in blocks of size 'block_size' to prevent from * errors due to large file sizes (>=2GB) */ number_of_elements = _mitkIpPicElements(pic); bytes_per_element = pic->bpe / 8; number_of_bytes = number_of_elements * bytes_per_element; block_size = 1024*1024; /* Use 1 MB blocks. Make sure that block size is smaller than 2^31 */ number_of_blocks = number_of_bytes / block_size; remaining_bytes = number_of_bytes % block_size; bytes_read = 0; block_nr = 0; /*printf( "mitkIpPicGet: number of blocks to read is %ul.\n", number_of_blocks ); */ data = (mitkIpUInt1_t*) pic->data; if( pic->type == mitkIpPicNonUniform ) { for ( block_nr = 0 ; block_nr < number_of_blocks ; ++block_nr ) bytes_read += mitkIpPicFRead( data + ( block_nr * block_size ), 1, (unsigned int) block_size, infile ); bytes_read += mitkIpPicFRead( data + ( number_of_blocks * block_size ), 1, (unsigned int) remaining_bytes, infile ); } else { for ( block_nr = 0 ; block_nr < number_of_blocks ; ++block_nr ) bytes_read += mitkIpPicFReadLE( data + ( block_nr * block_size ), 1, (unsigned int) block_size, infile ); bytes_read += mitkIpPicFReadLE( data + ( number_of_blocks * block_size ), 1, (unsigned int) remaining_bytes, infile ); } if ( bytes_read != number_of_bytes ) { fprintf( stderr, "Error while reading, only %lu bytes were read! Eof indicator is %u.\n", (long unsigned int)bytes_read, mitkIpPicFEOF(infile) ); #ifndef USE_ZLIB fprintf( stderr, "(ferror indicates %u).\n", ferror(infile)); #endif } if( infile != stdin ) mitkIpPicFClose( infile ); #ifdef WIN GlobalUnlock( pic->hdata ); #endif return( pic ); } #endif // CHILIPLUGIN diff --git a/Modules/IpPicSupport/mitkPicVolumeTimeSeriesReader.cpp b/Modules/IpPicSupport/mitkPicVolumeTimeSeriesReader.cpp index 3d4f1a7c13..28b6cc5118 100644 --- a/Modules/IpPicSupport/mitkPicVolumeTimeSeriesReader.cpp +++ b/Modules/IpPicSupport/mitkPicVolumeTimeSeriesReader.cpp @@ -1,177 +1,177 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkPicVolumeTimeSeriesReader.h" #include "mitkPicFileReader.h" #include #include extern "C" { mitkIpPicDescriptor * MITKipPicGet( char *infile_name, mitkIpPicDescriptor *pic ); mitkIpPicDescriptor * MITKipPicGetTags( char *infile_name, mitkIpPicDescriptor *pic ); } void mitk::PicVolumeTimeSeriesReader::GenerateOutputInformation() { mitk::Image::Pointer output = this->GetOutput(); if ( ( output->IsInitialized() ) && ( this->GetMTime() <= m_ReadHeaderTime.GetMTime() ) ) return ; itkDebugMacro( << "Reading file for GenerateOutputInformation()" << m_FileName ); if ( ! this->GenerateFileList() ) { itkWarningMacro( "Sorry, file list could not be generated!" ); return ; } // // Read the first file of the image sequence. Assume equal size and spacings for all // other volumes. @TODO Integrate support for different sizes and spacings // char* filename = const_cast ( m_MatchedFileNames[ 0 ].c_str() ); mitkIpPicDescriptor * header = mitkIpPicGetHeader( filename, NULL ); header = MITKipPicGetTags( filename, header ); if ( header == NULL ) { itk::ImageFileReaderException e( __FILE__, __LINE__ ); itk::OStringStream msg; msg << " Could not read file " << m_FileName.c_str(); e.SetDescription( msg.str().c_str() ); throw e; return ; } if ( header->dim != 3 ) { itk::ImageFileReaderException e( __FILE__, __LINE__ , "Only 3D-pic volumes are supported! " ); throw e; return ; } // // modify the header to match the real temporal extent // header->dim = 4; header->n[ 3 ] = m_MatchedFileNames.size(); output->Initialize( CastToImageDescriptor( header) ); mitkIpPicFree( header ); m_ReadHeaderTime.Modified(); } void mitk::PicVolumeTimeSeriesReader::GenerateData() { mitk::Image::Pointer output = this->GetOutput(); // // Check to see if we can read the file given the name or prefix // if ( m_FilePrefix == "" || m_FilePattern == "" ) { throw itk::ImageFileReaderException( __FILE__, __LINE__, "Both FilePattern and FilePrefix must be non-empty" ); } if ( m_MatchedFileNames.size() == 0 ) { throw itk::ImageFileReaderException( __FILE__, __LINE__, "Sorry, there are no files to read!" ); } // // read 3d volumes and copy them to the 4d volume // mitkIpPicDescriptor* volume3d = NULL; for ( unsigned int t = 0 ; t < m_MatchedFileNames.size() ; ++t ) { char* filename = const_cast< char* >( m_MatchedFileNames[ t ].c_str() ); MITK_INFO << "Reading file " << filename << "..." << std::endl; volume3d = MITKipPicGet( filename, NULL ); if ( volume3d == NULL ) { ::itk::OStringStream message; message << "mitk::ERROR: " << this->GetNameOfClass() << "(" << this << "): " << "File (" << filename << ") of time frame " << t << " could not be read!"; throw itk::ImageFileReaderException( __FILE__, __LINE__, message.str().c_str() ); } // // @TODO do some error checking // // // copy the 3d data volume to the 4d volume // // \todo use memory of Image as in PicFileReader (or integrate everything into the PicFileReader!) PicFileReader::ConvertHandedness(volume3d); - bool result; + bool result = false; // FIXME //result = output->SetPicVolume( volume3d, t ); if(result==false) { ::itk::OStringStream message; message << "mitk::ERROR: " << this->GetNameOfClass() << "(" << this << "): " << "Volume of time frame " << t << " did not match size of other time frames."; throw itk::ImageFileReaderException( __FILE__, __LINE__, message.str().c_str() ); } mitkIpPicFree ( volume3d ); } } bool mitk::PicVolumeTimeSeriesReader::CanReadFile(const std::string /*filename*/, const std::string filePrefix, const std::string filePattern) { if( filePattern == "" && filePrefix == "" ) return false; bool extensionFound = false; std::string::size_type PICPos = filePattern.rfind(".pic"); if ((PICPos != std::string::npos) && (PICPos == filePattern.length() - 4)) { extensionFound = true; } PICPos = filePattern.rfind(".pic.gz"); if ((PICPos != std::string::npos) && (PICPos == filePattern.length() - 7)) { extensionFound = true; } if( !extensionFound ) return false; return true; } mitk::PicVolumeTimeSeriesReader::PicVolumeTimeSeriesReader() { //this->DebugOn(); } mitk::PicVolumeTimeSeriesReader::~PicVolumeTimeSeriesReader() {} diff --git a/Modules/LegacyAdaptors/CMakeLists.txt b/Modules/LegacyAdaptors/CMakeLists.txt index aa4a818edc..ee95f73176 100644 --- a/Modules/LegacyAdaptors/CMakeLists.txt +++ b/Modules/LegacyAdaptors/CMakeLists.txt @@ -1,3 +1,5 @@ +mitkFunctionCheckCompilerFlags("-Wno-deprecated-declarations" CMAKE_CXX_FLAGS) + MITK_CREATE_MODULE( LegacyAdaptors DEPENDS Mitk mitkIpPic ) diff --git a/Plugins/org.mitk.core.jobs/src/internal/mitkDataStorageAccessRule.cpp b/Plugins/org.mitk.core.jobs/src/internal/mitkDataStorageAccessRule.cpp index 15cc85a95c..d7160aa205 100644 --- a/Plugins/org.mitk.core.jobs/src/internal/mitkDataStorageAccessRule.cpp +++ b/Plugins/org.mitk.core.jobs/src/internal/mitkDataStorageAccessRule.cpp @@ -1,197 +1,197 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision: 18503 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkDataStorageAccessRule.h" #include mitk::DataStorageAccessRule ::DataStorageAccessRule (mitk::DataStorage::Pointer myDataStorage, mitk::DataNode::Pointer myDataNode, mitk::DataStorageAccessRule::RuleType myRule) :m_Rule(myRule), m_sptrMyDataStorage(myDataStorage), m_sptrMyDataNode(myDataNode) { mitk::DataStorage::SetOfObjects::ConstPointer sptr_parentsNodesFirstRule = m_sptrMyDataStorage->GetSources(m_sptrMyDataNode); // checks if the DataNode does exists within the specified DataTree, if not an // Poco NotFoundException is thrown since the rule is useless bool exsists = false ; for(mitk::DataStorage::SetOfObjects::const_iterator it = sptr_parentsNodesFirstRule->begin(); it != sptr_parentsNodesFirstRule->end(); ++ it) { if (*it == m_sptrMyDataNode ) exsists = true ; } if (exsists == false) throw Poco::NotFoundException() ; } bool mitk::DataStorageAccessRule - ::Contains(berry::ISchedulingRule::Pointer rule) + ::Contains(berry::ISchedulingRule::Pointer rule) const { DataStorageAccessRule::Pointer sptr_temp = rule.Cast(); // test if the ISchedulingRule is a DataStorageAccessRule if( sptr_temp == 0 ) return false ; // test if the DataStorageAccessRule object is exactly the instance else { if ( this == sptr_temp.GetPointer() ) return true ; return false ; } } bool mitk::DataStorageAccessRule - ::IsConflicting(berry::ISchedulingRule::Pointer sptr_otherISchedulingRule) + ::IsConflicting(berry::ISchedulingRule::Pointer sptr_otherISchedulingRule) const { // test if the stored dataNode // cast to check if the ISchedulingRule is a DataStorageAccessRule DataStorageAccessRule::Pointer sptr_DataStorageAccessRule = sptr_otherISchedulingRule.Cast(); // checks if the Rule of the type ISchedulingRule is a DataStorageAccessRule if(sptr_DataStorageAccessRule == 0) return false ; // the rule to be compared with is a DataStorageAccessRule else { // testing if both jobs holding each rule do operate on the same DataStorage if not false is returned if( !CompareDataStorages(sptr_DataStorageAccessRule->GetDataStorage()) ) return false ; // checks if to rules to be compared are two add rules if (m_Rule == ADD_RULE && m_Rule == sptr_DataStorageAccessRule->GetRuleType()) return CompareTwoAddorRemoveRules() ; // checks if to the two rules to be compared are two remove rules if(m_Rule == REMOVE_RULE && m_Rule == sptr_DataStorageAccessRule->GetRuleType()) return CompareTwoAddorRemoveRules() ; // an add and remove rule needs to be compared else { return CompareAddandRemoveRules(sptr_DataStorageAccessRule) ; } } } bool mitk::DataStorageAccessRule ::CompareAddandRemoveRules(mitk::DataStorageAccessRule::Pointer sptr_otherDataStorageAccessRule) const { mitk::DataStorage::SetOfObjects::ConstPointer sptr_parentsNodesFirstRule = m_sptrMyDataStorage->GetSources(m_sptrMyDataNode); // checks if the DataStorageNode of to be compared DataStorageAccessRule is a parent node // if so the job holding this DataStorageAccessRule need to wait until the operation on the parent node is performed for(mitk::DataStorage::SetOfObjects::const_iterator it = sptr_parentsNodesFirstRule->begin(); it != sptr_parentsNodesFirstRule->end(); ++ it) { if (*it == sptr_otherDataStorageAccessRule->GetDataNode()) return true ; } mitk::DataStorage::SetOfObjects::ConstPointer sptr_derivedNodesRule = m_sptrMyDataStorage->GetDerivations(m_sptrMyDataNode); // checks if the DataStorage node of to be compared DataStorageAccessRule is a child node // if so the job holding this DataStorageAccessRule needs to wait until the operation on the parent node is performed for(mitk::DataStorage::SetOfObjects::const_iterator it = sptr_derivedNodesRule->begin(); it != sptr_derivedNodesRule->end(); ++it) { if(*it == sptr_otherDataStorageAccessRule->GetDataNode()) return true ; } // jobs operating on nodes on different branches do not cause conflicts thus they can be performed in different // threads concurrently return false ; } bool mitk::DataStorageAccessRule ::CompareDataStorages(mitk::DataStorage::Pointer otherDataStorage) const { if(m_sptrMyDataStorage == otherDataStorage) return true ; else return false; } bool mitk::DataStorageAccessRule ::CompareTwoAddorRemoveRules() const { return false ; } bool mitk::DataStorageAccessRule ::TestDataNode(mitk::DataNode::Pointer /*dataTreeToBeStored*/) const { mitk::DataStorage::SetOfObjects::ConstPointer tempAllNodes = m_sptrMyDataStorage->GetAll(); for(mitk::DataStorage::SetOfObjects::const_iterator it = tempAllNodes->begin(); it !=tempAllNodes->end(); ++ it){ if (m_sptrMyDataNode == *it ) return true ; } return false ; } mitk::DataNode::Pointer mitk::DataStorageAccessRule ::GetDataNode() const { return mitk::DataStorageAccessRule::m_sptrMyDataNode ; } mitk::DataStorage::Pointer mitk::DataStorageAccessRule ::GetDataStorage() const { return mitk::DataStorageAccessRule::m_sptrMyDataStorage ; } mitk::DataStorageAccessRule::RuleType mitk::DataStorageAccessRule ::GetRuleType() const { if (m_Rule == ADD_RULE) return ( mitk::DataStorageAccessRule::ADD_RULE ) ; else { return ( mitk::DataStorageAccessRule::REMOVE_RULE ) ; } } diff --git a/Plugins/org.mitk.core.jobs/src/mitkDataStorageAccessRule.h b/Plugins/org.mitk.core.jobs/src/mitkDataStorageAccessRule.h index 124bf2ee61..a77a81d62f 100644 --- a/Plugins/org.mitk.core.jobs/src/mitkDataStorageAccessRule.h +++ b/Plugins/org.mitk.core.jobs/src/mitkDataStorageAccessRule.h @@ -1,159 +1,159 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef MITKDATASTORAGEACCESSRULE_H_HEADER_INCLUDED_ #define MITKDATASTORAGEACCESSRULE_H_HEADER_INCLUDED_ #include #include "berryISchedulingRule.h" #include "berryObject.h" #include "mitkDataNode.h" #include "mitkDataStorage.h" #include "mitkStandaloneDataStorage.h" namespace mitk { /** *@class DataStorageAccessRule * *@brief The DataStorageAccessRule inherits from the ISchedulingRule class. DataStorageAccessRule are used to restrict the adding and * removing of DataStorage nodes in multi-threaded scenarios. Only DataStorageNodes within different branches can be modified * concurrently. The idea and its restrictions is explained in the sections and diagrams below. * *

the IsScheduling(...) method :

* returns true or false depending if conflictions with another rule are found * *

* *

*

the rule behavior if jobs holing add rules of an DataTree node

* * two add rules are always allowed since there are no conflictions when adding nodes concurrently. The final order the nodes are finally added has * to be checked by the programmer of the particular job * * *

the rule behavior when two jobs holding remove rules of a DataNode

* * two jobs holding remove rules can be executed concurrently since all removing scenarios do not cause conflictions. If two jobs are * trying to remove the same DataTree node the job by itself needs to check if the node is still available before executing the removing * command * * *

the rule behavior of a jobs that is holding an add rule compared with a job that is holding a remove rule on a * DataNode

* * adding and removing of DataTree nodes concurrently can cause serious errors and needs to be restricted. Performing add and remove * operations on different DataStorage branches can be done concurrently since no conflictions are expected. * the performing of add and remove operation on the same DataNode, its parent nodes or child nodes of the same branch * by different jobs is not allowed. Jobs holding rules that are trying to perform such operations are blocked until the running job is done. * *

* *

*

the Contains method (...) method :

* only necessary for a specific type of scheduling rules. Has to be used if IScheduling rules are composed into hierarchies. * In such scenarios the contains(...) method specifies the hierarchical relationships among the locks. For example if a method tries to acquire a specific * rule to lock a specific directory it needs to check if no job is holding a rule for one or more subdirectories. For all cases in which no composing of * IScheduling rules is needed the Contains(...) method only needs to check if two jobs are holding exactly the same IScheduling rule on the same object. * Normally this can be achieved by just calling the IsConflicting(...) method. *

* *@author Jan Woerner */ class MITK_JOBS_EXPORT DataStorageAccessRule : public berry::ISchedulingRule { public: enum RuleType {ADD_RULE = 0, REMOVE_RULE} ; RuleType m_Rule; berryObjectMacro(DataStorageAccessRule) DataStorageAccessRule (mitk::DataStorage::Pointer myDataStorage, mitk::DataNode::Pointer myDataNode, DataStorageAccessRule::RuleType myRule) ; - bool Contains (berry::ISchedulingRule::Pointer otherISchedulingRule) ; - bool IsConflicting (berry::ISchedulingRule::Pointer otherISchedulingRule) ; + bool Contains (berry::ISchedulingRule::Pointer otherISchedulingRule) const; + bool IsConflicting (berry::ISchedulingRule::Pointer otherISchedulingRule) const; private: /** * Returns false, identifying no conflictions between two DataStorageAccessRules. * Two add and remove rules do work together. From importance is that jobs using this rule need to check if the * node operating on is still available or already deleted by another job. The DataStorageAccessRule only checks if conflictions could * occur if the removing or adding of nodes is performed currently. */ bool CompareTwoAddorRemoveRules() const ; /** * searches for conflictions of an add DataStorageAccessRule with a remove DataStorageAccess rule * if the add and remove rule do operate in different branches, no conflictions are expected and false is returned */ bool CompareAddandRemoveRules(mitk::DataStorageAccessRule::Pointer sptr_otherDataStorageAccessRule) const; /** * for internal use only, * checks if the jobs that are to be compared do hold DataStorageAccessRule on the same * DataStorage. Jobs that do operate on different DataStorage do not conflict and false is returned */ bool CompareDataStorages(mitk::DataStorage::Pointer otherDataStorage) const; /** * for internal use only * validates if the DataTree node of a particular DataStorageAccess rule belongs to the DataStorage specified within the particular rule. * if not the rule is invalid and false is returned. No conflictions can be expected */ bool TestDataNode(mitk::DataNode::Pointer dataTreeToBeStored) const; /** * returns a pointer to the specified DataStorage node */ mitk::DataNode::Pointer GetDataNode() const; /** * returns a pointer to the specified DataStorage */ mitk::DataStorage::Pointer GetDataStorage() const; mitk::DataStorageAccessRule::RuleType GetRuleType() const; DataStorage::Pointer m_sptrMyDataStorage ; DataNode::Pointer m_sptrMyDataNode ; }; } #endif /*MITKDATASTORAGEACCESSRULE_H_HEADER_INCLUDED_ */