码迷,mamicode.com
首页 > 其他好文 > 详细

VTK-py读取与显示相关函数

时间:2018-08-18 14:22:42      阅读:197      评论:0      收藏:0      [点我收藏+]

标签:point   alt   The   src   date   triangle   poi   png   技术分享   

在VTK中可视化数据的一般流程如下:

技术分享图片

文件输入相关函数:

https://www.vtk.org/Wiki/VTK/Examples/Cxx#Input_and_Output

Readers ● Reads data from file

Filters ● Takes data as input, modifies it in some way, and returns the modified data

Mappers ● Maps data to graphics primitives (points, lines, or triangles) that can be displayed by the renderer

Actors ● vtkActor represents an object (geometry and properties) in a rendering scene

Rendering ● The process of converting 3D graphics primitives (points, lines, triangles, etc), a specification for lights and materials, and a camera view into an 2D image that can be displayed on the screen

Renderer ● vtkRenderer controls the rendering process for actors and scenes

Render window ● The vtkRenderWindow class creates a window for renderers to draw into

Interactors ● The vtkRenderWindowInteractor class provides platform-independent window interaction via the mouse and keyboard

一个读取.obj文件的代码:

 1 import vtk
 2 
 3 filename = "xxxxx.obj"
 4 reader = vtk.vtkOBJReader()
 5 reader.SetFileName(filename)
 6 reader.Update()
 7 
 8 mapper = vtk.vtkPolyDataMapper()
 9 mapper.SetInputConnection(reader.GetOutputPort())
10 
11 actor = vtk.vtkActor()
12 actor.SetMapper(mapper)
13 
14 renderer = vtk.vtkRenderer()
15 renderer.AddActor(actor)
16 #renderer.GetActiveCamera().SetPosition() #设置视点位置
17 #renderer.GetActiveCamera().SetViewUp(0, 1, 0)  #设置视点方向
18 renderer.SetBackground(0.1, 0.1, 0.1)  #设置背景颜色
19 
20 renWin = vtk.vtkRenderWindow()
21 renWin.SetSize(640, 480)     #设置窗口大小
22 renWin.AddRenderer(renderer)
23 
24 iren = vtk.vtkRenderWindowInteractor()
25 iren.SetRenderWindow(renWin)
26 iren.Initialize()
27 
28 renWin.Render()
29 iren.Start()

参考资料:

http://www.cb.uu.se/~aht/Vis2014/lecture2.pdf

VTK-py读取与显示相关函数

标签:point   alt   The   src   date   triangle   poi   png   技术分享   

原文地址:https://www.cnblogs.com/flyuz/p/9497120.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!