zoukankan      html  css  js  c++  java
  • VTK-py读取与显示相关函数

    在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

  • 相关阅读:
    操作系统--进程间同步
    操作系统--进程间通信
    LeetCode-- Unique Binary Search Trees II
    STL源码--序列容器(一)
    操作系统--用户级线程和内核级线程
    非洲孩子
    寻找最大数(三)
    找点
    心急的C小加
    1044 拦截导弹——http://codevs.cn/problem/1044/
  • 原文地址:https://www.cnblogs.com/flyuz/p/9497120.html
Copyright © 2011-2022 走看看