logo资料库

CAA二次开发之3D标注的应用.pdf

第1页 / 共27页
第2页 / 共27页
第3页 / 共27页
第4页 / 共27页
第5页 / 共27页
第6页 / 共27页
第7页 / 共27页
第8页 / 共27页
资料共27页,剩余部分请下载后查看
目标
从文件中获取标注集
获取文件
获取TPS文件
获取标注集
遍历标注集
遍历一个标注集中的各公差
获取公差的语义、关联的几何、公差带、尺寸界限
从标注获取几何元素并将其高亮
从选择的注释获取TTRS
分析标注
分析公差语义
分析与公差关联的几何元素
分析公差带
分析尺寸界限
创建标注
在选定的平面上创建标注的时候采用的状态机
命令代理设置
开始创建标注
获取选择的几何体
修改文本的位置
修改文本的尺寸和字体
修改文本内容
源代码使用方法
第 9 讲三维标注与公差 目录 1 目标 ..................................................................................................................................................................... 2 2 从文件中获取标注集 ......................................................................................................................................... 3 2.1 获取文件 ................................................................................................................................................. 3 2.2 获取 TPS 文件 ......................................................................................................................................... 4 2.3 获取标注集 ............................................................................................................................................. 4 2.4 遍历标注集 ............................................................................................................................................. 4 2.5 遍历一个标注集中的各公差 ................................................................................................................. 5 2.6 获取公差的语义、关联的几何、公差带、尺寸界限 .......................................................................... 5 3 从标注获取几何元素并将其高亮 ..................................................................................................................... 6 4 从选择的注释获取 TTRS .................................................................................................................................... 7 5 分析标注 ........................................................................................................................................................... 10 5.1 分析公差语义 ....................................................................................................................................... 10 5.2 分析与公差关联的几何元素 ............................................................................................................... 16 5.3 分析公差带 ........................................................................................................................................... 17 5.4 分析尺寸界限 ....................................................................................................................................... 18 6 创建标注 ........................................................................................................................................................... 22 6.1 在选定的平面上创建标注的时候采用的状态机 ................................................................................ 22 6.2 命令代理设置 ....................................................................................................................................... 22 6.3 开始创建标注 ....................................................................................................................................... 23 6.4 获取选择的几何体 ............................................................................................................................... 23 6.5 修改文本的位置 ................................................................................................................................... 24 6.6 修改文本的尺寸和字体 ....................................................................................................................... 24 6.7 修改文本内容 ....................................................................................................................................... 25 7 源代码使用方法 ............................................................................................................................................... 27
1 目标 创建标注 获取标注的信息 从标注中获取与之相关联的几何元素
从选取的几何元素获取与之关联的标注与公差 使用科技产品规范(TPS)接口。用例演示了 CATITPS 接口使用检索功能引用的一个 3d 注释。它还演示了如 何扫描竞技场结构 CATITTRS 接口来检索 RGE(参考几何元素)。CATIRGE 和 CATIRGETopology 接口用于 检索拓扑几何学的单元。最后,几何和拓扑评估执行创建和显示一个网格点与他们正常的单元。 2 从文件中获取标注集 2.1 获取文件 intAbstractEteamDlg::AbstractAll() { CATDocument* pCurDoc = BITFindCurrentDoc(); CATDocument* pDoc = pCurDoc;
char * TextPath="E:\\ooo.txt"; FILE * pStream = fopen(TextPath, "w"); if ( pStream == NULL ) return (7); // Write copyright in stream fprintf(pStream, "%s\n","COPYRIGHT DASSAULT SYSTEMES 2000"); HRESULT rc = E_FAIL; 2.2 获取 TPS 文件 // Retrieve TPS entry point interface on document//获取文件中 TPS 进入接口?? CATITPSDocument * piTPSDoc = NULL; if ( pDoc ) { rc = pDoc ->QueryInterface (IID_CATITPSDocument, (void**) &piTPSDoc); } if ( FAILED(rc) ) return (8); 2.3 获取标注集 // Retrieve list of tolerancing sets in document as a CATITPSList//获取文件中的标注集们?? CATITPSList * piSetList = NULL; rc = piTPSDoc ->GetSets(&piSetList); piTPSDoc -> Release(); piTPSDoc = NULL; if (!SUCCEEDED(rc) ) return 7; // Retrieve set count//获取标注集的数量 unsignedintSetCount = 0; piSetList -> Count(&SetCount); // Iterate on list of set and for each set analyze tolerances//遍历每个标注集并分析公差 CATITPSSet* piSet = NULL; 2.4 遍历标注集 for( unsigned intSetIdx = 0; SetIdxItem (SetIdx, &piCompOnSet); if ( !SUCCEEDED(rc) ) continue;
// Analyze sets of piTPSDoc 分析文件中的标注集们 rc = piCompOnSet ->QueryInterface(IID_CATITPSSet, (void **)&piSet); if ( !SUCCEEDED(rc) ) continue; // Retrieve tolerances that belong to set as a CATITPSList//获取一个标注集中的公差,公差以 CATITPSList 存储 CATITPSList* piToleList = NULL; rc = piSet ->GetTPSs(&piToleList); if ( !SUCCEEDED(rc) ) continue; // Retrieve tolerances count in set//获取一个标注集中的公差数量 unsignedintToleCount = 0; piToleList -> Count(&ToleCount); 2.5 遍历一个标注集中的各公差 // Analyze tolerances of set//分析标注集中的公差 for ( unsigned intToleIdx = 0; ToleIdx Item (ToleIdx, &piCompOnTole); if ( !SUCCEEDED(rc) ) continue; fprintf (pStream,"%s%s%i%s%i%s\n", "------------------------ ", " Set.", SetIdx,".Tolerance.",ToleIdx, " -----------------------"); 2.6 获取公差的语义、关联的几何、公差带、尺寸界限 // Dump tolerance informations//获取公差信息 CAATpiDumpCATITPSSemanticValidity (piCompOnTole, pStream); CAATpiDumpCATITPS (piCompOnTole, pStream); CAATpiDumpCATITPSToleranceZone (piCompOnTole, pStream); CAATpiDumpCATITPSDimensionLimits (piCompOnTole, pStream); HighLAllAnn PointLineFace piCompOnTole -> Release(); } } piSetList -> Release(); // Close output dump file fclose(pStream); (piCompOnTole);//高亮全部标注...OK (piCompOnTole);//高亮全部与标注相关的点、线、面
return (0); } 3 从标注获取几何元素并将其高亮 CATFrmEditor *pEditor=CATFrmEditor::GetCurrentEditor(); CATPathElement pUIPath = pEditor->GetUIActiveObject(); CATPathElement * pPathTPS = &pUIPath; CATHSO * pHSO = pEditor -> GetHSO(); 在上边代码中的自定义函数PointLineFace() //高亮全部与标注相关的点、线、面 void AbstractEteamDlg::PointLineFace(CATITPSComponent * ipiTole) { if ( !ipiTole ) { return; } int TTRSNodeCount = 0; int TTRSSupportCount = 0; int RGECount = 0; int FaceCount = 0; int EdgeCount = 0; int VertexCount = 0; // Retrieve CATITPS interface on input tolerance CATITPS * piTPS = NULL; HRESULT rc = ipiTole -> QueryInterface (IID_CATITPS, (void **)&piTPS ); if ( SUCCEEDED(rc) ) { // Links to toleranced surfaces is retrieved as a TTRS list unsignedint Count = 0; CATITTRSList * piTTRSList = NULL; CATITTRS * piTTRS = NULL; rc = piTPS -> GetTTRS (&piTTRSList); if ( SUCCEEDED(rc) ) { // Dump TTRS count piTTRSList -> Count (&Count); // Iterate on TTRS list, and for each of them read for ( unsignedint i = 0; i < Count; i++ ) CAT3DBagRep * pRep = new CAT3DBagRep();
{// Retrieve TTRS number i in the list as a CATITTRS piTTRS = NULL; rc = piTTRSList -> Item (i, &piTTRS); if ( SUCCEEDED(rc) ) { // Analyse TTRS Composition AnalyseTTRS (piTTRS, pHSO, pPathTPS, TTRSNodeCount, TTRSSupportCount, RGECount, FaceCount, EdgeCount, VertexCount, pRep); // Construct a Rep to visualize TTRS and add it to ISO //AddTTRSGeometryOnRepresentation (piTTRS, pPathTPS, pRep); piTTRS -> Release(); piTTRS = NULL; } } piTTRSList -> Release(); } } } 4 从选择的注释获取 TTRS 当选择代理 OnAnnotationSelected 称为过渡方法。CATPathElement 选择 pPathTPS 检索通过调用 GetValue 选择代理。选中的 3 d 注释 piTPS 检索作为 CATITPS 接口指针使用 CATPathElement 的搜索方 法 。 方 法 CATITPS:GetTTRS 检 索 的 列 表 竞 技 场 直 接 由 三 维 引 用 注 释 CATITTRSList 接 口 指 针 。 CATITTRSList:: 计 数 和 CATITTRSList:: 条 目 的方法 允 许 列 表上 进 行 迭 代。 检 索 列 表的 每 个 元 素作 为 CATITTRS AnalyseTTRS 接口指针和提供的方法来获取一些信息组成。 booleanCAATpiAccessGeometryCmd::OnAnnotationSelected (void * ipData) { if ( !_pSelectionAgent || !_pPanel ) return (TRUE); HRESULT rc = E_FAIL; intTTRSNodeCount = 0; intTTRSSupportCount = 0; intRGECount = 0; intFaceCount = 0; intEdgeCount = 0; intVertexCount = 0;
// Read display parameters from panel _pPanel ->GetRequiredDisplay (&_bDisplay3DGrid, &_bDisplayTTRSRep); // Retrieve the path of the selected annotation CATPathElement * pPathTPS = _pSelectionAgent ->GetValue (); if ( pPathTPS ) { // Retrieve HSO from editor and empty it CATFrmEditor * pEdt = GetEditor(); if ( pEdt ) { CATHSO * pHSO = pEdt ->GetHSO(); if ( pHSO ) { pHSO -> Empty(); // Add selected PathElement in the HSO, it will be highlighted pHSO ->AddElements (pPathTPS); CATISO * pISO = pEdt ->GetISO(); if ( pISO ) { // Clean existing element in ISO pISO ->RemoveElement (_pModelObjectForAdditionalRep); // Retrieve CATITPS interface on selected 3D annotation CATITPS * piTPS = NULL; rc = pPathTPS -> Search (IID_CATITPS, (void**) &piTPS); if ( SUCCEEDED(rc) ) { // Retrieve the list of TTRSs which are directly referenced by // the annotation, most often that list contains only 1 element, // exeptions are Semantics Targets V5 and Default Annotation CATITTRSList * piTTRSList = NULL; rc = piTPS ->GetTTRS (&piTTRSList); if ( SUCCEEDED(rc) ) { unsignedintTTRSCount = 0; piTTRSList -> Count (&TTRSCount); CATITTRS * piTTRS = NULL; // Allocate representation to display surfaces of TTRSs // Points and normals on the TTRSs faces will be // added in that Rep by AnalyseTTRS method.
分享到:
收藏