第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

渲染在 vtkCommand 中創(chuàng)建的 actor(回調(diào))

渲染在 vtkCommand 中創(chuàng)建的 actor(回調(diào))

Go
湖上湖 2021-10-19 09:49:26
我正在嘗試編寫一個程序,該程序在按下箭頭鍵時顯示和循環(huán)顯示不同文件格式的圖像。我發(fā)現(xiàn)設置我的 reader->mapper->actor 管道然后啟動我的 RenderWindowInteractor 允許渲染 actor,但是將此代碼移動到 RenderWindowInteractor 的 KeyPressEvent 的回調(diào)不允許渲染 actor。一旦事件循環(huán)開始,是否需要額外的步驟來設置新的actor,或者我犯了其他錯誤?import vtk#Create the renderer that will display our actorsren = vtk.vtkRenderer()actor = None#Maps the data from the Nifti file 'filename' onto a vtkImageSlice actordef LoadNifti():    # load head MRI in NIFTI format    reader = vtk.vtkNIFTIImageReader()    reader.SetFileName("head.nii")    reader.Update()    # Add an ImageSliceMapper, which maps data to an ImageSlice Actor    mapper = vtk.vtkImageSliceMapper()    #Set the slice position to the camera focal point    mapper.SliceAtFocalPointOn()    mapper.SetInputConnection(reader.GetOutputPort())    # Add an ImageSlice actor, which represents a slice as an image    global actor    actor = vtk.vtkImageSlice()    actor.SetMapper(mapper)#Placeholder for when I have DICOM workingdef ShowDICOM(filename):    pass#Create a RenderWindow to display images from the RendererrenWin = vtk.vtkRenderWindow()renWin.AddRenderer(ren)#Wrap the RenderWindow in a RenderWindowInteractor to catch key and mouse eventsiren = vtk.vtkRenderWindowInteractor()iren.SetRenderWindow(renWin)def foo():    LoadNifti()    ren.AddActor(actor)##Extend the default functionality of the interactor and its style with custom listenersdef KeyPressEvent(obj, ev):    foo()    print("This verifies that the callback is triggered")iren.AddObserver("KeyPressEvent", KeyPressEvent)        #Start the program############################################################################ WHEN foo() IS PRESENT BELOW, THE ACTOR WILL RENDER IMMEDIATELY.# WHEN foo() IS ABSENT BELOW, CALLING foo() BY TRIGGERING THE KeyPressEvent# IS NOT SUFFICIENT TO HAVE THE ACTOR RENDER.###########################################################################foo()#According to the docs, the Start method will initialize iren and render renWin automaticallyiren.Start()
查看完整描述

1 回答

?
子衿沉夜

TA貢獻1828條經(jīng)驗 獲得超3個贊

好吧,您絕對可以在回調(diào)中添加或刪除角色。要立即再次渲染場景,只需調(diào)用iren.Render()。


當您在沒有任何可見演員和明確定義的相機的情況下啟動渲染器時,ResetCamera通常需要。AutomaticResetCamera在初始化期間只調(diào)用一次,這就是為什么調(diào)用foo()beforeiren.Start()使對象可見的原因。


def foo():

    LoadNifti()

    ren.AddActor(actor)

    ren.ResetCamera() # should that be necessary

    iren.Render()


查看完整回答
反對 回復 2021-10-19
  • 1 回答
  • 0 關(guān)注
  • 431 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號