日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

PythonOCC 3D图形库学习—创建立方体模型

發布時間:2023/12/18 python 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 PythonOCC 3D图形库学习—创建立方体模型 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Open CASCADE(簡稱OCC)平臺是是一個開源的C++類庫,OCC主要用于開發二維和三維幾何建模應用程序,包括通用的或專業的計算機輔助設計CAD系統、制造或分析領域的應用程序、仿真應用程序或圖形演示工具。

PythonOCC是對Open CASCADE的封裝。PythonOCC按照官方描述:3D CAD/CAE/PLM DEVELOPMENT FRAMEWORK FOR THE PYTHON PROGRAMMING LANGUAGE. 即用于開發CAD/CAE/CAM程序的一個Python框架。PythonOCC的下載地址為:http://www.pythonocc.org/download/

學習一個框架先從最簡單的"Hello world"程序開始,下面用PythonOCC創建一個最簡單的立方體并顯示出來。

1 ''' 2 This examples creates and displays a simple box. 3 ''' 4 5 # The first line loads the init_display function, necessary to 6 # enable the builtin simple gui provided with pythonocc 7 from OCC.Display.SimpleGui import init_display 8 9 # Then we import the class that instanciates a box 10 # Here the BRepPrimAPI module means Boundary Representation Primitive API. 11 # It provides an API for creation of basic geometries like spheres,cones etc 12 from OCC.BRepPrimAPI import BRepPrimAPI_MakeBox 13 14 # Following line initializes the display 15 # By default, the init_display function looks for a Qt based Gui (PyQt, PySide) 16 display, start_display, add_menu, add_function_to_menu = init_display() 17 18 # The BRepPrimAPI_MakeBox class is initialized with the 3 parameters of the box: widht, height, depth 19 my_box = BRepPrimAPI_MakeBox(10., 20., 30.).Shape() 20 21 # Then the box shape is sent to the renderer 22 display.DisplayShape(my_box, update=True) 23 24 # At last, we enter the gui mainloop 25 start_display()

顯示結果如下,按鍵盤上的W,S,H鍵可以在線框模型,面模型和消隱線模型之間切換。按住左鍵移動鼠標可以旋轉物體,鼠標中鍵用于縮放,按住鼠標中鍵可以平移物體

參考:

http://www.pythonocc.org/

http://www.vrplumber.com/py3d.py

https://github.com/tpaviot/pythonocc-core/blob/5b7ac9167e50e302cea534c5c7777ca2432f6d09/doc/examples/helloworld.rst

轉載于:https://www.cnblogs.com/21207-iHome/p/5241151.html

總結

以上是生活随笔為你收集整理的PythonOCC 3D图形库学习—创建立方体模型的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。