vtk实战(一)——HelloVtk

程序运行环境vs2013,release,64位。
包含目录:(附件vtk-5.8.0解压目录)\vtk-5.8.0;(附件bin-64位release解压目录)\bin
库目录:(附件bin-64位release解压目录\bin\bin\Release
附加依赖项:

CommonCxxTests.lib;Cosmo.lib;MapReduceMPI.lib;mpistubs.lib;QVTK.lib;QVTKWidgetPlugin.lib;VPIC.lib;vtkalglib.lib;vtkCharts.lib;vtkCommon.lib;vtkDICOMParser.lib;vtkexoIIc.lib;vtkexpat.lib;vtkFiltering.lib;vtkfreetype.lib;vtkftgl.lib;vtkGenericFiltering.lib;vtkGeovis.lib;vtkGraphics.lib;vtkhdf5.lib;vtkHybrid.lib;vtkImaging.lib;vtkInfovis.lib;vtkIO.lib;vtkjpeg.lib;vtklibxml2.lib;vtkmetaio.lib;vtkmyCommon.lib;vtkmyImaging.lib;vtkmyUnsorted.lib;vtkNetCDF.lib;vtkNetCDF_cxx.lib;vtkParallel.lib;vtkpng.lib;vtkproj4.lib;vtkRendering.lib;vtksqlite.lib;vtksys.lib;vtktiff.lib;vtkverdict.lib;vtkViews.lib;vtkVolumeRendering.lib;vtkWidgets.lib;vtkzlib.lib;

程序代码:

#include "vtkCylinderSource.h"
#include "vtkPolyDataMapper.h"
#include "vtkActor.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkProperty.h"
#include "vtkCamera.h"

int main()
{
    /*首先创建一个棱柱,vtkCylinderSource继承自vtkPolyDataAlgorithm类,生成vtkPolyData对象*/
    vtkCylinderSource *cylinder = vtkCylinderSource::New();
    cylinder->SetResolution(8);

    /*vtkPolyDataMapper用来定义vtkPolyData信息,如颜色等,而后将信息映射到形体*/
    vtkPolyDataMapper *cylinderMapper = vtkPolyDataMapper::New();
    cylinderMapper->SetInputConnection(cylinder->GetOutputPort());

    /*上面定义了几何特性,接下来定义视角和纹理,下面代码定义了视角和颜色*/
    vtkActor *cylinderActor = vtkActor::New();
    cylinderActor->SetMapper(cylinderMapper);
    cylinderActor->GetProperty()->SetColor(1.0000, 0.3882, 0.2784);
    cylinderActor->RotateX(30.0);
    cylinderActor->RotateY(-45.0);

    /*创建图形结构,渲染窗口加载渲染器,渲染窗口捕获不同的鼠标事件进行不同的操作*/
    vtkRenderer *ren1 = vtkRenderer::New();
    vtkRenderWindow *renWin = vtkRenderWindow::New();
    renWin->AddRenderer(ren1);
    vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
    iren->SetRenderWindow(renWin);

    /*加载渲染器,设置渲染窗口和大小*/
    ren1->AddActor(cylinderActor);
    ren1->SetBackground(0.1, 0.2, 0.4);
    renWin->SetSize(200, 200);

    /*设置图形的放大缩小*/
    ren1->ResetCamera();
    ren1->GetActiveCamera()->Zoom(1.5);
    renWin->Render();

    /*启动渲染*/
    iren->Start();

    /*程序结束,删除所有实例*/
    cylinder->Delete();
    cylinderMapper->Delete();
    cylinderActor->Delete();
    ren1->Delete();
    renWin->Delete();
    iren->Delete();

    return 0;
}

程序源码
程序运行结果

编译好的vtk

bin-64位release.rar:
http://pan.baidu.com/s/1miPFfYC(vs10编译,64位release版,经测试vs13也可用)
vtk-5.8.0:http://pan.baidu.com/s/1boAijef
vtkdata-5.8.0:http://pan.baidu.com/s/1eSNj3XK

程序源码:

http://pan.baidu.com/s/1eSz2VCm

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值