python繪制圓柱體的方法
更新時(shí)間:2018年07月02日 08:32:54 作者:genispan
這篇文章主要為大家詳細(xì)介紹了python繪制圓柱體的方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
本文實(shí)例為大家分享了python繪制圓柱體示的具體代碼,供大家參考,具體內(nèi)容如下
#!/usr/bin/env python import vtk # 參考的C++版本源碼及解釋 感謝原作者 # http://blog.csdn.net/www_doling_net/article/details/8536376 def main(): cylinder = vtk.vtkCylinderSource() cylinder.SetHeight(3.0) # 設(shè)置柱體的高 cylinder.SetRadius(1.0) # 設(shè)置柱體橫截面的半徑 cylinder.SetResolution(6) # 設(shè)置柱體橫截面的等邊多邊形的邊數(shù) cylinderMapper = vtk.vtkPolyDataMapper() # 渲染多邊形幾何數(shù)據(jù) cylinderMapper.SetInputConnection(cylinder.GetOutputPort()) # VTK可視化管線的輸入數(shù)據(jù)接口 ,對應(yīng)的可視化管線輸出數(shù)據(jù)的接口為GetOutputPort(); cylinderActor = vtk.vtkActor() cylinderActor.SetMapper(cylinderMapper) # 設(shè)置生成幾何圖元的Mapper。即連接一個(gè)Actor到可視化管線的末端(可視化管線的末端就是Mapper)。 renderer = vtk.vtkRenderer() # 負(fù)責(zé)管理場景的渲染過程 renderer.AddActor(cylinderActor) renderer.SetBackground(0.1, 0.2, 0.4) renWin = vtk.vtkRenderWindow() # 將操作系統(tǒng)與VTK渲染引擎連接到一起。 renWin.AddRenderer(renderer) renWin.SetSize(300, 300) iren = vtk.vtkRenderWindowInteractor() # 提供平臺獨(dú)立的響應(yīng)鼠標(biāo)、鍵盤和時(shí)鐘事件的交互機(jī)制 iren.SetRenderWindow(renWin) # 交互器樣式的一種,該樣式下,用戶是通過控制相機(jī)對物體作旋轉(zhuǎn)、放大、縮小等操作 style = vtk.vtkInteractorStyleTrackballCamera() iren.SetInteractorStyle(style) iren.Initialize() iren.Start() # Clean up del cylinder del cylinderMapper del cylinderActor del renderer del renWin del iren main()
效果圖:
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
python實(shí)現(xiàn)windows下文件備份腳本
這篇文章主要為大家詳細(xì)介紹了python實(shí)現(xiàn)windows下文件備份的腳本,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-05-05Python標(biāo)準(zhǔn)庫之urllib和urllib3的使用及說明
這篇文章主要介紹了Python標(biāo)準(zhǔn)庫之urllib和urllib3使用及說明,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-12-12python將三維數(shù)組展開成二維數(shù)組的實(shí)現(xiàn)
今天小編就為大家分享一篇python將三維數(shù)組展開成二維數(shù)組的實(shí)現(xiàn),具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-11-11