VTK在MFC中实现的小实例
2013-11-24 09:40
211 查看
void CVTKMFCDlg::OnBnClickedButton1()
{
// TODO: 在此添加控件通知处理程序代码
CRect rect;
m_dixing.GetClientRect(&rect); //显示在MFC上的静态文本框中
// create sphere geometry
vtkSphereSource *sphere = vtkSphereSource::New();
sphere->SetRadius(1.0);
sphere->SetThetaResolution(18);
sphere->SetPhiResolution(18);
// map to graphics library
vtkPolyDataMapper *map = vtkPolyDataMapper::New();
map->SetInput(sphere->GetOutput());
// actor coordinates geometry, properties, transformation
vtkActor *aSphere = vtkActor::New();
aSphere->SetMapper(map);
aSphere->GetProperty()->SetColor(0,0,1); // sphere color blue
// a renderer and render window
vtkRenderer *ren1 = vtkRenderer::New();
vtkRenderWindow *renWin = vtkRenderWindow::New();
CWnd *pWnd=GetDlgItem(IDC_dixing);
HWND hwnd =pWnd->GetSafeHwnd();
renWin->SetParentId(hwnd);//设置文本框为要显示的父窗口
renWin->SetSize(rect.Width(),rect.Height());
renWin->AddRenderer(ren1);
// an interactor
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);
// add the actor to the scene
ren1->AddActor(aSphere);
ren1->SetBackground(1,1,1); // Background color white
// render an image (lights and cameras are created automatically)
renWin->Render();
// begin mouse interaction
iren->Start();
// release memory and return
sphere->Delete();
map->Delete();
aSphere->Delete();
ren1->Delete();
renWin->Delete();
iren->Delete();
}
{
// TODO: 在此添加控件通知处理程序代码
CRect rect;
m_dixing.GetClientRect(&rect); //显示在MFC上的静态文本框中
// create sphere geometry
vtkSphereSource *sphere = vtkSphereSource::New();
sphere->SetRadius(1.0);
sphere->SetThetaResolution(18);
sphere->SetPhiResolution(18);
// map to graphics library
vtkPolyDataMapper *map = vtkPolyDataMapper::New();
map->SetInput(sphere->GetOutput());
// actor coordinates geometry, properties, transformation
vtkActor *aSphere = vtkActor::New();
aSphere->SetMapper(map);
aSphere->GetProperty()->SetColor(0,0,1); // sphere color blue
// a renderer and render window
vtkRenderer *ren1 = vtkRenderer::New();
vtkRenderWindow *renWin = vtkRenderWindow::New();
CWnd *pWnd=GetDlgItem(IDC_dixing);
HWND hwnd =pWnd->GetSafeHwnd();
renWin->SetParentId(hwnd);//设置文本框为要显示的父窗口
renWin->SetSize(rect.Width(),rect.Height());
renWin->AddRenderer(ren1);
// an interactor
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);
// add the actor to the scene
ren1->AddActor(aSphere);
ren1->SetBackground(1,1,1); // Background color white
// render an image (lights and cameras are created automatically)
renWin->Render();
// begin mouse interaction
iren->Start();
// release memory and return
sphere->Delete();
map->Delete();
aSphere->Delete();
ren1->Delete();
renWin->Delete();
iren->Delete();
}
相关文章推荐
- cocos2d-x笔记
- .Net学习笔记《C#高级编程》之windows服务
- 河南科技学院CSDN俱乐部--c语言讲解
- windows 下mysql的安装于使用(启动、关闭)
- A summary of how to produce American TH sounds
- Node.js Web 开发框架大全《路由篇》
- 《卫生经济学》读书笔记:第2章 健康和医疗服务:经济学的展望
- hello world ,详解
- C++ - 类模板(class template)友元(friend) 的 全部六种形式 及 代码
- C++ - 类模板(class template)友元(friend) 的 全部六种形式 及 代码
- [置顶] Android_照相机Camera_调用系统照相机返回data为空
- CSDN博客排版的那些事
- Linux网络编程必看书籍推荐
- 跨平台的检测键盘是否有键按下并返回按键的值
- 驱动中获取PsActiveProcessHead变量地址的五种方法
- 驱动中获取PsActiveProcessHead变量地址的五种方法
- svn不能添加.a文件的解决方法
- M,BB面试+职业求教
- jQuery页面滚动图片等元素动态加载实现
- 使用安卓手机连接win7的热点