python簡單繪圖,python畫圓柱體,python繪制圓柱體的方法

 2023-10-08 阅读 26 评论 0

摘要:本文實例為大家分享了python繪制圓柱體示的具體代碼,供大家參考,具體內容如下#!/usr/bin/env pythonpython簡單繪圖?import vtk# 參考的C++版本源碼及解釋 感謝原作者# http://blog.csdn.net/www_doling_net/article/details/8536376圓柱體可以畫出什么

本文實例為大家分享了python繪制圓柱體示的具體代碼,供大家參考,具體內容如下

#!/usr/bin/env python

python簡單繪圖?import vtk

# 參考的C++版本源碼及解釋 感謝原作者

# http://blog.csdn.net/www_doling_net/article/details/8536376

圓柱體可以畫出什么圖形?def main():

cylinder = vtk.vtkCylinderSource()

cylinder.SetHeight(3.0) # 設置柱體的高

用圓柱可以畫出圓形對嗎?cylinder.SetRadius(1.0) # 設置柱體橫截面的半徑

cylinder.SetResolution(6) # 設置柱體橫截面的等邊多邊形的邊數

cylinderMapper = vtk.vtkPolyDataMapper() # 渲染多邊形幾何數據

python編程、cylinderMapper.SetInputConnection(cylinder.GetOutputPort()) # VTK可視化管線的輸入數據接口 ,對應的可視化管線輸出數據的接口為GetOutputPort();

cylinderActor = vtk.vtkActor()

cylinderActor.SetMapper(cylinderMapper) # 設置生成幾何圖元的Mapper。即連接一個Actor到可視化管線的末端(可視化管線的末端就是Mapper)。

renderer = vtk.vtkRenderer() # 負責管理場景的渲染過程

renderer.AddActor(cylinderActor)

renderer.SetBackground(0.1, 0.2, 0.4)

renWin = vtk.vtkRenderWindow() # 將操作系統與VTK渲染引擎連接到一起。

renWin.AddRenderer(renderer)

renWin.SetSize(300, 300)

iren = vtk.vtkRenderWindowInteractor() # 提供平臺獨立的響應鼠標、鍵盤和時鐘事件的交互機制

iren.SetRenderWindow(renWin)

# 交互器樣式的一種,該樣式下,用戶是通過控制相機對物體作旋轉、放大、縮小等操作

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()

效果圖:

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持。 ad51e517755f8fd6a7ec83ced4ecfaf3.png

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://808629.com/135927.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 86后生记录生活 Inc. 保留所有权利。

底部版权信息