2 MITK测试代码step4
2017-03-02 10:37
197 查看
1 官网教程
http://docs.mitk.org/2016.11/Step04Page.html
2 Step4.cpp
3 CMakeLists.txt
4 files.cmake
编译及生成请参考第一篇,然后下载俩个数据,一个三维的,一个二维的。
5 编辑D:\myproj\mitk\step4_bin下Step4_debug.bat代码(仅供参考,请根据自己路径修改)
6 运行效果
http://docs.mitk.org/2016.11/Step04Page.html
2 Step4.cpp
/*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkRegisterClasses.h" #include "QmitkRenderWindow.h" #include "QmitkSliceWidget.h" #include "mitkNodePredicateDataType.h" #include "mitkProperties.h" #include "mitkRenderingManager.h" #include "mitkStandaloneDataStorage.h" #include <mitkIOUtil.h> #include <QApplication> #include <QHBoxLayout> #include <itksys/SystemTools.hxx> #include <mitkImage.h> //##Documentation //## @brief Use several views to explore data //## //## As in Step2 and Step3, load one or more data sets (many image, //## surface and other formats), but create 3 views on the data. //## The QmitkRenderWindow is used for displaying a 3D view as in Step3, //## but without volume-rendering. //## Furthermore, we create two 2D views for slicing through the data. //## We use the class QmitkSliceWidget, which is based on the class //## QmitkRenderWindow, but additionally provides sliders //## to slice through the data. We create two instances of //## QmitkSliceWidget, one for axial and one for sagittal slicing. //## The two slices are also shown at their correct position in 3D as //## well as intersection-line, each in the other 2D view. int main(int argc, char *argv[]) { QApplication qtapplication(argc, argv); if (argc < 2) { fprintf( stderr, "Usage: %s [filename1] [filename2] ...\n\n", itksys::SystemTools::GetFilenameName(argv[0]).c_str()); return 1; } // Register Qmitk-dependent global instances QmitkRegisterClasses(); //************************************************************************* // Part I: Basic initialization //************************************************************************* // Create a DataStorage mitk::StandaloneDataStorage::Pointer ds = mitk::StandaloneDataStorage::New(); //************************************************************************* // Part II: Create some data by reading files //************************************************************************* int i; for (i = 1; i < argc; ++i) { // For testing if (strcmp(argv[i], "-testing") == 0) continue; //********************************************************************* // Part III: Put the data into the datastorage //********************************************************************* // Load datanode (eg. many image formats, surface formats, etc.) mitk::IOUtil::Load(argv[i], *ds); } //************************************************************************* // Part IV: Create windows and pass the tree to it //************************************************************************* // Create toplevel widget with horizontal layout QWidget toplevelWidget; QHBoxLayout layout; layout.setSpacing(2); layout.setMargin(0); toplevelWidget.setLayout(&layout); //************************************************************************* // Part IVa: 3D view //************************************************************************* // Create a renderwindow QmitkRenderWindow renderWindow(&toplevelWidget); layout.addWidget(&renderWindow); // Tell the renderwindow which (part of) the datastorage to render renderWindow.GetRenderer()->SetDataStorage(ds); // Use it as a 3D view renderWindow.GetRenderer()->SetMapperID(mitk::BaseRenderer::Standard3D); // Reposition the camera to include all visible actors renderWindow.GetRenderer()->GetVtkRenderer()->ResetCamera(); // ******************************************************* // ****************** START OF NEW PART ****************** // ******************************************************* //************************************************************************* // Part IVb: 2D view for slicing axially //************************************************************************* // Create QmitkSliceWidget, which is based on the class // QmitkRenderWindow, but additionally provides sliders QmitkSliceWidget view2(&toplevelWidget); layout.addWidget(&view2); view2.SetLevelWindowEnabled(true); // Tell the QmitkSliceWidget which (part of) the tree to render. // By default, it slices the data axially view2.SetDataStorage(ds); // Get the image from the data storage. A predicate (mitk::NodePredicateBase) // is used to get only nodes of the type mitk::Image. mitk::DataStorage::SetOfObjects::ConstPointer rs = ds->GetSubset(mitk::TNodePredicateDataType<mitk::Image>::New()); view2.SetData(rs->Begin(), mitk::SliceNavigationController::Axial); // We want to see the position of the slice in 2D and the // slice itself in 3D: add it to the datastorage! ds->Add(view2.GetRenderer()->GetCurrentWorldGeometry2DNode()); //************************************************************************* // Part IVc: 2D view for slicing sagitally //************************************************************************* // Create QmitkSliceWidget, which is based on the class // QmitkRenderWindow, but additionally provides sliders QmitkSliceWidget view3(&toplevelWidget); layout.addWidget(&view3); view3.SetDataStorage(ds); // Tell the QmitkSliceWidget which (part of) the datastorage to render // and to slice sagitally view3.SetData(rs->Begin(), mitk::SliceNavigationController::Sagittal); // We want to see the position of the slice in 2D and the // slice itself in 3D: add it to the datastorage! ds->Add(view3.GetRenderer()->GetCurrentWorldGeometry2DNode()); // ******************************************************* // ******************* END OF NEW PART ******************* // ******************************************************* //************************************************************************* // Part V: Qt-specific initialization //************************************************************************* toplevelWidget.show(); // for testing #include "QtTesting.h" if (strcmp(argv[argc - 1], "-testing") != 0) return qtapplication.exec(); else return QtTesting(); } /** \example Step4.cpp */
3 CMakeLists.txt
cmake_minimum_required(VERSION 2.8.4) project(Step4) # 这里改成你的项目名 find_package(MITK REQUIRED) # Check that MITK has been build with Qt support #if(NOT MITK_USE_QT) # message(SEND_ERROR "MITK needs to be built with MITK_USE_QT set to ON") #endif() # Check prerequisites for this application. # We need the Qmitk module. #MITK_CHECK_MODULE(result Qmitk) #if(result) # message(SEND_ERROR "MITK module(s) \"${result}\" not available from the MITK build at ${MITK_DIR}") #endif() # Set-up the build system to use the Qmitk module #MITK_USE_MODULE(Qmitk) include_directories(${ALL_INCLUDE_DIRECTORIES}) link_directories(${ALL_LIBRARY_DIRS}) mitk_create_executable(${PROJECT_NAME} DEPENDS MitkQtWidgetsExt) #add_executable(${PROJECT_NAME} Step4.cpp) # 这里改成你的源文件名 target_link_libraries(${PROJECT_NAME} ${ALL_LIBRARIES})
4 files.cmake
# List all source files set(CPP_FILES Step4.cpp)
编译及生成请参考第一篇,然后下载俩个数据,一个三维的,一个二维的。
5 编辑D:\myproj\mitk\step4_bin下Step4_debug.bat代码(仅供参考,请根据自己路径修改)
PATH=/plugins/debug;D:/MITK-bin-win/MITK-build/bin/debug;D:/MITK-bin-win/MITK-build/bin/plugins/debug;D:/MITK-bin-win/MITK-build/lib/debug;D:/MITK-bin-win/MITK-build/lib/plugins/debug;D:/MITK-bin-win/ep/bin;D:/MITK-bin-win/ep/lib;C:/Qt/Qt5.6.2/5.6/msvc2013_64/bin;D:/MITK-bin-win/ep/lib/cmake/ITK-4.9/bin;D:/MITK-bin-win/ep/src/CTK-build/CTK-build/bin/debug;D:/MITK-bin-win/ep/src/CTK-build/qRestAPI-build/debug;%PATH% debug\Step4.exe D:\data\Pic3D.nrrd D:\data\lungs.vtk pause
6 运行效果
相关文章推荐
- 测试代码
- 重画系列:DataGridColumnStyle之测试代码
- 测试代码
- 代码测试
- 关于测试代码必须做以下几件事情的下厨做菜理解法。
- CnBlogs.Com用到的CSS控制的代码折叠功能测试
- 优化代码时要选用正确的测试方法
- c++代码测试-std::string元素
- (翻译)测试错误代码
- vc与bcb最优化代码测试(1)
- 单元测试-使用nmock测试你的.NET代码(1)
- 测试代码在实际类的内部写还是外部写的思考
- Eclipse代码片断编辑测试窗
- 单元测试-使用nmock测试你的.NET代码(2)
- 代码测试的简单框架
- 关于Peer Review、代码评审和测试驱动等
- Rsa加密的Java测试代码
- ms05016分析及测试代码
- NNnit 测试代码的编写等
- 使用Rational PureCoverage测试代码覆盖率