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 ...
随机推荐
- nginx在windwos中的使用
本文章参考了 nginx for windows的介绍:http://nginx.org/en/docs/windows.html 你从官网上下载到的是一个 zip 格式的压缩包,首先要把压缩包解压. ...
- Controller 接口控制器详解
Controller 控制器,是 MVC 中的部分 C,为什么是部分呢?因为此处的控制器主要负责功能处理部分:1.收集.验证请求参数并绑定到命令对象:2.将命令对象交给业务对象,由业务对象处理并返回模 ...
- OpenStack 服务状态检查
openstack服务不正常 使用命令 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 [root@node-5 TimaIaas]# nova- ...
- 解决Android SDK Manager更新下载速度慢
1.在Host文件加上 203.208.46.146 www.google.com 74.125.113.121 developer.android.com 203.208.46.146 dl.goo ...
- Error while trying to retrieve text for error ORA-01019 的解决办法
这个问题涉及到 64 位的oracle服务, 和32位的客户端导致的问题. 环境如下: win8.1 + 64位oracle 11.1 做服务器, 客户端由于采用32位程序,不支持64位的oracle ...
- 使用 TFDConnection 的 pooled 连接池
从开始看到这个属性,就一直认为他可以提供一个连接池管理功能, 苦于文档资料太少, 甚至在帮助中对该属性的使用都没有任何介绍,如果你搜索百度,也会发现基本没资料. 最后终于在其官方网站看到了其完整相关的 ...
- 对EJB返回的AaaryList显示到table的处理方法
1. ArrayList --> Object[] ArrayList x = new ArrayList(); int i = x.size(); ...
- 【Pro ASP.NET MVC 3 Framework】.学习笔记.3.MVC的主要工具-单元测试
IProductRepository接口定义了一个仓库,我们通过它获得.更新Product对象.IPriceReducer接口指定了一个功能,它将要对所有的Products实施,通过一个参数,降低他们 ...
- activeMQ下载,安装,启动,关闭
1.新建一个文件夹activeMQ mkdir /server 2.授权 chmod 777 /server 3.下载activeMQ安装包,拷贝到/activeMQ目录下 apache-a ...
- Mysql密码恢复
由于种种原因,Mysql root用户的密码可能被恶意篡改,这个时候就需要对Mysql进行密码恢复了.大致步骤如下: 1.修改MySQL的登录设置: # vi /etc/my.cnf 在[mysqld ...