VTK学习2

这里好像不能贴图。忙了一早上,终于在VTK+vc6.0下开发了第一个程序,兴奋!!!!!

 

First you need to create a MFC/SDI Project:

  1. Use the Visual C++ IDE (Version 6) to create a project.
  2. Choose File | New Project.
    Select the Projects tab and the MFC App Wizard (exe)
  3. Name the project and create a new workspace by pressing OK.
  4. In Step 1, select Single Document
  5. Continue through to Step 4 by pressing Next.
  6. In Step 4 select advanced. If you want to associate a file extension with the program, enter it into the File extension box. In this case the extension is vtk. If you want vary Window Styles, select the Window Style tab and choose whatever you want.
  7. Click on Close
  8. Either continue clicking Next or Finish.

The next stage is to modify the project settings to include the VTK files and libraries.

  1. Choose Project | Settings... and ensure that Settings for All Configurations is chosen.
  2. Select the Tab: C/C++, category Preprocessor and add in the path to the header files into the Additional Include Directories box e.g. C:/vtk/vtkbin, C:/vtk/vtk/Common, C:/vtk/vtk/Filtering,C:/vtk/vtk/Graphics, C:/vtk/vtk/Hybrid, C:/vtk/vtk/Imaging, C:/vtk/vtk/IO, C:/vtk/vtk/Rendering
  3. Select the Tab: Link, and enter the Object/Library modules into the Object/Library Modules box e.g. vtkCommon.lib vtkFiltering.lib vtkGraphics.lib vtkHybrid.lib vtkImaging.lib vtkIO.lib vtkjpeg.lib vtkpng.lib vtkRendering.lib vtkzlib.lib
  4. Now select Input and change Settings For: All Configurations to Debug and put in the path to the Debug libraries and DLL's into the Additional Library path box e.g: C:/vtk/vtkbin/bin/Debug
  5. Now select Input and change Settings For: Debug to Release and put in the path to the Release libraries and DLL's into the Additional Library path box e.g: C:/vtk/vtkbin/bin/Release
  6. 把DLL文件拷到编译的程序下
  7. 打完收工

The final stage is to add the VTK functionality to the application.

我照例子作了一个程序。

  1. Add the necessary VTK variables and corresponding VTK header files. It is best to make these variables private. Now these variables need to be created and deleted. So...
  2. In the constructor add the necessary creation code.
  3. In the destructor, add the necessary deletion code.
    Remember
    : for every New in the constructor, you must have a corresponding Delete in the destructor.
  4. Add the windows message handler corresponding to WM_CREATE and insert code code to enable adding the renderer to the vtk window and link the view to the VTK window. This function is called OnCreate().
  5. We need to add functionality to the OnDraw method to enable the VTK object to be viewed, manipulated and printed. In this method, we will also call a function that sets up the pipeline for the rendering process. Let's call this member function Pipeline().
  6. In order to allow resizing, add the windows message handler corresponding to WM_SIZE and insert code for resizing. This creates a function called OnSize().
  7. Flickering will occur if you resize the view so, add the windows message handler corresponding to WM_ERASEBKGND to create the function called OnEraseBkgnd() and over-ride it to return TRUE.
  8. We need to allow the interactor to process commands from the keyboard so we add the windows virtual function WindowProc() and insert some code to handle the desired messages.
  9. Add the required code to Pipeline() to create the VTK rendition of a scene or object.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值