1. 资源
cmake官网 https://cmake.org/download/
下载 cmake-3.8.0-rc4-win64-x64.msi
VTK 官网 https://vtk.org/download/
下载 VTK-7.1.1.zip
ITK 官网 https://itk.org/ITK/resources/software.html
下载 InsightToolkit-4.11.1.zip
VS2015 通过MSDN下载映像文件,然后安装
2.文件夹
2.2cmake
2,2VTK
其中
source_code中存放下载的ZIP文件以及解压缩之后的文件
release中存放cmake编译后的文件
VTK-bin中存放VS编译后的文件
2.3 ITK
3.cmake编译VTK ITK
3.1安装运行cmake,双击cmake-gui.exe
3.2编译配置
上面为三个需要设置的地方
步骤:选好文件夹→选vs版本→configure→设置上面三个地方→configure到上面都没有红色→generate→以管理员的身份运行VS打开.sln文件(以VTK为例)
4 VS中的编译操作
步骤:
点击all build→重新生成,直到所有的成功→点击install,仅生成,直到所有的都成功
结果
5 VS中的配置局部属性表(VTK为例)
5.1 将VS2015 VTK_bin中bin文件以及ITK_bin中的bin文件添加到系统环境变量
5.2新建VC++空项目 project1→点击下面的属性管理器→右击Debug |x64,添加新项目属性表→将属性表保存在VTK总的文件夹中→设置VC++目录中的包含目录以及库目录,如图所示
→设置c/c++中的常规中的附加包含目录,如图所示
→设置链接器中的输入中的附加依赖项(依赖项的方法添加为:打开D:\TOOLS\VTK\VTK_bin\lib将文件夹中所有的.lib文件名添加到里面)
6测试
6.1VTK测试程序
//
// This simple example shows how to do basic rendering and pipeline
// creation using C++.
//
#include "vtkCylinderSource.h"
#include "vtkPolyDataMapper.h"
#include "vtkActor.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkProperty.h"
#include "vtkCamera.h"
#include <vtkAutoInit.h>
#include <vtkAutoInit.h>
VTK_MODULE_INIT(vtkRenderingOpenGL2)
VTK_MODULE_INIT(vtkInteractionStyle);
VTK_MODULE_INIT(vtkRenderingFreeType);
int main()
{
// This creates a polygonal cylinder model with eight circumferential facets.
//
vtkCylinderSource *cylinder = vtkCylinderSource::New();
cylinder->SetResolution(8);
// The mapper is responsible for pushing the geometry into the graphics
// library. It may also do color mapping, if scalars or other attributes
// are defined.
//
vtkPolyDataMapper *cylinderMapper = vtkPolyDataMapper::New();
cylinderMapper->SetInputConnection(cylinder->GetOutputPort());
// The actor is a grouping mechanism: besides the geometry (mapper), it
// also has a property, transformation matrix, and/or texture map.
// Here we set its color and rotate it -22.5 degrees.
vtkActor *cylinderActor = vtkActor::New();
cylinderActor->SetMapper(cylinderMapper);
cylinderActor->GetProperty()->SetColor(1.0000, 0.3882, 0.2784);
cylinderActor->RotateX(30.0);
cylinderActor->RotateY(-45.0);
// Create the graphics structure. The renderer renders into the
// render window. The render window interactor captures mouse events
// and will perform appropriate camera or actor manipulation
// depending on the nature of the events.
//
vtkRenderer *ren1 = vtkRenderer::New();
vtkRenderWindow *renWin = vtkRenderWindow::New();
renWin->AddRenderer(ren1);
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);
// Add the actors to the renderer, set the background and size
//
ren1->AddActor(cylinderActor);
ren1->SetBackground(0.1, 0.2, 0.4);
renWin->SetSize(200, 200);
// We'll zoom in a little by accessing the camera and invoking a "Zoom"
// method on it.
ren1->ResetCamera();
ren1->GetActiveCamera()->Zoom(1.5);
renWin->Render();
// This starts the event loop and as a side effect causes an initial render.
iren->Start();
// Exiting from here, we have to delete all the instances that
// have been created.
cylinder->Delete();
cylinderMapper->Delete();
cylinderActor->Delete();
ren1->Delete();
renWin->Delete();
iren->Delete();
return 0;
}
6.2 ITK测试程序
#include <iostream>
#include "itkImage.h"
using namespace std;
int main()
{
typedef itk::Image<unsigned short, 3> ImageType;
ImageType::Pointer image = ImageType::New();
cout << "ITK Hello World !" << endl;
getchar();
return 0;
}
到此配置完毕
7.遇到的问题
7.1 VS中第一次没有配置C/C++常规,依赖项一个都没有
7.2 在ITK的lib文件中,有一个.setting文件是不可以添加到依赖项的
感谢的博文:
1.cmake配置
https://blog.csdn.net/hebbely/article/details/81067505
https://blog.csdn.net/wae42675/article/details/71922529
2.VS的配置
https://blog.csdn.net/wangxiao7474/article/details/69454760
3.测试代码
https://blog.csdn.net/berlinpand/article/details/79044333