00001 /*========================================================================= 00002 00003 Program: Medical Imaging & Interaction Toolkit 00004 Language: C++ 00005 Date: $Date$ 00006 Version: $Revision$ 00007 00008 Copyright (c) German Cancer Research Center, Division of Medical and 00009 Biological Informatics. All rights reserved. 00010 See MITKCopyright.txt or https://www.mitk.org/copyright.html for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 00018 00019 #include "mitkContour.h" 00020 #include "mitkDataNode.h" 00021 #include "mitkContourMapper2D.h" 00022 #include "mitkCommon.h" 00023 #include "mitkStandaloneDataStorage.h" 00024 #include "mitkGlobalInteraction.h" 00025 00026 #include "mitkVtkPropRenderer.h" 00027 00028 #include <fstream> 00029 00030 int mitkContourMapper2DTest(int /*argc*/, char* /*argv*/[]) 00031 { 00032 mitk::Contour::Pointer contour; 00033 mitk::ContourMapper2D::Pointer contourMapper; 00034 mitk::DataNode::Pointer node; 00035 00036 // Global interaction must(!) be initialized if used 00037 mitk::GlobalInteraction::GetInstance()->Initialize("global"); 00038 00039 contourMapper = mitk::ContourMapper2D::New(); 00040 node = mitk::DataNode::New(); 00041 std::cout << "Testing mitk::ContourMapper2D::New(): "; 00042 00043 contour = mitk::Contour::New(); 00044 node->SetData(contour); 00045 00046 if (contour.IsNull()) { 00047 std::cout << "[FAILED]" << std::endl; 00048 return EXIT_FAILURE; 00049 } 00050 else { 00051 std::cout<<"[PASSED]"<<std::endl; 00052 } 00053 00054 contourMapper->SetDataNode( node ); 00055 contourMapper->Update(NULL); 00056 mitk::Contour* testContour = (mitk::Contour*)contourMapper->GetInput(); 00057 std::cout << testContour << std::endl; 00058 00059 mitk::StandaloneDataStorage::Pointer ds = mitk::StandaloneDataStorage::New(); 00060 00061 ds->Add( node ); 00062 00063 mitk::BoundingBox::Pointer bounds = ds->ComputeBoundingBox(); 00064 00065 std::cout << "bounds: " << bounds << std::endl; 00066 00067 bounds = ds->ComputeVisibleBoundingBox(); 00068 std::cout << "visible bounds: " << bounds << std::endl; 00069 00070 vtkRenderWindow* renWin = vtkRenderWindow::New(); 00071 00072 mitk::VtkPropRenderer::Pointer renderer = mitk::VtkPropRenderer::New( "ContourRenderer",renWin, mitk::RenderingManager::GetInstance() ); 00073 00074 std::cout<<"Testing mitk::BaseRenderer::SetData()"<<std::endl; 00075 00076 renderer->SetDataStorage(ds); 00077 00078 std::cout<<"[TEST DONE]"<<std::endl; 00079 00080 renWin->Delete(); 00081 00082 return EXIT_SUCCESS; 00083 }