OpenCASCADE Extended Data Exchange - XDE 2019-10-14

OpenCASCADE Extended Data Exchange - XDE

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版本)


Figure 1. 导入的STEP模型

2. Extended Data Exchange(XDE)


Figure 2. 使用XDE导入的模型

3. XDE Basic Terms


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


Figure 3. 装配结构树


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


6. Names


Figure 5. 模型名字

7. Colors and Layers


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


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



Copyright © 2019 游艇会206官方网站 All Rights Reserved