OpenCASCADE Extended Data Exchange - XDE

OpenCASCADE Extended Data Exchange - XDE

[email protected]

Abstract. OpenCASCADE Data Exchange allows developing OCCT-Based applications that can interact with other CAD systems by writing and reading CAD models to and from external data. The exchanges run smoothly regardless of the quality of external data or requirements to its internal representation, for example to the data types, accepted geometric inaccuracies, etc. Data Exchange is organized in a modular way as a set of interfaces that comply with various CAD formats: IGES, STEP, STL, VRML, etc. The interfaces allow software based on OCCT to exchange data with various CAD/PDM software packages, maintaining a good level of interoperability. Extended Data Exchange allows translating additional attributes attached to geometric data(colors, layers, names, materials, etc.)

Key Words. DataExchange, STEP, IGES, XDE, OCAF,

1. Introduction

OpenCASCADE的DataExchange数据交换模块可以通过读写CAD模型数据的方式与其他CAD系统进行交互。标准数据交换(Standardized Data Exchange)的接口可以查询和检查输入文件,转换文件中的CAD模型,正确性检查。目前开源部分支持的文件格式有:

l STEP(AP203:Mechanical Design;AP214:Automotive Design)

l IGES(5.3版本)

l VRML和STL;

Figure 1. 导入的STEP模型

2. Extended Data Exchange(XDE)

扩展的数据交换模块可以转换附加在几何BREP体中其他信息,如颜色、图层,组装结构等,因此提高与其他CAD软件的兼容性。目前包含这些信息的文件格式有IGES和STEP。XDE通过XCAF框架来读写包含颜色、图层等信息的IGES,STEP文件。

Figure 2. 使用XDE导入的模型

3. XDE Basic Terms

为了更好的理解XDE,定义了几个关键术语:

l Shape:单独的模型,不属于任何装配结构(a standalone shape, which does not belong to the assembly structure);

l Instance:其他模型的一个实例化,位置信息可以相同,也可以不同(a replication of another shape with a location that can be the same location or different one);

l Assembly:装配结构;

4. XDE Organization

XDE的基础是XCAF,XCAF是一个基于OCAF(Open CASCADE Technology Application Framework)框架的框架,可用于处理装配信息和其他属性数据。XDE使用OCAF来存储装配结构和属性,所以可以得到装配结构树的每层TopoDS表示。

5. Assemblies

XDE支持装配结构的读写。如下图所示:

Figure 3. 装配结构树

装配结构通过OCAF的Label/SubLabel来组织:

Figure 4. 一个简单的框架模型

类XCAFDoc_ShapeTool来管理Label中的模型属性。

6. Names

XDE支持读写IGES和STEP中的名字数据。这个关闭这个功能以减小文件。

Figure 5. 模型名字

7. Colors and Layers

XDE可以读写模型的颜色数据,使用到的类有:

l 通用颜色:generic color(XCAFDoc_ColorGen)

l 曲面颜色:surface color(XCAFDoc_ColorSurf)

l 曲线颜色:curve color(XCAFDoc_ColorCurv)

Figure 6. XDE颜色

8. Code Example

程序将Draw Test Harness的samples的XDE的例子模型来测试读取装配结构、颜色等信息。首先将例子模型通过命令:WriteStep D d:/rod.step来保存装配结构、颜色等数据到STEP格式。

Figure 7. XDE Samples in Draw Test Harness

Figure 8. Shapes with assembly and color info

使用XDE读取STEP文件代码示例如下:

Handle(XCAFDoc_ColorTool) aColorTool;
Handle(XCAFDoc_ShapeTool) aShapeTool;

void visit(const TDF_Label& theLabel)
{
    theLabel.EntryDump(std::cout);

    Handle(TDataStd_Name) aName;
    if (theLabel.FindAttribute(TDataStd_Name::GetID(), aName))
    {
        std::cout << "  Name: " << aName->Get() << std::endl;
    }

    if (aColorTool->IsSet(theLabel, XCAFDoc_ColorGen))
    {
        Quantity_Color aColor;
        aColorTool->GetColor(theLabel, aColor);

        std::cout << "  Color: " << Quantity_Color::StringName(aColor.Name()) << std::endl;
    }

    if (aShapeTool->IsShape(theLabel))
    {
        TopoDS_Shape aShape;
        aShapeTool->GetShape(theLabel, aShape);
    }

    for (TDF_ChildIterator c(theLabel); c.More(); c.Next())
    {
        visit(c.Value());
    }
}

void readStepXde(const std::string& theStepName)
{
    Handle(TDocStd_Document) aDoc;
    Handle(XCAFApp_Application) anApp = XCAFApp_Application::GetApplication();
    anApp->NewDocument("MDTV-XCAF", aDoc);

    STEPCAFControl_Reader aStepReader;
    aStepReader.SetColorMode(true);
    aStepReader.SetNameMode(true);

    aStepReader.ReadFile(theStepName.c_str());

    aStepReader.Transfer(aDoc);

    TDF_Label aRootLabel = aDoc->Main();

    aShapeTool = XCAFDoc_DocumentTool::ShapeTool(aRootLabel);
    aColorTool = XCAFDoc_DocumentTool::ColorTool(aRootLabel);

    visit(aRootLabel);

}

int main(int argc, char *argv[])
{
    readStepXde("D:/rod.STEP");

    return 0;
}

程序运行结果如下图所示:

Figure 9. 使用XDE读取STEP装配结构、颜色、名字等

9. Conclusion

使用XDE模块支持STEP和IGES中的装配结构、颜色、名字等信息的读写,提高与其他CAD系统数据交换效果。

XDE主要使用OCAF框架来处理装配结构、属性信息,所以要使用XDE,必须理解OCAF的框架,OCAF框架也是一个基于Label的树结构。

原文地址:https://www.cnblogs.com/opencascade/p/XDE.html

时间: 2024-12-20 08:15:57

OpenCASCADE Extended Data Exchange - XDE的相关文章

【12c】扩展数据类型(Extended Data Types)-- MAX_STRING_SIZE

[12c]扩展数据类型(Extended Data Types)-- MAX_STRING_SIZE 在12c中,与早期版本相比,诸如VARCHAR2, NAVARCHAR2以及 RAW这些数据类型的大小会从4K以及2K字节扩展至32K字节.只要可能,扩展字符的大小会降低对LOB 数据类型的使用.为了启用扩展字符大小,你必须将MAX_STRING_SIZE的初始数据库参数设置为EXTENDED. 要使用扩展字符类型需要执行以下过程: 1.关闭数据库 2.以升级模式重启数据库3.更改参数: ALT

Oracle 12C 新特性之扩展数据类型(extended data type)

Oracle 12C 新特性-扩展数据类型,在12c中,与早期版本相比,诸如VARCHAR2, NAVARCHAR2以及 RAW这些数据类型的大小会从4K以及2K字节扩展至32K字节.只要可能,扩展字符的大小会降低对LOB数据类型的使用.为了启用扩展字符大小,你必须将MAX_STRING_SIZE的初始数据库参数设置为EXTENDED. 实验流程:1.查看参数max_string_size默认值SQL> show parameter max_string_sizeNAME     TYPE VA

OpenCASCADE BRepTools

OpenCASCADE BRepTools [email protected] Abstract. OpenCASCADE BRepTools provides utilities for BRep data structure. OuterWire method to find the outer wire of a face. Dump method to dump a BRep object. It also can be used as the data exchange for Ope

A Simple OpenCASCADE Qt Demo-occQt

A Simple OpenCASCADE Qt Demo-occQt [email protected] Abstract. OpenCASCADE have provided the Qt samples in the samples directory, but they are a little complicated. So I decide write a simple OpenCASCADE Qt demo for the OpenCASCADE beginners. Key Wor

OpenCASCADE Expression Interpreter by Flex &amp; Bison

OpenCASCADE Expression Interpreter by Flex & Bison [email protected] Abstract. OpenCASCADE provide data structure of any expression, relation or function used in mathematics. Flex and Bison are tools for building programs that handle structured input

OpenCASCADE Interpolations and Approximations

OpenCASCADE Interpolations and Approximations [email protected] Abstract. In modeling, it is often required to approximate or interpolate points to curves and surfaces. In interpolation, the process is complete when the curve or surface passes throug

Indexing Sensor Data

In particular embodiments, a method includes, from an indexer in a sensor network, accessing a set of sensor data that includes sensor data aggregated together from sensors in the sensor network, one or more time stamps for the sensor data, and metad

PatentTips - Data Plane Packet Processing Tool Chain

BACKGROUND The present disclosure relates generally to systems and methods for providing a data plane processing tool chain for processing packets using OSI layers?4?and above in the data plane. With the development of multi-core processors, applicat

C++入门

  C++入门必看,提升必看 Visual C++MFC入门教程 目录 +-- 第一章 VC入门|------ 1.1 如何学好VC|------ 1.2 理解Windows消息机制|------ 1.3 利用Visual C++/MFC开发Windows程序的优势|------ 1.4 利用MFC进行开发的通用方法介绍|------ 1.5 MFC中常用类,宏,函数介绍+-- 第二章 图形输出|------ 2.1 和GUI有关的各种对象|------ 2.2 在窗口中输出文字|------