1.管线技术(Pipeline,流水线)
- 可视化管线(Visualization Pipeline):将原始数据加工成图形数据的过程。
- 图形管线(Graphics Pipeline):图形数据加工为我们所看到的图像的过程。
2.TVTK的管线
3. 用TVTK工具观察管线
from tvtk.api import tvtk
from tvtk.tools import ivtk
from pyface.api import GUI
s = tvtk.CubeSource(x_length=1.0, y_length=2.0, z_length=3.0)
m = tvtk.PolyDataMapper(input_connection=s.output_port)
a = tvtk.Actor(mapper=m)
# 创建一个带Crust(Python Shell)的窗口
gui = GUI()
win = ivtk.IVTKWithCrustAndBrowser()
win.open()
win.scene.add_actor(a)
# 开始界面消息循环
gui.start_event_loop()
这里会有一个bug,导致dialog子窗口与主窗口分离。
可以用以下代码进行修改:
from tvtk.api import tvtk
from tvtk.tools import ivtk
from pyface.api import GUI
s = tvtk.CubeSource(x_length=1.0, y_length=2.0, z_length=3.0)
m = tvtk.PolyDataMapper(input_connection=s.output_port)
a = tvtk.Actor(mapper=m)
# 创建一个带Crust(Python Shell)的窗口
gui = GUI()
win = ivtk.IVTKWithCrustAndBrowser()
win.open()
win.scene.add_actor(a)
# 修正窗口错误
dialog = win.control.centralWidget().widget(0).widget(0)
from pyface.qt import QtCore
dialog.setWindowFlags(QtCore.Qt.WindowFlags(0x00000000))
dialog.show()
gui.start_event_loop()
在下面的shell输入print(scene.renderer.actors[0].mapper.input.points.to_array())
可以得到构成长方体的顶点的位置信息。
照相机:
Edit Properties:
对以上代码进行封装:
# Tvtkfunc.py
from tvtk.api import tvtk
def ivtk_scene(actors):
from tvtk.tools import ivtk
# 创建一个带Crust(Python Shell)的窗口
win = ivtk.IVTKWithCrustAndBrowser()
win.open()
win.scene.add_actor(actors)
# 修正窗口错误
dialog = win.control.centralWidget().widget(0).widget(0)
from pyface.qt import QtCore
dialog.setWindowFlags(QtCore.Qt.WindowFlags(0x00000000))
dialog.show()
return win
def event_loop():
from pyface.api import GUI
gui = GUI()
gui.start_event_loop()