医站点医维基

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 1710|回复: 5

[VTK] VTK例子22-设置观察交互模式

[复制链接]

336

主题

411

回帖

2808

积分

管理员

积分
2808

热心会员推广达人优秀版主荣誉管理论坛元老

发表于 2015-12-6 12:28:52 | 显示全部楼层 |阅读模式
设置观察交互模式
#include "stdafx.h"
//VTK 对场景中的多个对象设置不同的交互方式方式
//#if 1
#include "vtkconesource.h"
#include "vtkpolydatamapper.h"
#include "vtkactor.h"
#include "vtkrenderer.h"
#include "vtkrenderwindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkInteractorStyleTrackballCamera.h"
#include "vtkInteractorStyleTrackballActor.h"
int main(int argc, char* argv[])
{
//建立模型
vtkConeSource *cone=vtkConeSource::New();
cone->SetHeight(5);
cone->SetCenter(0,0,0);
cone->SetRadius(2);
cone->SetResolution(100);
vtkPolyDataMapper * map=vtkPolyDataMapper::New();
map->SetInput(cone->GetOutput());
vtkActor *actor=vtkActor::New();
actor->SetMapper(map);
//建立模型
vtkConeSource *cone1=vtkConeSource::New();
cone1->SetHeight(5);
cone1->SetCenter(10,0,0);
cone1->SetRadius(2);
cone1->SetResolution(100);
vtkPolyDataMapper * map1=vtkPolyDataMapper::New();
map1->SetInput(cone1->GetOutput());
vtkActor *actor1=vtkActor::New();
actor1->SetMapper(map1);
//建立模型
vtkConeSource *cone2=vtkConeSource::New();
cone2->SetHeight(5);
cone2->SetCenter(20,0,0);
cone2->SetRadius(2);
cone2->SetResolution(100);
vtkPolyDataMapper * map2=vtkPolyDataMapper::New();
map2->SetInput(cone2->GetOutput());
vtkActor *actor2=vtkActor::New();
actor2->SetMapper(map2);
//设置render
vtkRenderer * ren=vtkRenderer::New();
ren->AddActor(actor);
ren->AddActor(actor1);
ren->AddActor(actor2);
ren->SetBackground(.9,.5,.4);
vtkRenderWindow* win=vtkRenderWindow::New();
win->AddRenderer(ren);
win->SetSize(600,480);
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
iren->SetRenderWindow(win);
iren->Initialize();
//设置观察交互模式
//vtkInteractorStyleTrackballCamera *pvtkInteractorStyleTrackballCamera=vtkInteractorStyleTrackballCamera::New();
//iren->SetInteractorStyle(pvtkInteractorStyleTrackballCamera); //对所有actor使用相同的交互
vtkInteractorStyleTrackballActor *pvtkInteractorStyleTrackballActor=vtkInteractorStyleTrackballActor::New();
iren->SetInteractorStyle(pvtkInteractorStyleTrackballActor); //对每个不同的actor使用不同的交互
win->Render();
//开始交互
iren->Start();
return 0;
}
22.png
回复

使用道具 举报

0

主题

396

回帖

791

积分

高级会员

积分
791

最佳新人

发表于 2016-5-11 21:24:26 | 显示全部楼层
LZ高人啊,我来学习了
回复

使用道具 举报

178

主题

438

回帖

1713

积分

金牌会员

积分
1713

热心会员推广达人优秀版主荣誉管理论坛元老

发表于 2016-5-16 02:27:15 | 显示全部楼层
顶!!!!!!!!!
回复

使用道具 举报

62

主题

418

回帖

1355

积分

版主

积分
1355

热心会员推广达人优秀版主荣誉管理论坛元老

发表于 2016-5-19 11:09:54 | 显示全部楼层
回复

使用道具 举报

48

主题

389

回帖

1146

积分

版主

积分
1146

热心会员推广达人优秀版主荣誉管理论坛元老

发表于 2016-5-20 02:35:35 | 显示全部楼层
一直在寻找这个,多谢了
回复

使用道具 举报

48

主题

389

回帖

1146

积分

版主

积分
1146

热心会员推广达人优秀版主荣誉管理论坛元老

发表于 2016-5-21 07:05:27 | 显示全部楼层
zhichizhichi
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|关于我们|医维基|网站地图|Archiver|手机版|医疗之家 ( 沪ICP备2023001278号-1 )  

GMT+8, 2024-5-16 15:58 , Processed in 0.207480 second(s), 32 queries .

Designed by Medical BBS

快速回复 返回顶部 返回列表