Open Cascade手册(8)
open cascade 基础
Open Cascade 基础1. 介绍在当今的工程设计和制造行业中,三维建模和仿真技术被广泛应用,而开源的 CAD/CAM/CAE 评台 Open Cascade 作为一种强大的工具,在这一领域中表现出了巨大的潜力。
本文将重点探讨 Open Cascade 的基础知识和应用,以便读者能够更好地理解并运用这一技术。
2. Open Cascade 的概述Open Cascade 是一种开源的三维 CAD/CAM/CAE 开发评台,它提供了一整套的软件组件、工具和库,用于构建各种涉及三维建模、几何处理、网格生成、可视化和仿真的应用程序。
Open Cascade 基于C++ 开发,并提供了丰富的 API,用户可以在其基础上进行二次开发和定制化。
3. Open Cascade 的核心模块Open Cascade 的核心模块包括几何建模内核、数据交换模块、可视化模块、网格处理模块等。
其中,几何建模内核是 Open Cascade 最重要的组成部分之一,它包含了丰富的几何算法和数据结构,可以对各种几何实体进行建模、计算和分析。
4. Open Cascade 的应用领域Open Cascade 在工程设计、制造和仿真领域有着广泛的应用。
它可以用于快速原型制作、产品设计、模具设计、数值控制加工、有限元分析等方面。
由于其开源的特性,Open Cascade 还在学术研究领域中被广泛应用,许多大学和研究机构都在利用 Open Cascade 进行各种研究项目。
5. 个人观点和理解在我看来,Open Cascade 提供了一种非常便捷和灵活的方式,让工程师和研究人员可以更好地应用三维建模和仿真技术。
通过学习和掌握 Open Cascade,我们能够更好地理解和把握三维几何建模的原理和方法,并且能够更自由地进行定制化开发,满足不同应用场景的需求。
6. 总结和回顾通过本文的介绍,我们对 Open Cascade 的基础知识有了更深入的了解。
Open_CASCADE学习笔记-句柄
OPEN CASCADE学习笔记——句柄著: Roman Lygin译:George Feng这是一篇关于开源三维建模软件O P E N C A S C A D E内核的博文:R O M A N L Y G I N是O P E N C A S C A D E的前程序开发员和项目经理,曾经写过许多关于该开源软件开发包的深入文章,可以在他的博客(H T T P://O P E N C A S C A D E.B L O G S P O T.C O M)上面找到这些文章。
序在OpenCascade的论坛上知道了Roman Lygin在他的博客上写了Open CASCADE notes系列文章,但是却无法访问他的博客,幸而百度文库已经收录了Topology and Geometry和Surface Modeling两篇文章,拜读之后获益良多。
如果大家发现文中翻译有错误或不足之处,望不吝赐教,可以发到我的邮箱fenghongkui@,十分感谢。
2012年6月28日星期四译者案:句柄是某个对象的一种标号,它是一个数值,它不是指针,根据指针可以知道对象在内存中的位置,但是通过句柄却不能直接更改内存中的对象,这事实上对于内存中的对象形成了一种保护。
中文中句柄这个词应该是来源于手柄的演化,利用手柄可以拎起来皮箱、包裹、茶壶等,就是说通过手柄可以控制一个对象,而计算机语言中的句柄却是用来“拎”(间接访问)内存中或者其他设备对象的。
我的第一篇文章,引言我也成为一个博友了,这是我第一次发博文,所以我对这种发文方式没有概念,也不知道是否有效。
让我们走着瞧吧。
我曾经在Open CASCADE(OCC)工作了7年时间,2004年离开,然后去了Intel,在那一直工作到现在。
在OCC的那些年的经历是非常珍贵的,我做过软件开发和项目管理,客户关系维护,与来自于各地和具有各种文化背景的人一起工作。
从1997年开始,我就在CAD数据交换小组作为软件开发工程师工作,我觉得这非常幸运,因为这使我可以学习到很多OCC代码,因为数据交换使用了大量的OCC算法。
Open+CASCADE中文教程
目录更多教程请到/hoya5121/category/556157.aspx 1. 项目概览 (4)1.1. 先决条件 (4)1.2. 项目 (4)1.3. 项目说明 (4)2. 技术描述 (6)2.1. 点 (6)2.2. 几何 (7)2.3. 拓扑 (8)2.4. 完整描述 (10)3. 构建主体 (12)3.1. 柱体 (12)3.2. 倒圆角 (13)3.3. 瓶颈 (15)3.4. 空洞 (16)4. 构建螺纹 (19)4.1. 创建表面 (19)4.2. 2D曲线 (19)4.3. 边框 (23)4.4. 螺纹 (24)5. 组合部件 (26)6. 附录 (27)1. 项目概览这个教程将教你使用OCC建立3D模型。
这个教程的目的不是描述所有的OCC类,而是让你开始思考OCC这个工具。
1.1.先决条件这个教程假设你已经有了C++的经验。
因为OCC是一个用C++设计的高性能建模库。
这样的组合将使你能够创建健壮的应用程序。
1.2. 项目下图是使用这个3D几何建模库提供的方法创建的一个瓶子:本教程将一步一步的教你创建这样一个瓶子。
你也可以在OCC安装目录中找到教程的源码(Tutorial/src/MakeBottle.cxx.)1.3.项目说明瓶子的详细参数参数参数名称参数值瓶高MyHeight 70mm瓶宽MyWidth 50mm瓶厚MyThickness 30mm另外我们将采用笛卡尔坐标系的原点做为瓶子的中心建立这个模型需要的四个步骤• 构建瓶子的轮廓• 构建瓶子的主体• 构建瓶颈上的螺纹• 组合部件2. 描述2.1. 点创建瓶子轮廓,首先要在XOY平面上创建特征点(下图)。
这些点将用来定义几何体的轮廓。
在OCC里有2个类可以用来描述3D坐标点:• gp_Pnt 类• Geom_CartesianPoint 类(句柄操作)这里句柄是一种提供自动内存管理的智能指针。
如何选择最合适类,考虑下列因素:• gp_Pnt 通过值操作。
Open Cascade手册(15)
Foundation Classes Modeling Algorithms Visualization Application Framework Data Exchange Building tools 3rd Party Products Samples and Tools Warnings Products
Open CASCADE Technology Products
Open CASCADE Technology
Highlights
Open CASCADE Support of UTF8 encoding for extended strings, and Unicode symbols in IGES Next step in thread-safety: protection against concurrent construction / destruction of Handle objects Improved compatibility with STL and Windows-specific code Multiple new features introduced in visualization module New visualization library NIS (New Interactive Service) New standard attributes and numerous improvements in OCAF Integrated code changes made by OCC users for MacOS X and FreeBSD porting Improved support of perspective view in Open CASCADE viewer New version of the OCAF binary persistence format The functionality of reading/writing VRML2.0 files has been implemented The definitions of Standard_CString and Standard_ExtString (typedefs) have been changed to be const: from char * (or short *) to const char * (or const short *) New supported platforms : Windows Vista, Mandriva2006, 2007, 2008, Debian Etch, Red Hat Enterprise 4.0 New supported compiler: gcc 4.0-4.2, Visual C++ 8.0
OpenCascade中文帮助文档
1.2.3 持久化和数据模式 数据模式是应用程序用来存储数据的一种结构,由一些持久类构成。 一个对象若可以被永久存储,则是持久的。持久对象可以被它的创建程序或
其它程序在以后的时间里再次使用。 要 想 使 一 个 对 象 在 CDL 中 是 持 久 的 , 必 须 声 明 它 的 类 型 继 承 自
例 2.1:
class Array1OfReal instantiates Array1 from TCollection (Real);
这 个 声 明 位 于 TColStd 包 的 一 个 CDL 文 件 中 。 它 定 义 了 一 个 新 的 类 TColStd_Array1OfReal。该类是通用类 TCollection_Array1 的一个实例,并且参 数类型指定为实型。
通过值处理的类型首先有基本类型,如布尔类型、字符型、整型、实型等。 通过句柄处理的类型变量,如果它不指向任何对象,那我们就说它是空的。要引 用一个对象,我们就得用它的一个构造函数实例化该对象,如例 2.3。
例 2.3:
Handle(myClass) m = new myClass;
在 OCC 中,句柄是一些特殊类,它们以引用的方式对动态存储对象进行安 全处理。句柄提供了一种引用计算机制,通过这种机制,当对象不被引用时,可 以自动析构对象。
1.3 本章小结
本章用面向对象方法和软件工程思想从整体上分析了 OCC 的体系结构。整 个 OCC 包含五个模块;模块中包含工具箱;工具箱中包含包;包中包含类;类 是 OCC 软件的最基本要素。
本章还介绍了 OCC 的几个基本概念:类、泛化、数据类型的分类、持久化 和数据模式。与 C++类的命名不同,OCC 有自己的命名方法。OCC 中类分为普 通类、推迟类和通用类三种,分别对应 C++中的具体类、抽象类和模板类。OCC 的数据可以分为句柄处理类型和值处理类型两种。OCC 的持久化和数据模式与 一般软件的原理相同,不同的是:为了使对象持久化,需要声明该对象是由 Standard_Persistent 类或其派生类派生的。
opencascade 手册
opencascade 手册OpenCascade手册OpenCascade是一套面向CAD/CAE应用程序开发的开源工具包。
它提供了丰富的几何建模功能和数据交换能力,允许开发人员构建高度灵活和可扩展的CAD/CAE应用。
1. 简介OpenCascade是一个基于C++的开源工具包,旨在提供一套强大的几何建模功能。
它由法国的OpenCascade公司开发,并于1999年首次发布。
OpenCascade使用B-样条曲线和曲面来表示几何实体,并提供了一系列操作和算法来实现对这些实体的操作和处理。
2. 功能特点OpenCascade提供了丰富的几何建模功能,包括创建、编辑和操作各种几何实体,如点、线、圆、椭圆、曲线、曲面、体等。
它支持实体的几何和拓扑属性,如位置、旋转、缩放、倾斜、厚度、颜色等。
此外,OpenCascade还支持各种几何运算,如裁剪、补丁、布尔运算、偏差、投影等。
3. 应用领域OpenCascade广泛应用于CAD/CAE领域,包括计算机辅助设计、计算机辅助工程、工业设计等。
它被用于开发各种CAD软件,如CATIA、SolidWorks、AutoCAD等,以及模拟和仿真软件,如Ansys、Simulink等。
4. 使用方法使用OpenCascade进行几何建模需要以下步骤:(1) 导入OpenCascade库。
(2) 创建几何实体,如点、线、曲线等。
(3) 进行几何操作,如裁剪、布尔运算等。
(4) 导出生成的几何实体。
以下是一个简单的示例代码,演示了如何使用OpenCascade创建一个三维立方体并导出到文件:```#include <TopoDS.hxx>#include <BRepPrimAPI_MakeBox.hxx>#include <BRepTools.hxx>int main(){TopoDS_Shape shape = BRepPrimAPI_MakeBox(10, 10, 10).Shape();BRepTools::Write(shape, "cube.brep");return 0;}```在这个示例中,我们使用`BRepPrimAPI_MakeBox`类创建了一个10x10x10的立方体,并使用`BRepTools::Write`函数将生成的几何实体导出到文件"cube.brep"。
OpenSCAD快速使用手册
intersection() //得出多个多面体相交的部分,(与运算)
操作字符,标记出指定多边形,以方便调整 * 隐藏 ! 仅显示,不生成 # 高亮显示 % 透明显示
数学函数 abs sign acos asin atan atan2 sin cos floor round ceil ln len log lookup min max pow sqrt exp rands 其他 echo(…) str(…) for (i = [start:end]) { … } //for 循环 for (i = [start:step:end]) { … } for (i = […,…,…]) { … } intersection_for(i = [start:end]) { … } intersection_for(i = [start:step:end]) { … } intersection_for(i = […,…,…]) { … } if (…) { … } assign (…) { … } search(…) import("….stl") //导入 stl 模型 linear_extrude(height,center,convexity,twist,slices) //挤出 rotate_extrude(convexity) surface(file = "….dat",center,convexity)
projection(cut) //投影 render(convexity) 特殊变量 $fa 最小角度 $fs 最小长度 $fn 最小分段 $t 动画分步
4,变形translate([,y,z]) //依照[x,y,z]响量进行平移
rotate([x,y,z]) //围绕 XYZ 轴,分别作 x,y,z 度的旋转。
opencascade-使用指南教学提纲
Standard Types
II Notion Of Handles
What Is A Handle In a concept of Object Oriented Language,
an object is an instance of a data type. The definition of this object determines the way it can be used.
Data types fall into two categories according to the way they are manipulated :
either by value, or by reference (pointer).
C++ usual problems linked to usage of pointers are :
Each module contains several libraries, each library contains classes grouped into packages :
Directories Structure
What You Should Know
To pass through the training successfully it is necessary to know :
Syntax difficulties : Where do I put "*", "&", etc. ?
Management difficulties : When should I delete my objects ?
To cope with the last issue, Open CASCADE Technology provides so called Handle mechanism that is an implementation of smart pointer mechanism. With this mechanism, referenced objects created on the heap are automatically destroyed when no longer in use.
Open_CASCADE学习笔记-曲面建模
缺省情况下,扫略曲面会生成 B 样条曲面,可以是有理样条曲面也可以是多项 式样条曲面,这依赖于 Perform()方法中的参数。假如你想生成基本曲面(圆环面 torus,圆柱面 cylinder,球面 sphere 等),当曲线配置允许的情况下(when curves configuration allows),可以调用函数 GenerateParticularCase(),并将参数设置 为 Standard_True。
2012 年 6 月 28 日星期四
第 1 节 曲面建模(直纹曲面)
曲面建模是任意一款三维几何建模软件的基本特性。Open CASCADE(OCC)提供 了一组基本的曲面(平面、锥面、球面等),Bezier 和 B-样条曲面,回转曲面、拉 伸和偏移曲面(offset surfaces)。将参数空间的底层曲面剪裁可以得到剪裁曲面 (trimmed surface)。 Open CASCADE 实现了 STEP 的一个子集(ISO 标准 10303,第 42 节),该子集用 于描述几何和拓扑体,虽然与 ISO 标准 10303 稍有不同。
成的曲面可以不同。 图 4 GeomFill_IsFixed 图 5 GeomFill_IsFrenet
图 6 GeomFill_IsConstantNormal
可以在 DRAW 程序中做一个测试,输入'sweep' 命令,并提供不同的参数选项。
管子 Pipes GeomFill_Pipe 提供了几种预定义的生成扫略曲面的方法: 1) 具有恒定截面的管子; 2) 具有恒定半径的圆管; 3) 具有恒定半径和两条轨道的圆管。
Open_CASCADE学习笔记-并行程序开发
OPEN CASCADE学习笔记——并行程序开发著: Roman Lygin译:George Feng这是一篇关于开源三维建模软件O P E N C A S C A D E内核的博文:R O M A N L Y G I N是O P E N C A S C A D E的前程序开发员和项目经理,曾经写过许多关于该开源软件开发包的深入文章,可以在他的博客(H T T P://O P E N C A S C A D E.B L O G S P O T.C O M)上面找到这些文章。
序在Open Cascade的论坛上知道了Roman Lygin在他的博客上写了Open Cascade notes系列文章,考虑到Open Cascade的学习资料并不多,于是从他的博客上下载了其中绝大部分文章,将其翻译过来以方便大家学习交流。
如果大家发现文中翻译有错误或不足之处,望不吝赐教,可以发到我的邮箱fenghongkui@,十分感谢。
2012年11月22日星期四第1节并行程序开发综述正如在之前的文章中提到的,我正在开发CAD Exchanger的ACIS导入部分,并且将其开发成并发执行的。
到目前为止结果非常理想(除了STL的流解析,因为之前文章中提到的Microsoft的bug,我安装了VS2008SP1正在检测这个错误是否得到了修正)。
所以我准备在这篇文章中分享我的经验,希望能够对其他开发人员有帮助(有关并行性问题在论坛上讨论的也越来越多)。
也希望Open CASCADE小组能够从我的发现中受益。
我之前已经简短介绍过几次并行应用程序开发了,再强调一下在多核时代并行应用程序将在某个时期成为主流,你最好现在就准备好应对这个趋势。
这对你的职业路线是非常有助的,这些能力将增强你的竞争力。
最近发布的Intel Parallel Studio(它已经成为我的工具箱的很重要的部分)可以调试多线程应用程序,简化开发人员的工作。
关于并行程序开发这个方面有很多基础书籍。
OpenCascade入门教程
OpenCascade入门教程TutorialMy First ApplicationVersion 6.3 / September 2008Table of Contents1.PROJECT OVERVIEW (4)1.1.P REREQUISITES (4)1.2.T HE PROJECT (4)1.3.P ROJECT S PECIFICATIONS (4)2.BUILDING THE PROFILE (6)2.1.D EFINING S UPPORT P OINTS (6)2.2.P ROFILE:D EFINING THE G EOMETRY (7) 2.3.P ROFILE:D EFINING THE T OPOLOGY (8)2.4.P ROFILE:C OMPLETING THE P ROFILE (10)3.BUILDING THE BODY (12)3.1.P RISM THE P ROFILE (12)3.2.A PPLYING F ILLETS (13)3.3.A DDING THE N ECK (15)3.4.C REATING A H OLLOWED S OLID (16)4.BUILDING THE THREADING (19)4.1.C REATING S URFACES (19)4.2.D EFINING 2D C URVES (19)4.3.B UILDING E DGES AND W IRES (23)4.4.C REATING T HREADING (24)5.BUILDING THE RESULTING COMPOUND (26)6.APPENDIX (27)4 Project Overview1. Project OverviewThis tutorial will teach you how to use Open CASCADE services to model a 3D object. The purpose ofthis tutorial is not to describe all Open CASCADE classes but to help you to start thinking in terms of the Open CASCADE tool.1.1. PrerequisitesThis tutorial assumes that you have experience in using and setting up C++.From a programming standpoint, Open CASCADE is designed to enhance your C++ tools with high performance modeling classes, methods and functions. The combination of all these resources will allow you to create substantial applications.1.2. The projectTo illustrate the use of classes provided in the 3D geometric modeling toolkits, you will create a bottle as shown:In the tutorial we will create, step-by-step, a function that will model a bottle as shown above. You will find the complete source code of this tutorial, including the very function MakeBottle in the distribution of Open CASCADE. The function body is provided in the file Tutorial/src/MakeBottle.cxx.1.3. Project SpecificationsWe first define the bottle specifications as follows:Object Parameter ParameterName Parameter Value Bottle height MyHeight 70mmBottle width MyWidth 50mm Bottle thickness MyThickness30mm为了演示3D 几何模型工具箱中类的使用丆你可以创建一个如下的瓶子。
OpenCascade中文帮助文档
例 2.2:
class MapOfReal instantiates Map from TCollection (Real,MapRealHasher);
这个声明位于 TColStd 中。它不仅定义了 TColStd_MapOfReal 类,也定义了 TColStd_MapIteratorOfMapOfReal 类(该类是通用类 TCollection_Map 的内嵌类 MapIterator 的一个实例)。内嵌类的实例独立于主类的实例,而决非绑定于它。 作为内嵌类,即使它们本身不是通用类,但是内嵌于通用类,它们也是通用的。
而面向对象的方法将数据及对数据的操作放在一起,作为一个相互依存、不 可分离的整体——对象。对同类型对象抽象出其共性,形成类。类中的大多数数 据,只能用本类的方法进行处理。类通过一个简单的外部接口与外界发生关系, 对象与对象之间通过消息进行通信[2]。这样,程序模块间的关系更为简单,程序 模块的独立性、数据的安全性就有了良好的保障,实现了“高内聚”“低耦合”。 另外,继承与多态性可以大大提高程序的可重用性,使得软件的开发和维护都更 为方便。
Standard_Persistent 类或其派生类。所有继承自 Standard_Persistent 类的类都是通 过引用处理的。
对于由 Standard_Storable 类派生出的所有类,它们的实例(对象)是不能被
单独存储的,但是可以作为持久对象的区域被存储。所有继承自 Standard_Storable 类的类,其对象都是通过值处理的。
通过值处理的类型首先有基本类型,如布尔类型、字符型、整型、实型等。 通过句柄处理的类型变量,如果它不指向任何对象,那我们就说它是空的。要引 用一个对象,我们就得用它的一个构造函数实例化该对象,如例 2.3。
Open Cascade手册(1)
$SSOLFDWLRQ)UDPHZRUNWhat is OCAF ?Purpose of OCAF (1)Overview of the Architecture (2)Getting Started (3)Benefits of OCAF (4)A Look Inside OCAFThe Design of OCAF (5)The Data Framework (8)Persistent Data Storage (11)Version 6.3 / September 2008Tour Opus 1277, Esplanade du Général de Gaulle92914 PARIS LA DEFENSEFRANCECopyright © 2008, by Open CASCADE S.A.S. PROPRIETARY RIGHTS NOTICE: All rights reserved. No part of this material may be reproduced or transmitted in any form or by any means, electronic, mechanical, or otherwise, including photocopying and recording or in connection with any information storage or retrieval system, without the permission in writing from Open CASCADE S.A.S. The information in this document is subject to change without notice and should not be construed as a commitment by Open CASCADE S.A.S. Open CASCADE S.A.S. assures no responsibility for any errors that may appear in this document. The software described in this document is furnished under a license and may be used or copied only in accordance with the terms of such a license. CAS.CADE and Open CASCADE are registered trademarks of Open CASCADE S.A.S. Other brand or product names are trademarks or registered trademarks of their respective holders.NOTICE FOR USERS:This User Guide is a general instruction for Open CASCADE study. It may be incomplete and even contain occasional mistakes, particularly in examples, samples, etc. Open CASCADE S.A.S. bears no responsibility for such mistakes. If you find any mistakes or imperfections in this document, or if you have suggestions for improving this document, please, contact us and contribute your share to the development of Open CASCADE Technology: bugmaster@What is OCAF ? Purpose of OCAFThe Open CASCADE Application Framework (OCAF) is an easy-to-use platformfor rapid ly develop ing sophisticated domain-specific design applications. A typicalapplication developed using OCAF deals with two or three-dimensional (2D or 3D)geometric modeling in trade-specific Computer Aided Design (CAD) systems,manufacturing or analysis applications, simulation applications or illustration tools.Developing a design application requires addressing many technical aspects. Inparticular, given the functional specification of your application, you must at least:n Design the architecture of the application — definition of the software components and the way they cooperaten Define the data model able to support the functionality required — a design application operates on data maintained during the whole end-user workingsessionn Structure the software in order toµsynchronize the display with the data — commands modifying objects must update the viewsµsupport generalized undo-redo commands — this feature has to be taken into account very early in the design processn Implement the function for saving the data — if the application has a long life cycle, the compatibility of data between versions of the application has to beaddressedn Build the application user interfaceBy providing architectural guidance and ready-to-use solutions to these issues,OCAF helps you to develop your application significantly faster: you concentrateon the application’s functionality.© Open CASCADE S.A. 1What is OCAF ?© Open CASCADE S.A. 2Overview of the ArchitectureOCAF provides you with an object-oriented Application-Document-Attributemodel. This consists of C++ class libraries. The main class, Application , is anabstract class in charge of handling documents during the working session.Services provided by this class include:nCreating new documents nSaving documents and opening them n Initializing document viewsThe document, implemented by the concrete class Document , is the container forthe application data. Its main purpose is to centralize notifications of data editingin order to provide Undo-Redo. Each document is saved in a single flat ASCII filedefined by its format and extension (a ready-to-use format is provided withOCAF).Application data are attributes, that is, instances of classes derived from theAttribute abstract class, organized according to the OCAF Data Framework.The OCAF Data Framework references aggregations of attributes usingpersistent identifiers in a single hierarchy (the Data Framework is described in thenext chapter, A Look Inside OCAF ). A wide range of attributes come with OCAF,including:nPrimitive attributes such as Integer, Real, Name and Comment nShape attribute containing the geometry of the whole model or elements of it n Other geometric attributes such as Datums (points, axis and plane) and Constraints such as tangent-to, at-a-given-distance, from-a-given-angle,concentric, etc.n Modeling step and Function attributes — the purpose of these attributes is to rebuild objects after they have been modified (parameterization of models)n Visualization attributes — these attributes allow data to be visualized in a 2D or 3D viewernUser attributes, that is, attributes typed by the application In addition, application-specific data can be added by defining new attributeclasses; naturally, this changes the standard file format. The only functions thathave to be implemented are:nCopying the attribute n Converting it from and to its persistent homolog (persistence is briefly presented in the paragraph Persistent Data Storage in the next chapter)Figure 1 below illustrates this architecture.What is OCAF ? Figure 1The Application-Document-Attribute modelNote As OCAF uses other modules of Open CASCADE — see the technical overview of Open CASCADE in the appendix — the Shape attribute is implemented withthe geometry supported by the Modeling Data module and the viewer is the oneprovided with the Visualization module. Modeling functions can be implementedusing the Modeling Algorithms module.Getting StartedAt the beginning of your development, you first define an application class byinheriting from the Application abstract class. You only have to create anddetermine the resources of the application for specifying the format of yourdocuments (you generally use the standard one) and their file extension.Then, you design the application data model by organizing attributes you chooseamong those provided with OCAF. You can specialize these attributes using theUser attribute. For example, if you need a reflection coefficient, you aggregate aUser attribute identified as a reflection coefficient with a Real attribute containingthe value of the coefficient (as such, you don’t define a new class).If you need application specific data not provided with OCAF, for example, toincorporate a finite element model in the data structure, you define a new attributeclass containing the mesh, and you include its persistent homolog in a new fileformat.© Open CASCADE S.A.3What is OCAF ?© Open CASCADE S.A. 4Once you have implemented the commands which create and modify the datastructure according to your specification, OCAF provides you, without anyadditional programming:nPersistent reference to any data, including geometric elements — several documents can be linked with such reference nDocument-View association n Ready-to-use functions such asµ Undo-redoµ Save and open application dataFinally, you develop the application’s graphical user interface using the toolkit ofyour choice, for example:nKDE Qt or GNOME GTK+ on Linux nMicrosoft Foundation Classes (MFC) on Windows nMotif on Sun n Other commercial products such as Ilog ViewsYou can also implement the user interface in the Java language using the Swing-based Java Application Desktop component (JAD) provided with OCAF.Benefits of OCAFAs you use the architecture provided by OCAF, the design of your application ismade easy: the application developer concentrates on the functionality instead ofthe underlying mechanisms required to support this functionality.Also, thanks to the coupling with the other Open CASCADE modules, yourapplication can rapidly be prototyped. In addition, the final application can bedeveloped by industrializing the prototype — you don’t need to restart thedevelopment from scratch.Last but not least, you base your application on an Open Source component: thisguarantees the perenniality of your development.A Look Inside OCAF The Design of OCAFReference-key modelIn most existing geometric modeling systems, the data are topology driven. Theyusually use a boundary representation (BRep), where geometric models aredefined by a collection of faces, edges and vertices, to which application data areattached. Examples of data include:n a colorn a materialn information that a particular edge is blendedWhen the geometric model is parameterized, that is, when you can change thevalue of parameters used to build the model (the radius of a blend, the thicknessof a rib, etc.), the geometry is highly subject to change. In order to maintain theattachment of application data, the geometry must be distinguished from otherdata.In OCAF, the data are reference-key driven. It is a uniform model in whichreference-keys are the persistent identification of data. All accessible data,including the geometry, are implemented as attributes attached to reference-keys.The geometry becomes the value of the Shape attribute, just as a number is thevalue of the Integer and Real attributes and a string that of the Name attribute.On a single reference-key, many attributes can be aggregated; the application canask at runtime which attributes are available. For example, to associate a textureto a face in a geometric model, both the face and the texture are attached to thesame reference-key.© Open CASCADE S.A. 5A Look Inside OCAF© Open CASCADE S.A. 6Figure 2Topologydriven versus reference-key driven approachesTopology driven Reference-key drivenTopological namingReference-keys can be created in two ways:nAt programming time, by the application n At runtime, by the end-user of the application (providing that you include this capability in the application)As an application developer, you generate reference-keys in order to givesemantics to the data. For example, a function building a prism may create threereference-keys: one for the base of the prism, a second for the lateral faces and athird for the top face. This makes up a semantic built-in the application’s prismfeature. On the other hand, in a command allowing the end-user to set a textureto a face he/she selects, you must create a reference-key to the selected face if ithas not previously been referenced in any feature (as in the case of one of thelateral faces of the prism).When you create a reference-key to selected topological elements (faces, edgesor vertices), OCAF attaches to the reference-key information defining the selectedtopology — the Naming attribute. For example, it may be the faces to which aselected edge is common to. This information, as well as information about theevolution of the topology at each modeling step (the modified, newed and deletedfaces), is used by the naming algorithm to maintain the topology attached to thereference-key. As such, on a parameterized model, after modifying the value of aparameter, the reference-keys still address the appropriate faces, even if theirgeometry has changed. Consequently, you change the size of the cube shown inthe figure 2 above, the user texture stay attached to the right face.A Look Inside OCAF© Open CASCADE S.A. 7Note As Topological naming is based on the reference-key and attributes such asNaming (selection information) and Shape (topology evolution information),OCAF is not coupled to the underlying modeling libraries. The only modelingservices required by OCAF are the following:nEach algorithm must provide information about the evolution of the topology (the list of faces modified, newed and deleted by the algorithm)n Exploration of the geometric model must be available (a 3D model is made of faces bounded by close wires, themselves composed by a sequence of edgesconnected by their vertices)Currently, OCAF uses the Open CASCADE modeling libraries.Aggregation of attributesTo design an OCAF-based data model, the application developer is encouragedto aggregate ready-to-use attributes instead of defining new attributes byinheriting from an abstract root class.There are two major advantages in using aggregation rather than inheritance:n As you don’t implement data by defining new classes, the format of saved data provided with OCAF doesn’t change; so you don’t have to write the Saveand Open functionsnThe application can query the data at runtime if a particular attribute is available Summaryn OCAF is based on a uniform reference-key model in which:µ Reference-keys provide persistent identification of dataµ Data, including geometry, are implemented as attributes attached toreference-keysµ Topological naming maintains the selected geometry attached toreference-keys in parameterized modelsn In many applications, the data format provided with OCAF doesn’t need to be extendednOCAF is not coupled to the underlying modeling librariesA Look Inside OCAF© Open CASCADE S.A. 8The Data FrameworkData structureThe OCAF Data Framework is the Open CASCADE realization of the reference-key model presented in the previous paragraph. It implements the reference-key as label objects, organized in a tree structure characterized by the following features:nA document contains only one tree of labels nEach label has a tag expressed as an integer value unique at its level in the tree nA label is identified by a string — the entry — built by concatenation of tags from the root of the tree, for example [0:1:2:1]nAttributes are of a type identified by a universal unique identifier (GUID)n Attributes are attached to labels; a label may refer to many attributes as long as each has a different GUIDAs such, each piece of data has a unique persistent address made up of the document path, its entry and the GUID of its class.For example, an application for designing coffee machines first allocates a label for the machine unit. It then adds sub-labels for the main features (glass coffee pot, water receptacle and filter) which it refines as needed (handle and reservoir of the coffee pot and spout of the reservoir). You now attach technical data describing the handle — its geometry and color — and the reservoir — its geometry and material. Later on, you can modify the handle’s geometry without changing its color — both remain attached to the same label.Figure 3 below illustrates this data structure.A Look Inside OCAF© Open CASCADE S.A. 9Figure 3The data structure of the coffee machineThe nesting of labels is key to OCAF. This allows a label to have its own structurewith its local addressing scheme which can be reused in a more complexstructure. Take, for example, the coffee machine. Given that the coffee pot’shandle has a label of tag [1], the entry for the handle in the context of the coffeepot only (without the machine unit) is [0:1:1]. If you now model a coffeemachine with two coffee pots, one at the label [1], the second at the label [4] inthe machine unit, the handle of the first pot would have the entry [0:1:1:1] (asin the Figure 3 above) whereas the handle of the second pot would be[0:1:4:1]. This way, we avoid any confusion between coffee pot handles.Note The purpose of the label hierarchy is to provide the data with persistentaddresses. In particular, applications which show the end-user the data in a tree-list view do not display this hierarchy. For that, an attribute (TreeNode ) which youinsert in the data structure is provided.Compound documentsAs the identification of data is persistent, one document can reference datacontained in another document, the referencing and referenced documents beingsaved in two separate files.Lets look at the coffee machine application again. The coffee pot can be placed inone document. The coffee machine document then includes an occurrence — apositioned copy — of the coffee pot. This occurrence is defined by an XLinkattribute (the eXternal Link) which references the coffee pot of the first documentA Look Inside OCAF(the XLink contains the relative path of the coffee pot document and the entry ofthe coffee pot data [0:1]).Figure 4The coffee machine compound documentIn this context, the end-user of the coffee machine application can open thecoffee pot document, modify the geometry of, for example, the reservoir, andoverwrite the document without worrying about the impact of the modification inthe coffee machine document. To deal with this situation, OCAF provides aservice which allows the application to check whether a document is up-to-date.This service is based on a modification counter included in each document: whenan external link is created, a copy of the referenced document counter isassociated to the XLink in the referencing document. Providing that eachmodification of the referenced document increments its own counter, we candetect that the referencing document has to be updated by comparing the twocounters (an update function importing the data referenced by an XLink into thereferencing document is also provided).© Open CASCADE S.A. 10A Look Inside OCAF© Open CASCADE 11Transaction mechanismThe Data Framework also provides a transaction mechanism inspired from database management systems: the data are modified within a transaction whichis terminated either by a Commit if the modifications are validated or by an Abort ifthe modifications are abandoned — the data are then restored to the state it wasin prior to the transaction. This mechanism is extremely useful for:nSecuring editing operations (if an error occurs, the transaction is abandoned and the structure retains its integrity)n Simplifying the implementation of the Cancel function (when the end-user begins a command, the application may launch a transaction and operatedirectly in the data structure; abandoning the action causes the transaction toAbort)nExecuting Undo (at commit time, the modifications are recorded in order to be able to restore the data to their previous state) The transaction mechanism consists simply of managing a backup copy of attributes. During a transaction, attributes are copied before their firstmodification. If the transaction is validated, the copy is destroyed. If thetransaction is abandoned, the attribute is restored to its initial value (whenattributes are added or deleted, the operation is simply reversed).Transactions are document-centered, that is, the application starts a transaction on a document. So, modifying a referenced document and updating one of itsreferencing documents requires two transactions, even if both operations aredone in the same working session.Persistent Data StorageIn OCAF, persistence, that is, the mechanism used to save a document in a file,is based on an explicit formal description of the data saved.When you open a document, the application reads the corresponding file and firstcreates a memory representation of it. This representation is then converted tothe application data model — the OCAF-based data structure the applicationoperates on. The file’s memory representation consists of objects defined byclasses known as persistent. The persistent classes needed by an application tosave its documents make the application’s data schema. This schema defines theway the data are organized in the file — the format of the data. In other words, thefile is simply an ASCII dump of the persistent data defined by the schema, thepersistent data being created from the application data model during the saveprocess.Only canonical information is saved. As a matter of fact, the application datamodel usually contains additional data to optimize processing. For example, theA Look Inside OCAF© Open CASCADE S.A. 12persistent Bézier curve is defined by its poles, whereas its data model equivalentalso contains coefficients used to compute a point at a given parameter. Theadditional data is calculated when the document is opened.The major advantages of this approach are the following:n Providing that the data format is published, files created by OCAF-based applications can be read without needing a runtime of the application(openness)nAlthough the persistence approach makes the data format more stable,OCAF provides a framework for managing compatibility of data betweenversions of the application — modification of the data format is supportedthrough the versioning of schema.OCAF includes a ready-to-use schema suitable for most applications. However, itcan be extended if needed. For that, the only things you have to do are:nTo define the additional persistent attributes n To implement the functions converting these persistent attribute to and from the application data model.Note Applications using compound documents extensively (saving data in many fileslinked together) should implement data management services. As a matter offact, it’s out the scope of OCAF to provide functions such as:nVersion and configuration management of compound documents n Querying a referenced document for its referencing documentsIn order to ease the delegation of document management to a data managementapplication, OCAF encapsulates the file management functions in a driver (themeta-data driver). You have to implement this driver for your application tocommunicate with the data management system of your choice.。
Open_CASCADE基础介绍
Open CASCADE基础介绍(1)一直在用OCC作项目,但这方面的中文资料很少,看来OCC在中国还不是十分普及;后来,项目中使用OCC和DirectX结合使用,取得了很好的效果;随着OCC6.3版本的推出,Open CASCADE在速度方面已有了很大的改变。
以下为一些OCC的基础知识,愿与各位OCC爱好者共同学习;一:OCC中的基础类:gp_Pnt在OCC中,gp_Pnt表示一个顶点,gp_Vec表示一个向量,可以用两个顶点来生成一个向量。
比如:gp_Pnt P1(0,0,0);gp_Pnt P2(5,0,0);gp_Vec V1 (P1,P2);向量有一个方法.IsOpposite(),可以用来测试两个向量的方向是相对还是平行;比如:gp_Pnt P3(-5,0,2);gp_Vec V2 (P1,P3);Standard_Boolean result =V1.IsOpposite(V2,Precision::Angular());另外向量还有一些重要方法:--Standard_Real Magnitude() const;计算向量的大小;--Standard_Real SquareMagnitude() const;计算向量的平方;--向量的加减乘除操作;--向量的单位化;--通过一个点,线,面得出其镜像的向量;--向量的旋转,平移,缩放;具体的函数名称可以看OCC的头文件说明;有时需要决定一组空间点是位于一个点;一条直线,或一个平面,或一个空间: OCC中提供了相应的算法;比如:TColgp_Array1OfPnt array (1,5); // sizing arrayarray.SetValue(1,gp_Pnt(0,0,1));array.SetValue(2,gp_Pnt(1,2,2));array.SetValue(3,gp_Pnt(2,3,3));array.SetValue(4,gp_Pnt(4,4,4));array.SetValue(5,gp_Pnt(5,5,5));GProp_PEquation PE (array,1.5 );if (PE.IsPoint()){ /* ... */} //是否是同一个点gp_Lin L;if (PE.IsLinear()) {L = PE.Line();} //是否位于一条直线上;if (PE.IsPlanar()){ /* ... */}//是否在一个平面内;if (PE.IsSpace()) { /* ... */}gp_Dir类:此类用来描述3D空间中的一个单位向量;常用方法:(1):IsEqual(const gp_Dir& Other,const Standard_Real AngularTolerance) const;两个单位向量是否相等;(2):IsNormal(const gp_Dir& Other,const Standard_Real AngularTolerance) const;两个单位向量的夹角是否是PI/2;(3):IsOpposite(const gp_Dir& Other,const Standard_Real AngularTolerance) const;两个单位向量是否方向相反;(4):IsParallel(const gp_Dir& Other,const Standard_Real AngularTolerance) const;两个单位向量夹角O或PI;(5):Angle(const gp_Dir& Other) const;求两个向量之间的夹角;(6):void CrossCross(const gp_Dir& V1,const gp_Dir& V2) ;计算三个向量之间的叉积;(7):Standard_Real Dot(const gp_Dir& Other) const;计算点积;(8):Standard_Real DotCross(const gp_Dir& V1,const gp_Dir& V2) const;计算叉积再点积;(9):gp_Dir Reversed() const;得到反方向,在OCC中用 gp_Lin2d 类,来生成一个二维空间的直线,有它的原点和单位向量;gp_Ax2d 类:通过原点和X方向单位和Y方向单位建立一个二维坐标系;利用sense参数可以决定是右手系还是左手系;可以利用平移、旋转、缩放、镜像来更改坐标系;类似地,gp_Ax3类:用来描述一个3D空间的坐标系。
open cascade occ 几何模型创建与删除操作
open cascade occ 几何模型创建与删除操作Open Cascade OCC(Open Cascade Technology)是一个开源的计算机辅助设计(CAD)和计算机辅助制造(CAM)软件开发平台,它提供了一套丰富的工具和算法,用于创建、编辑和处理几何模型。
在本文中,我们将详细介绍如何使用Open Cascade OCC进行几何模型的创建和删除操作。
创建几何模型为了创建几何模型,我们首先需要定义一些基本的几何实体,如点、线和面等。
Open Cascade OCC提供了一些类和函数来创建这些基本实体,并将它们组合成一个完整的几何模型。
1. 创建点要创建一个点,我们可以使用OccPt类的构造函数,并传入点的坐标信息。
例如,以下代码将创建一个位于(0, 0, 0)坐标的点:```gp_Pnt point(0, 0, 0);```2. 创建线在Open Cascade OCC中,线由两个点定义。
我们可以使用OccLIne类的构造函数来创建一条线,并传入起点和终点的坐标信息。
例如,以下代码将创建一条从点(0, 0, 0)到点(1, 1, 1)的直线:```gp_Pnt startPoint(0, 0, 0);gp_Pnt endPoint(1, 1, 1);OccLine line(startPoint, endPoint);```3. 创建面在Open Cascade OCC中,面由一系列边界上的点定义。
我们可以使用OccFace类的构造函数来创建一个面,并传入一个闭合的轮廓线,该轮廓线由一系列点组成。
例如,以下代码将创建一个包含三个点的三角形面:```gp_Pnt point1(0, 0, 0);gp_Pnt point2(1, 0, 0);gp_Pnt point3(0, 1, 0);OccEdge edge1(point1, point2);OccEdge edge2(point2, point3);OccEdge edge3(point3, point1);OccWire wire;wire.Add(edge1);wire.Add(edge2);wire.Add(edge3);OccFace face(wire);```删除几何模型在Open Cascade OCC中,要删除几何模型可以使用BRepAlgoAPI_Cut函数。
open cascade occ 几何模型创建与删除操作 -回复
open cascade occ 几何模型创建与删除操作-回复Open Cascade OCC(Open Cascade Technology)是一个开源的三维几何建模内核库,它提供了丰富的几何模型创建和删除操作的功能。
本文将一步一步回答“Open CASCADE OCC 几何模型创建与删除操作”的问题。
第一步:安装Open Cascade OCC要使用Open CASCADE OCC几何建模内核,首先需要下载并安装它。
你可以从Open Cascade官方网站(第二步:创建一个几何模型在Open Cascade OCC中,几何模型是通过一系列的几何操作来创建的。
以下是创建几何模型的一些常见操作:1. 创建点和线在Open Cascade OCC中,点和线是几何模型的基本构建块。
可以使用BRepBuilderAPI_MakePoint和BRepBuilderAPI_MakeEdge类来创建点和线。
例如,以下代码创建一个简单的线段:cppgp_Pnt start(0, 0, 0);gp_Pnt end(1, 1, 1);BRepBuilderAPI_MakeEdge line(start, end);2. 创建面在Open Cascade OCC中,面是由一组边组成的。
可以使用BRepBuilderAPI_MakeFace类来创建一个面。
例如,以下代码创建一个平面:cppBRepBuilderAPI_MakeFace face(line.Edge());3. 创建实体在Open Cascade OCC中,实体是由一组面组成的。
可以使用BRepBuilderAPI_MakeSolid类来创建一个实体。
例如,以下代码创建一个简单的立方体:cppTopoDS_Shape solid = BRepPrimAPI_MakeBox(1, 1, 1).Solid();第三步:对几何模型进行修改创建几何模型后,可以对它进行各种修改操作。
open cascade 基础
open cascade 基础Open Cascade基础Open Cascade是一个用于建模和仿真的开源软件开发工具包。
它提供了丰富的功能,可用于创建和编辑三维几何模型,进行几何分析,进行数值模拟和可视化等。
本文将介绍Open Cascade的基础知识,包括其背景、功能和应用领域等。
一、Open Cascade的背景及历史Open Cascade是由法国公司Open Cascade SAS开发和维护的开源软件工具包。
该公司成立于1998年,旨在开发和推广用于CAD(计算机辅助设计)、CAE(计算机辅助工程)和CAM(计算机辅助制造)的软件开发工具包。
Open Cascade软件工具包最初是从欧洲航空防务和航天工业中心(OCC)分离出来的,经过二十多年的发展和完善,成为了广泛使用的三维建模工具。
二、Open Cascade的核心功能1. 几何模型创建与编辑Open Cascade提供了强大的几何模型创建和编辑功能。
它支持多种几何实体,如点、线、曲线、曲面、体等,并提供了相关的操作和算法,例如旋转、平移、缩放、融合等。
使用Open Cascade,用户可以轻松创建和编辑复杂的几何模型。
2. 几何分析与处理Open Cascade还提供了丰富的几何分析和处理功能。
它支持部件间的布尔运算(如并集、交集、差集),可以计算几何实体的特征属性(如表面积、体积、质心等),并提供了用于几何修复和参数化等高级算法。
这些功能可用于CAD/CAM软件的开发和工程仿真等领域。
3. 数值模拟与仿真Open Cascade可与数值模拟软件集成,用于进行结构力学、流体力学、热传导等仿真分析。
它提供了各种算法和方法,例如有限元分析、有限差分法、边界元法等,以及模型导入/导出、网格生成和后处理等功能。
这使得Open Cascade成为了一种强大的仿真工具。
4. 可视化与渲染Open Cascade能够对三维模型进行可视化和渲染。
opencascad 原理
opencascad 原理OpenCASCAD 是一款开源的 CAD 模型库和工具集,它提供了一种基于 Python 的开放式 CAD 建模方法,使得用户可以更加方便地创建、编辑和共享 CAD 模型。
本篇文章将详细介绍 OpenCASCAD 的原理,包括其基本概念、工作原理、核心功能以及使用方法。
一、基本概念CAD(计算机辅助设计)是一种利用计算机系统辅助设计人员完成各种设计工作的技术。
CAD 模型是 CAD 系统的核心,它是对现实世界的一种抽象和数字化表达,用于指导实际生产、加工和制造。
OpenCASCAD 主要针对机械设计领域,提供了多种常用的 CAD 建模元素和工具。
二、工作原理OpenCASCAD 的工作原理主要分为以下几个步骤:1. 模型创建:用户可以使用 OpenCASCAD 提供的一系列建模元素和工具,创建自己的 CAD 模型。
这些建模元素包括线条、圆弧、曲面、实体等,工具则包括拉伸、旋转、剪切、复制等操作。
2. 模型编辑:在创建模型的基础上,用户可以对模型进行进一步的编辑和修改,以满足实际需求。
OpenCASCAD 支持多种编辑操作,如移动、旋转、缩放、合并、拆分等。
3. 模型输出:完成编辑后,用户可以将模型导出为常见的 CAD 文件格式,如 DXF、STEP、IGES 等,以便于与其他设计软件进行交换和共享。
三、核心功能OpenCASCAD 提供了以下核心功能:1. 建模元素和工具:包括线条、圆弧、曲面、实体等建模元素,以及拉伸、旋转、剪切、复制等操作工具。
2. 编辑功能:支持多种编辑操作,如移动、旋转、缩放、合并、拆分等,方便用户对模型进行修改。
3. 尺寸标注:提供多种尺寸标注工具,用于测量和标识模型中的尺寸信息。
4. 约束和链接:支持对模型的约束关系进行设置和管理,以保证模型的准确性。
同时,支持将其他 CAD 模型链接到 OpenCASCAD 中,以便于参考和编辑。
5. 三维渲染:提供三维渲染功能,可以将 CAD 模型以三维图像的形式展示出来,便于用户进行视觉上的判断和评估。
OpenCASCADE学习笔记详解
前言很久就想这篇东西,可一直懒于动脑且为一些俗事烦恼,所以才拖到现在才动笔把我上学期间一篇论文整理一下,仅供参考。
我分成几段来写,如果想看懂这篇文章,那首先要了解每段之前的关键词,不懂的可以在网上搜一下。
然后还有看这篇文章的时候希望你能按自己的需要来看,有很多是写给自己看的,你只挑自己有用的看就行了,省得到时候埋怨我浪费你宝贵的时间,我这人写东西不行,尽量写的有条理,尽量吧。
第1章意义,它是三维造型软件的内核、基础。
关键词:三维造型软件、虚拟现实技术、仿真技术、OpenGL、几何内核系统、布尔操作首先,做什么事情都要有意义,因此我先说明一下Open CASCADE到底是个什么类型的工具,使用这个工具是否对你将要完成的目标有帮助。
如果有帮助,那么你可以继续往下看它的具体用法;如果没有,那么你就应该按照你的目标继续寻找实现目标的手段,不用把时间浪费在这篇文章上;如果你清楚了Open CASCADE的这一工具是干什么用的就可以跳过意义直接看下一章。
我先说一下我对这个工具的理解,然后会贴一些网上对这个工具的说明。
Open CASCADE是一款三维造型软件的内核系统,也就是制作三维造型软件的工具。
那何为三维造型软件呢?其实市面上已经有很多这样的软件了,比如说PRO/E、UE、Solid Edge、Catia、国内还自主研发的金银花系统(好象叫这个名字)以上这些大多都是用于工业上的,3DMAX、VRML(这里要说明一下VRML其实是一款适合网络的三维造型语言,应属语言系列,和HTML语言类似,不太附和三维造型软件的标准)也是三维造型软件,当然还有很多很多这种类型的软件,就不做过多介绍。
三维造型软件,可以在电脑上如实地(尺寸、颜色、材质等)搭建起一个虚拟的模型,这些模型可以用于工业设计、艺术设计、装修设计等等等一系列的虚拟现实技术相关的行业,也可以用来做一些仿真实验的模型构建。
可能有很多人都已经用过一款或两款三维造型软件,但是你在用的时候想没想过三维造型软件是怎么做出来的呢?它的底层是由什么支持的?它是由两部分支持的,一是硬件支持,如显卡,这个我们不讨论;二是软件,作为软件,我猜想(注意是我猜的,如有疑问请查实)它也是可以分成两个部分,一是硬件驱动的标准体系(请关注OpenGL),二就是几何内核系统。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Data ExchangeIGES FORMATUser’s GuideVersion 6.3 / September 20082 Copyright © 2008, by Open CASCADE S.A.S.PROPRIETARY RIGHTS NOTICE: All rights reserved. No part of this material may be reproduced or transmitted in any form or by any means, electronic, mechanical, or otherwise, including photocopying and recording or in connection with any information storage or retrieval system, without the permission in writing from Open CASCADE S.A.S.The information in this document is subject to change without notice and should not be construed as a commitment by Open CASCADE S.A.S. Open CASCADE S.A.S. assures no responsibility for any errors that may appear in this document.The software described in this document is furnished under a license and may be used or copied only in accordance with the terms of such a license.CAS.CADE and Open CASCADE are registered trademarks of Open CASCADE S.A.S. Other brand or product names are trademarks or registered trademarks of their respective holders.NOTICE FOR USERS:This User Guide is a general instruction for Open CASCADE study. It may be incomplete and even contain occasional mistakes, particularly in examples, samples, etc. Open CASCADE S.A.S. bears no responsibility for such mistakes. If you find any mistakes or imperfections in this document, or if you have suggestions for improving this document, please, contact us and contribute your share to the development of Open CASCADE Technology: bugmaster@Tour Opus 1277, Esplanade du Général de Gaulle92914 PARIS LA DEFENSEFRANCETable of Contents1. INTRODUCTION (5)1.1.T HE IGES-O PEN CASCADE PROCESSOR (5)2. READING IGES (7)2.1.P ROCEDURE (7)2.2.D OMAIN COVERED (7)2.2.1. Translatable entities (7)2.2.2. Attributes (7)2.2.3. Administrative data (7)2.3.D ESCRIPTION OF THE PROCESS (8)2.3.1. Loading the IGES file (8)2.3.2. Checking the IGES file (8)2.3.3. Setting translation parameters (8)2.3.4. Selecting entities (13)2.3.5. Performing the IGES file translation (15)2.3.6. Getting the translation results (15)2.4.M APPING OF IGES ENTITIES TO O PEN CASCADE SHAPES (16)2.4.1. Points (16)2.4.2. Curves (16)2.4.3. Surfaces (18)2.4.4. Boundary Representation Solid Entities (20)2.4.5. Structure Entities (20)2.4.6. Subfigures (20)2.4.7. Transformation Matrix (21)2.5.M ESSAGES (21)2.6.T OLERANCE MANAGEMENT (21)2.6.1. Values used for tolerances during reading IGES (21)2.6.2. Initial setting of tolerances in translating objects (22)2.6.3. Transfer process (23)2.7.C ODE ARCHITECTURE (25)2.7.1. List of the classes (25)2.7.2. List of API classes (25)2.7.3. Graph of calls (25)2.8.E XAMPLE (26)3. WRITING IGES (28)3.1.P ROCEDURE (28)3.2.D OMAIN COVERED (28)3.3.D ESCRIPTION OF THE PROCESS (28)3.3.1. Initializing the process (28)3.3.2. Setting the translation parameters (28)3.3.3. Performing the Open CASCADE shape translation (31)3.3.4. Writing the IGES file (31)3.4.M APPING O PEN CASCADE SHAPES TO IGES ENTITIES (31)3.4.1. Curves (31)3.4.2. Surfaces (32)3.4.3. Topological entities (33)3.5.T OLERANCE MANAGEMENT (34)3.5.1. Setting resolution in an IGES file (34)3.6.C ODE ARCHITECTURE (34)3.6.1. List of the classes (34)3.6.2. List of API classes (35)3.6.3. Graph of calls (35)3.7.E XAMPLE (36)4. API FOR READING/WRITING IGES (37)4 4.1.O VERVIEW (37)4.2.P ACKAGE IGESC ONTROL (37)4.2.1. General description (37)4.2.2. Class IGESControl_Controller (37)4.2.3. Class IGESControl_Reader (38)4.2.4. Class IGESControl_Writer (42)4.2.5. General description (44)4.2.6. Class IGESToBRep_Reader (45)4.3.P ACKAGE IGESD ATA (48)4.3.1. General description (48)4.3.2. Class IGESData_IGESModel (48)4.3.3. Class IGESData_IGESEntity (51)5. USING XSTEPDRAW (59)5.1.XSDRAWIGES O VERVIEW (59)5.2.S ETTING INTERFACE PARAMETERS (59)5.3.R EADING IGES FILES (60)5.4.A NALYZING THE TRANSFERRED DATA (61)5.4.1. Checking file contents (61)5.4.2. Estimating the results of reading IGES (63)5.5.W RITING AN IGES FILE (65)5.6.I NDEX OF USEFUL COMMANDS (65)6. READING FROM AND WRITING TO XDE (67)6.1.D ESCRIPTION OF THE PROCESS (67)6.1.1. Loading an IGES file (67)6.1.2. Checking the loaded IGES file (67)6.1.3. Setting parameters for translation to XDE (67)6.1.4. Performing the translation of an IGES file to XDE (67)6.1.5. Initializing the process of translation from XDE to IGES (67)6.1.6. Setting parameters for translation from XDE to IGES (67)6.1.7. Performing the translation of an XDE document to IGES (68)6.1.8. Writing an IGES file (68)Introduction51. Introduction1.1. The IGES-Open CASCADE processorThis manual explains how to convert an IGES file to an Open CASCADE shape and vice versa. It provides basic documentation on conversion. For advanced information on conversion, see our offerings on our web site at /support/training.htmlIGES files up to and including IGES version 5.3 can be read. IGES files that are produced bythis interface conform to IGES version 5.3 (Initial Graphics Exchange Specification, IGES 5.3.ANS US PRO/IPO-100-1996).This manual principally deals with two Open CASCADE classes:•The Reader class, which loads IGES files and translates their contents to Open CASCADE shapes,•The Writer class, which translates Open CASCADE shapes to IGES entities and then writes these entities to IGES files.File translation is performed in the programming mode, via C++ calls, and the resulting Open CASCADE objects are shapes.All definitions in IGES version 5.3 are recognized but only 3D geometric entities are translated. When the processor encounters data, which is not translated, it ignores it and writes a message identifying the types of data, which was not handled. This message can be written either to a log file or to screen output.Reading IGES72. Reading IGES2.1. ProcedureYou can translate an IGES file to an Open CASCADE shape by following the steps below:1. Load the file,2. Check file consistency,3. Set the translation parameters,4. Perform the file translation,5. Fetch the results.2.2. Domain covered2.2.1. Translatable entitiesThe types of IGES entities, which can be translated, are:• Points• Lines• Curves• Surfaces• B-Rep entities•Structure entities (groups). Each entity in the group outputs a shape. There can be a group of groups.•Subfigures. Each entity defined in a subfigure outputs a shape• Transformation Matrix.NOTEAll non-millimeter length unit values in the IGES file are converted to millimeters.2.2.2. AttributesEntity attributes in the Directory Entry Section of the IGES file (such as layers, colors and thickness) are translated to Open CASCADE using XDE.2.2.3. Administrative dataAdministrative data, in the Global Section of the IGES file (such as the file name, the name ofthe author, the date and time a model was created or last modified) is not translated to Open CASCADE. Administrative data can, however, be consulted in the IGES file.82.3. Description of the process2.3.1. Loading the IGES fileBefore performing any other operation, you have to load the file using the syntax below.IGESControl_Reader reader;IFSelect_ReturnStatus stat = reader.ReadFile(“filename.igs”);The loading operation only loads the IGES file into computer memory; it does not translate it.2.3.2. Checking the IGES fileThis step is not obligatory. Check the loaded file with:Standard_Boolean ok = reader.Check(Standard_True);The variable “ok is True” is returned if no fail message was found; “ok is False” is returned if there was at least one fail message.reader.PrintCheckLoad (failsonly, mode);Error messages are displayed if there are invalid or incomplete IGES entities, giving you information on the cause of the error.Standard_Boolean failsonly = Standard_True or Standard_False;If you give True, you will see fail messages only. If you give False, you will see both fail and warning messages.Your analysis of the file can be either message-oriented or entity-oriented. Choose your preference with:IFSelect_PrintCount mode = IFSelect_xxxWhere xxx can be any of the following:ItemsByEntity gives a sequential list of all messages per IGES entity.CountByItem gives the number of IGES entities with their types per message. ShortByItem gives the number of IGES entities with their types per message anddisplays rank numbers of the first five IGES entities per message. ListByItem gives the number of IGES entities with their type and rank numbersper message.EntitiesByItem gives the number of IGES entities with their types, rank numbers andDirectory Entry numbers per message.2.3.3. Setting translation parametersThe following parameters can be used to translate an IGES file to an Open CASCADE shape. If you give a value that is not within the range of possible values, it will be ignored.read.iges.bspline.continuitymanages the continuity of BSpline curves (IGES entities 106, 112 and 126) after translation to Open CASCADE (Open CASCADE requires that the curves in a model be at least C1 continuous; no such requirement is made by IGES).0: no change; the curves are taken as they are in the IGES file. Open CASCADE C0 entities may be produced.1: if an IGES BSpline, Spline or CopiousData curve is C0 continuous, it is broken downReading IGES9into pieces of C1 continuous Geom_BSplineCurve.2: This option concerns IGES Spline curves only. IGES Spline curves are broken down into pieces of C2 continuity. If C2 cannot be ensured, the Spline curves will be brokendown into pieces of C1 continuity.Read this parameter with:Standard_Integer ic =Interface_Static::IVal("read.iges.bspline.continuity");Modify this value with:if (!Interface_Static::SetIVal("read.iges.bspline.continuity",2)).. error ..;Default value is 1.NOTEThis parameter does not change the continuity of curves that are used in the construction ofIGES BRep entities. In this case, the parameter does not influence the continuity of the resulting Open CASCADE curves (it is ignored).read.precision.modereads the precision value."File" (0) the precision value is read in the IGES file header (default)."User" (1) the precision value is that of the read.precision.val parameter.Read this parameter with:Standard_Integer ic =Interface_Static::IVal("read.precision.mode");Modify this value with:if (!Interface_Static::SetIVal ("read.precision.mode",1)).. error ..;Default value is "File" (0).read.precision.valuser precision value. This parameter gives the precision used during translation when the read.precision.mode parameter value is 1.0.0001: default.any real positive (non null) value.This value is a basis value for computation tolerances for TopoDS_Vertex, TopoDS_Edgeand TopoDS_Face entities.This value is in the measurement unit defined in the IGES file header.Read this parameter with:Standard_Real rp = Interface_Static::RVal("read.precision.val"); Modify this parameter with:if (!Interface_Static::SetRVal ("read.precision.val",0.001)).. error ..;Default value is 0.0001.NOTEThe value given to this parameter is a target value that is applied to TopoDS_Vertex,10 TopoDS_Edge and TopoDS_Face entities. The processor does its best to reach it. Under certain circumstances, the value you give may not be attached to all of the entities concernedat the end of processing. IGES-to-Open CASCADE translation does not improve the quality of the geometry in the original IGES file. This means that the value you enter may be impossibleto attain the given quality of geometry in the IGES file.NOTEValue of tolerance used for computation is calculated by multiplying the value of read.precision.val and the value of coefficient of transfer from the file units to millimeters. read.maxprecision.modedefines the mode of applying the maximum allowed tolerance. Its possible values are: "Preferred"(0) maximum tolerance is used as a limit but sometimes it can be exceeded (currently, only for deviation of a 3D curve of an edge from its pcurvesand from vertices of such edge) to ensure shape validity "Forced"(1) maximum tolerance is used as a rigid limit, i.e. it can not be exceeded and, if this happens, tolerance is trimmed to suit the maximum-allowablevalue.Read this parameter with:Standard_Integer mv =Interface_Static::IVal("read.maxprecision.mode");Modify this parameter with:if (!Interface_Static::SetIVal ("read.maxprecision.mode",1)).. error ..;Default value is "Preferred" (0).read.maxprecision.valdefines the maximum allowable tolerance (in mm) of the shape. It should be not less than the basis value of tolerance set in processor (either Resolution from the file or read.precision.val). Actually, the maximum between read.maxprecision.val and basis tolerance is used to define maximum allowed tolerance.Read this parameter with:Standard_Real rp =Interface_Static::RVal("read.maxprecision.val");Modify this parameter with:if (!Interface_Static::SetRVal ("read.maxprecision.val",0.1)).. error ..;Default value is 1.read.stdsameparameter.modedefines the using of BRepLib::SameParameter. Its possible values are:0 ("Off") - BRepLib::SameParameter is not called,1 ("On") - BRepLib::SameParameter is called.Functionality of BRepLib::SameParameter is used through ShapeFix_Edge::SameParameter.It ensures that the resulting edge will have the lowest tolerance taking pcurves either unmodified from the IGES file or modified by BRepLib::SameParameter.Read this parameter with:Standard_Integer mv =Interface_Static::IVal("read.stdsameparameter.mode");Modify this parameter with:if (!Interface_Static::SetIVal ("read.stdsameparameter.mode",1)) .. error ..;Deafault value is 0 ("Off").read.surfacecurve.modepreference for the computation of curves in case of 2D/3D inconsistency in an entity which has both 2D and 3D representations.Here we are talking about entity types 141 (Boundary), 142 (CurveOnSurface) and 508 (Loop). These are entities representing a contour lying on a surface, which is translated to a TopoDS_Wire, formed by TopoDS_Edges. Each TopoDS_Edge must have a 3D curve and a 2D curve that reference the surface.The processor also decides to re-compute either the 3D or the 2D curve even if both curves are translated successfully and seem to be correct, in case there is inconsistency between them. The processor considers that there is inconsistency if any of the following conditions is satisfied:•the number of sub-curves in the 2D curve is different from the number of sub-curves in the 3D curve. This can be either due to different numbers of sub-curves given in the IGES file or because of splitting of curves during translation.•3D or 2D curve is a Circular Arc (entity type 100) starting and ending in the same point (note that this case is incorrect according to the IGES standard)The parameter read.surfacecurve.mode defines which curve (3D or 2D) is used for re-computing the other one:1. "Default" (0): use the preference flag value in the entity's Parameter Data section. Theflag values are:•0: no preference given,•1: use 2D for 142 entities and 3D for 141 entities,•2: use 3D for 142 entities and 2D for 141 entities,•3: both representations are equally preferred.2."2DUSE_PREFERRED" (2): THE 2D IS USED TO REBUILD THE 3D IN CASE OFTHEIR INCONSISTENCY,3. "2DUse_Forced" (-2): the 2D is always used to rebuild the 3D (even if 2D is present in thefile),4. "3DUse_Preferred" (3): the 3D is used to rebuild the 2D in case of their inconsistency,5. "3DUse_Forced" (-3): the 3D is always used to rebuild the 2D (even if 2D is present in thefile),If no preference is defined (if the value of read.surfacecurve.mode is "Default" and the value of the preference flag in the entity's Parameter Data section is 0 or 3), an additional analysis is performed.The 3D representation is preferred to the 2D in two cases:•if 3D and 2D contours in the file have a different number of curves,•if the 2D curve is a Circular Arc (entity type 100) starting and ending in the same point and the 3D one is not.In any other case, the 2D representation is preferred to the 3D.If either a 3D or a 2D contour is absent in the file or cannot be translated, then it is re-computed from another contour. If the translation of both 2D and 3D contours fails, the whole curve (type 141 or 142) is not translated. If this curve is used for trimming a face, the face will be translated without this trimming and will have natural restrictions.Read this parameter with:Standard_Integer ic =Interface_Static::IVal("read.surfacecurve.mode");Modify this value with:if (!Interface_Static::SetIVal ("read.surfacecurve.mode",3)).. error ..;Default value is "Default" (0).read.encoderegularity.angleThis parameter is used within the BRepLib::EncodeRegularity() function which is called for a shape read from an IGES or a STEP file at the end of translation process. This function sets the regularity flag of an edge in a shell when this edge is shared by two faces. This flag shows the continuity, which these two faces are connected with at that edge.Read this parameter with:Standard_Real era =Interface_Static::RVal("read.encoderegularity.angle");Modify this parameter with:if (!Interface_Static::SetRVal("read.encoderegularity.angle",0.1)).. error ..;Default value is 0.01.read.iges.bspline.approxd1.modeThis parameter is obsolete (it is rarely used in real practice). If set to True, it affects the translation of bspline curves of degree 1 from IGES: these curves (which geometrically are polylines) are split by duplicated points, and the translator attempts to convert each of the obtained parts to a bspline of a higher continuity.Read this parameter with:Standard_Real bam =Interface_Static::CVal("read.iges.bspline.approxd1.mode");Modify this parameter with:if (!Interface_Static::SetRVal("read.encoderegularity.angle","On")).. error ..;Default value is Off.read.iges.sequenceThese two parameters define the name of the resource file and the name of the sequence of operators(defined in that file) for Shape Processing, which is automatically performed by the IGES translator. The Shape Processing is a user-configurable step, which is performed afterthe translation and consists in application of a set of operators to a resulting shape. This isa very powerful tool allowing to customize the shape and to adapt it to the needs ofa receiving application. By default, the sequence consists of a single operator ShapeFix -that is how Shape Healing is called from the IGES translator.Please find an example of the resource file for IGES (which defines parameters corresponding to the sequence applied by default, i.e. if the resource file is not found) inthe Open CASCADE installation, by the path %CASROOT%/src/XSTEPResource/IGES ($CASROOT/src/XSTEPResource/IGES).In order for the IGES translator to use that file, you have to define the environment variableCSF_IGESDefaults, which should point to the directory where the resource file resides.Note that if you change parameter , you should change the nameof the resource file and the name of the environment variable correspondingly. The variable should contain a path to the resource file.Default values: - IGES, read.iges.sequence - FromIGES.read.scale.unitThis parameter is obsolete (the parameter xstep.cascade.unit should be used insteadwhen necessary). If it is set to 'M', the shape is scaled 0.001 times (as if it were in meters) after translation from IGES or STEP.Default value is MM.xstep.cascade.unitThis parameter defines units to which a shape should be converted when translatedfrom IGES or STEP to CASCADE. Normally it is MM; only those applications thatwork internally in units other than MM should use this parameter.Default value is MM.2.3.4. Selecting entitiesA list of entities can be formed by invoking the method IGESControl_Reader::GiveList.Handle(TColStd_HSequenceOfTransient) list = reader.GiveList();Several predefined operators can be used to select a list of entities of a specific type.To make a selection, you use the method IGESControl_Reader::GiveList with the selectiontype in quotation marks as an argument. You can also make cumulative selections. For example, you would use the following syntax:1. Requesting the faces in the file:faces = Reader.GiveList("iges-faces");2. Requesting the visible roots in the filevisibles = Reader.GiveList("iges-visible-roots");3. Requesting the visible facesvisfac = Reader.GiveList("iges-visible-roots",faces);Using a signature, you can define a selection dynamically, filtering the string by means of a criterion. When you request a selection using the method GiveList, you can give either a predefined selection or a selection by signature. You make your selection by signature usingthe predefined signature followed by your criterion in parentheses as shown in the example below. The syntaxes given are equivalent to each other.faces = Reader.GiveList(“xst-type(SurfaceOfRevolution)”);faces = Reader.GiveList(“iges-type(120)”);You can also look for:•values returned by your signature which match your criterion exactlyfaces = Reader.GiveList(“xst-type(=SurfaceOfRevolution)”);•values returned by your signature which do not contain your criterionfaces = Reader.GiveList(“xst-type(!SurfaceOfRevolution)”);•values returned by your signature which do not exactly match your criterion.faces = Reader.GiveList(“xst-type(!=SurfaceOfRevolution)”);List of predefined operators that can be used:• xst-model-allSelects all entities.• xst-model-rootsSelects all roots.• xst-transferrable-allSelects all translatable entities.• xst-transferrable-rootsSelects all translatable roots (default).• xst-sharing + <selection>Selects all entities sharing at least one entity selected by <selection>.• xst-shared + <selection>Selects all entities shared by at least one entity selected by <selection>.• iges-visible-rootsSelects all visible roots, whether translatable or not.• iges-visible-transf-rootsSelects all visible and translatable roots.• iges-blanked-rootsSelects all blank roots, whether translatable or not.• iges-blanked-transf-rootsSelects all blank and translatable roots.• iges-status-independantSelects entities whose IGES Subordinate Status = 0.• iges-bypass-groupSelects all root entities. If a root entity is a group (402/7 or 402/9), the entities in the group are selected.• iges-bypass-subfigureSelects all root entities. If a root entity is a subfigure definition (308), the entities in the subfigure definition are selected.• iges-bypass-group-subfigureSelects all root entities. If a root entity is a group (402/7 or 402/9) or a subfigure definition (308), the entities in the group and in the subfigure definition are selected.• iges-curves-3dSelects 3D curves, whether they are roots or not (e.g. a 3D curve on a surface).• iges-basic-geomSelects 3D curves and untrimmed surfaces.• iges-facesSelects face-supporting surfaces (trimmed or not).• iges-surfacesSelects surfaces not supporting faces (i.e. with natural bounds).• iges-basic-curves-3dSelects the same entities as iges-curves-3d. Composite Curves are broken down into their components and the components are selected.2.3.5. Performing the IGES file translationPerform translation according to what you want to translate:1. Translate an entity identified by its rank with:Standard_Boolean ok = reader.Transfer (rank);2. Translate an entity identified by its handle with:Standard_Boolean ok = reader.TransferEntity (ent);3. Translate a list of entities in one operation with:Standard_Integer nbtrans = reader.TransferList (list);reader.IsDone();nbtrans returns the number of items in the list that produced a shape.reader.IsDone() indicates whether at least one entity was translated.4. Translate a list of entities, entity by entity:Standard_Integer i,nb = list->Length();for (i = 1; i <= nb; i ++) {Handle(Standard_Transient) ent = list->Value(i);Standard_Boolean OK = reader.TransferEntity (ent);}5. Translate the whole file (all entities or only visible entities) with:Standard_Boolean onlyvisible = Standard_True or Standard_False;reader.TransferRoots(onlyvisible)2.3.6. Getting the translation resultsEach successful translation operation outputs one shape. A series of translations gives a series of shapes.Each time you invoke TransferEntity, Transfer or Transferlist, their results are accumulated and NbShapes increases. You can clear the results (Clear function) between two translation operations, if you do not do this, the results from the next translation will be added to the accumulation. TransferRoots operations automatically clear all existing results before they start.Standard_Integer nbs = reader.NbShapes();returns the number of shapes recorded in the result.TopoDS_Shape shape = reader.Shape(num);,returns the result <num>, where <num> is an integer between 1 and NbShapes.TopoDS_Shape shape = reader.Shape();returns the first result in a translation operation.TopoDS_Shape shape = reader.OneShape();returns all results in a single shape which is:• a null shape if there are no results,•in case of a single result, a shape that is specific to that result,• a compound that lists the results if there are several results.reader.Clear();erases the existing results.reader.PrintTransferInfo (failsonly, mode);displays the messages that appeared during the last invocation of Transfer or TransferRoots. If <failsonly> is IFSelect_FailOnly, only fail messages will be output, if it is IFSelect_FailAndWarn, all messages will be output. Parameter “mode” can have IFSelect_xxx values where xxx can be:GeneralCountgives general statistics on the transfer (number of translated IGES entities, number of fails and warnings, etc)CountByItemgives the number of IGES entities with their types per message.ListByItemgives the number of IGES entities with their type and DE numbers per message.ResultCountgives the number of resulting Open CASCADE shapes per typeMappinggives mapping between roots of the IGES file and the resulting Open CASCADE shape per IGES and Open CASCADE type.2.4. Mapping of IGES entities to Open CASCADE shapesNOTEIGES entity types that are not given in the following tables are not translatable.2.4.1. PointsIGES entity type CASCADE shape Comments116: Point TopoDS_Vertex2.4.2. CurvesCurves, which form the 2D of face boundaries, are translated as Geom2D_Curves (Geom2D circles, etc.).。