(1) PrefaceI used vs2005 and C ++ to develop VTK programs in my school. I wrote a VTK Development Guide on my blog; after work, I found that if I had abandoned the underlying data computing, it would be extremely simple to use C # To develop VTK programs. In terms of VTK-based program development efficiency, the development efficiency of C # is several times higher than that of C ++. Mainly manifested in: (1) more convenient application framework construction (Form programming replaces the Interface Programming of MFC); (2) more convenient object generation and Destruction Management (C #'s garbage collection mechanism); (3) Dot NET wrapper encapsulation of VTK makes VTK programming more convenient, simply using "using VTK; ", completed all the operations on the C ++ header file. (4) more convenient window message intercept, thanks to the C # form. The following describes how to use.. Net C # environment for VTK application development:(2) preparations:1. Download. Net wrappers for VTK 5 in http://vtkdotnet.sourceforge.net/can find the wrapper of vtk5 in. net
| |
1.1 notes) |
| |
VTK-5.0.1-control-1.1.zip mirror. |
6664545 |
I386 |
| |
VTK-5.0.1-help-1.1.chm mirror. |
18104898 |
I386 |
| |
VTK-5.0.1-wrap-1.1-bin.zip mirror. |
10781075 |
I386 |
| |
VTK-5.0.1-wrap-1.1-src.zip mirror. |
10942984 |
Platform-independent |
Among them, vtk-5.0.1-control-1.1.zip, VTK-5.0.1-wrap-1.1-bin.zip files are required, the former contains vtkformswindow. DLL, in.. net. The latter includes VTK.. net. 2. unzip vtk-5.0.1-wrap-1.1-bin.zip, which contains three directories: bin directory, include directory, and lib directory.. Net DLL files and unmanaged DLL link library files. The include directory contains the header files required for vtk development in the c ++ environment; the lib directory contains all the Lib library files developed in the C ++ environment. This article mainly discusses. therefore, the bin directory is similar to * DOTNET. copy the DLL file to the C:/Windows directory or the running directory of your project. 3. in vs2005, create the C # from application program, right-click the project references, and choose add reference .., as shown in: Select Browse and enter Filter Name, * DOTNET in file name. DLL only displays VTK. net wrapper file, in order to facilitate all the * DOTNET. select and add the DLL file to references, right-click the toolbox, and select choose items... Select Browse and select the vtkformswindow. dll file. At this point, the vtkformswindowcontrol control has been added to the toolbox.
(3) ExampleDrag vtkformswindowcontrol from toolbox to form, as shown in. At this point, vs automatically adds private VTK to form code. vtkformswindowcontrol vtkformswindowcontrol1; In general, VTK is in. NET development is very similar to C ++, all implemented through VTK rendering pipeline. The difference is that in C ++, you need to care about when to destroy the generated object, in C #, this step is completed by the garbage collection mechanism of C. The example code is as follows: using system; using system. collections. generic; using system. componentmodel; using system. data; using system. drawing; using system. text; using system. windows. forms; using VTK; namespace vtktest {public partial class form1: FORM {public form1 () {initializecomponent (); vtkearthur source = new vtkearthur source (); vtkpolydatamapper map = new vtkpolydatamapper (); vtkactor actor = new vtkactor (); vtkrenderer Ren = new vtkrenderer (); vtkrenderwindow win = This. vtkformswindowcontrol1.getrenderwindow (); map. setinput (source. getoutput (); actor. setmapper (MAP); Ren. addactor (actor); Ren. setbackground (. 5 ,. 5, 1); win. addrenderer (ren) ;}} has the following effect: Another example: <C # VTK installation ......> tags: vtk c # DOTNET wrapper visiualization