PythonOCC 3D图形库学习—导入STEP模型
PythonOCC comes with importers/exporters for the most commonly used standard data files format in engineering: STEP, IGES, STL (ascii/binary) and VRML. After the import is successfull, the resulting shape can be handled as a native topology/geometry, i.e. you can use boolean operations, shape fixing, traverse topology etc. PythonOCC中含有导入/导出模块,可以处理STEP,IGES,STL等格式的CAD模型.
STEP file is a CAD file format, usually used to share 3D models between users with different CAD systems. CAD file interchangeability is a huge, huge headache in the field, so it has to be make uniform. Standard ISO 10303 is trying to solve this problem. This standard is informally known as “STEP”, which stands for “Standard for the Exchange of Product model data”. STEP-file (ISO 10303-21) is implementation method of STEP standard that can represent 3D object in Computer-aided design (CAD) and related information.
各种CAD软件一般都使用自己定义的格式存储模型,因此造成数据交换困难,比如在UG里面创建的三维模型不能直接导入到Solidworks中。因此CAD数据交换标准之一的STEP格式被制定出来,使用任何的主流三维设计软件Peo/E、UG、CATIA、Solidworks等都可以直接打开STEP格式的文件(*.step, *.stp)
下面使用PythonOCC导入飞行器STEP格式的三维模型并显示出来(模型下载网址:https://grabcad.com/library):
'''
You can translate a STEP file into an OCCT shape in the following steps:
1.load the file,
2.check file consistency,
3.set the translation parameters,
4.perform the translation,
5.fetch the results.
''' import sys
from OCC.Display.SimpleGui import init_display
from OCC.IFSelect import IFSelect_RetDone,IFSelect_ItemsByEntity # Reads STEP files, checks them and translates their contents into Open CASCADE models
from OCC.STEPControl import STEPControl_Reader # Creates a reader object with an empty STEP mode
step_reader = STEPControl_Reader() # Loads a file and returns the read status
status = step_reader.ReadFile('Drone.step') # check status
if status == IFSelect_RetDone: # RetDone : normal execution with a result
# Checking the STEP file
# Error messages are displayed if there are invalid or incomplete STEP entities
step_reader.PrintCheckLoad(True, IFSelect_ItemsByEntity) # Performing the STEP file translation
step_reader.TransferRoot() # Each successful translation operation outputs one shape
# Returns the shape resulting from a translation
shape = step_reader.Shape()
else:
print("Error: can't read file.")
sys.exit(0) # initializes the display
display, start_display, add_menu, add_function_to_menu = init_display() # Then the shape is sent to the renderer
display.DisplayShape(shape, update=True) # enter the gui mainloop
start_display()
苏30:
F-22 猛禽:
大疆phantom3:
参考:
http://www.opencascade.com/doc/occt-6.9.1/overview/html/occt__tutorial.html
http://www.opencascade.com/doc/occt-6.9.0/refman/html/class_s_t_e_p_control___reader.html
PythonOCC 3D图形库学习—导入STEP模型的更多相关文章
- PythonOCC 3D图形库学习—创建立方体模型
Open CASCADE(简称OCC)平台是是一个开源的C++类库,OCC主要用于开发二维和三维几何建模应用程序,包括通用的或专业的计算机辅助设计CAD系统.制造或分析领域的应用程序.仿真应用程序或图 ...
- PV3D学习笔记-导入DAE模型
网上关于PV3D导入DAE模型的例子都非常多,可惜我研究了半天,一个都没成功,或者是破面问题,或者是贴图不显示,再或者贴图乱掉了.今天晚上终于搞定,心得发上来. 制作模型的软件是SketchUp ...
- Unity 3d导入3dMax模型 产生若干问题
Unity 3d导入3dMax模型 会产生若干问题,按照官方 的说明,将max 模型导成fbx文件 导入untiy似乎也不能解决 1.x轴向偏转3dmax模型导入后自动有一个x轴270度的偏转,巧合的 ...
- Unity3D游戏开发从零单排(五) - 导入CS模型到Unity3D
游戏动画基础 Animation组件 Animation组件是对于老的动画系统来说的. 老的动画形同相应的动画就是clip,每一个运动都是一段单独的动画,使用Play()或CrossFade(),直接 ...
- 用scikit-learn学习LDA主题模型
在LDA模型原理篇我们总结了LDA主题模型的原理,这里我们就从应用的角度来使用scikit-learn来学习LDA主题模型.除了scikit-learn, 还有spark MLlib和gensim库 ...
- ICML 2018 | 从强化学习到生成模型:40篇值得一读的论文
https://blog.csdn.net/y80gDg1/article/details/81463731 感谢阅读腾讯AI Lab微信号第34篇文章.当地时间 7 月 10-15 日,第 35 届 ...
- 使用keras导入densenet模型
从keras的keras_applications的文件夹内可以找到内置模型的源代码 Kera的应用模块Application提供了带有预训练权重的Keras模型,这些模型可以用来进行预测.特征提取和 ...
- opengl导入obj模型
在经过查阅各种资料以及各种bug之后,终于成功的实现了导入基本的obj模型. 首相介绍一下什么是obj模型 一.什么是OBJ模型 obj文件实际上是一个文本文档,主要有以下数据,一般可以通过blend ...
- Django:学习笔记(7)——模型进阶
Django:学习笔记(7)——模型进阶 模型的继承 我们在面向对象的编程中,一个很重要的的版块,就是类的继承.父类保存了所有子类共有的内容,子类通过继承它来减少冗余代码并进行灵活扩展. 在Djang ...
随机推荐
- 深入了解webservice_概念总结
最近公司需要对java web端的第三方接口进行测试,使用WebService+TestNG实现,TsetNg是常用的自动化测试框架,这就不介绍了. WebService是一种跨编程语言和跨操作系统平 ...
- 由Unicode编码想到弄懂编码表
test unicode好 007400650073007400200075006E00690063006F00640065597D 这是一个Unicode编码,一共六七万的汉字,可以说Unicode ...
- fork系统调用(转载)
(1) fork系统调用说明 fork系统调用用于从已存在进程中创建一个新进程,新进程称为子进程,而原进程称为父进程.fork调用一次,返回两次,这两个返回分别带回它们各自的返回值,其中在父进程中的返 ...
- OpenMP的调度
schedule(static, size) 这是静态调度,如果没有设置size, 默认是根据任务书来决定, 比如我电脑是8核,有26个任务,那么分配后结果是4 4 3 3 3 3 3 3. 因为先分 ...
- OpenStack 计算节点删除
前提 计算节点中一个僵尸计算节点存在,而里面的CPU数目在总物理CPU中,导致认为当前能创建实例.而实际没有这么多资源. 其中node-11为僵尸节点. 原因 删除计算节点不能直接格式化该服务器,否则 ...
- 通过HP Loadrunner VuGen来录制安卓的应用
作者:Richard Pal 来自:perftesting 翻译:Elaine00 通过这篇文章,我将介绍如何通过HP Loadrunner VuGen来测试一个安卓应 ...
- SDK Manager failed to install 'java.exe' locking directory
转自:http://stackoverflow.com/questions/13587478/sdk-manager-failed-to-install-java-exe-locking-direct ...
- 161115、MyBatis 通过包含的jdbcType类型
MyBatis常用jdbcType类型 BIT FLOAT CHAR TIMESTAMP OTHER UNDEFINEDTINYI ...
- Web SQL
HTML5本地存储——Web SQL Database 基于 HTML5 中的 Web SQL Database 来构建应用程序 前端HTML5几种存储方式的总结 <!DOCTYPE HTML& ...
- HDU 5961:传递(暴搜)
http://acm.hdu.edu.cn/showproblem.php?pid=5961 题意:中文题意.给出两个图,判断这个两个图是否都是传递的.注意一下传递的定义要看清,一开始没看清连样例都看 ...