• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            eryar

            PipeCAD - Plant Piping Design Software.
            RvmTranslator - Translate AVEVA RVM to OBJ, glTF, etc.
            posts - 603, comments - 590, trackbacks - 0, articles - 0

            OpenCASCADE Application Framework

            Data Framework Services

            eryar@163.com

            一、概述Overview

            OpenCASCADE的數(shù)據(jù)框架對來自不同程序的數(shù)據(jù)提供了統(tǒng)一的處理環(huán)境。這就簡化了數(shù)據(jù)交換、修改,也保證了數(shù)據(jù)統(tǒng)一性、穩(wěn)定性。實(shí)現(xiàn)方法需要用到以下部分:

            u 標(biāo)號Tha tag

            u 標(biāo)簽The label

            u 屬性The attribute

            Contents of a document

            Figure 1. Contents of a document

            如上圖所示,框架樹的第一個(gè)標(biāo)簽(label)是根標(biāo)簽(root)。每個(gè)標(biāo)簽(label)有個(gè)以整數(shù)表示的標(biāo)號(tag)。由當(dāng)前標(biāo)簽的標(biāo)號到根標(biāo)簽的標(biāo)號,可以得到一個(gè)惟一的標(biāo)號列表,如:0:1:2:1

            每個(gè)標(biāo)簽(label)可以一些屬性(attribute),這些屬性可以包含數(shù)據(jù)。每個(gè)屬性由GUID來區(qū)分。標(biāo)簽最重要的性質(zhì)是其入口只是數(shù)據(jù)框架的一個(gè)地址。

            二、標(biāo)號The Tag

            一個(gè)標(biāo)號Tag就是一個(gè)整數(shù),它用兩種方式標(biāo)示了一個(gè)label

            u 相對標(biāo)示法 Relative identification:一個(gè)標(biāo)簽的標(biāo)號只與其父標(biāo)簽有關(guān)系。如對于一個(gè)指定的標(biāo)簽,可能由四個(gè)子標(biāo)簽組成,其標(biāo)號分別為2718100。使用相對標(biāo)示方法,在設(shè)置屬性時(shí)有安全的范圍。

            u 絕對標(biāo)示法 Absolute identification:一個(gè)標(biāo)簽在數(shù)據(jù)框架中位置由無歧義的、從根標(biāo)簽的標(biāo)號到當(dāng)前標(biāo)簽的標(biāo)號用冒號表示的標(biāo)號列表(list of tags)來表示。

            不管采用哪種方法,都要注意的是這些標(biāo)號的值沒什么實(shí)際的意義。只是用來確定每個(gè)標(biāo)簽在樹結(jié)構(gòu)的位置,都是為了使用文檔支持Undo/Redo的功能。

            創(chuàng)建標(biāo)號Tag的兩種方式:

            u Random delivery 隨機(jī)創(chuàng)建;

            u User-defined delivery 用戶自定義創(chuàng)建;

            正如字面所說,隨機(jī)創(chuàng)建標(biāo)號時(shí),標(biāo)號是由系統(tǒng)隨機(jī)生成。用戶自定義創(chuàng)建標(biāo)號時(shí),標(biāo)號的值是創(chuàng)建標(biāo)號函數(shù)的參數(shù)。

            1. 隨機(jī)創(chuàng)建標(biāo)號法生成子標(biāo)簽 Creating child labels using random delivery of tags

            使用TDF_TagSource::NewChild來添加標(biāo)簽。如下代碼所示,函數(shù)NewChild的參數(shù)level2也是一個(gè)TDF_Label

            2. 用戶自定義創(chuàng)建標(biāo)號法生成子標(biāo)簽 Creation of a child label by user delivery from a tag

            創(chuàng)建子標(biāo)簽的另一種方式就是用戶自定義創(chuàng)建。即在指定標(biāo)號創(chuàng)建標(biāo)簽。可以使用TDF_Label::FindChildTDF_Label::Tag來獲得指定標(biāo)號的子標(biāo)簽。

            如上代碼所示,3是需要查找的標(biāo)簽的標(biāo)號,Standard_False用來表示若查找不到指定標(biāo)號時(shí)是否創(chuàng)建子標(biāo)簽。

            三、標(biāo)簽The Label

            標(biāo)號(Tag)給了標(biāo)簽(Label)一個(gè)唯一的地址。數(shù)據(jù)框架中的標(biāo)簽是包含屬性,綁定數(shù)據(jù)的容器。數(shù)據(jù)框架的本質(zhì)是一個(gè)標(biāo)簽樹,如下圖所示:

            數(shù)據(jù)框架中的標(biāo)簽不能被刪除,因此,當(dāng)文檔打開后已經(jīng)的數(shù)據(jù)框架結(jié)構(gòu)不能被刪除。

            1. 創(chuàng)建標(biāo)簽 Label creation

            可以在任意層次創(chuàng)建標(biāo)簽,也可以找到標(biāo)簽在數(shù)據(jù)框架中的深度(Depth)。TDF_Label提供上述功能。

            2. 創(chuàng)建子標(biāo)簽 Creating child labels

            在數(shù)據(jù)框架中指定標(biāo)簽上創(chuàng)建子標(biāo)簽使用TDF_Label::FindChild。如下所示:

            當(dāng)把FindChilde的第二個(gè)參數(shù)設(shè)為Standard_True時(shí),就確保了查找不到指定標(biāo)號的標(biāo)簽時(shí)會創(chuàng)建一個(gè)標(biāo)簽。如下所示:

            3. 訪問子標(biāo)簽 Retrieving child labels

            可以使用遍歷器來訪問當(dāng)前標(biāo)簽的第一層的子標(biāo)簽。如下所示:

            也可以訪問當(dāng)前標(biāo)簽的所有子標(biāo)簽,如下所示:

            使用TDF_Tool::Entry可以得到當(dāng)前標(biāo)簽的入口字符串,如下所示:

            4. 訪問父標(biāo)簽

            訪問當(dāng)前標(biāo)簽的父標(biāo)簽:

            四、屬性The Attribute

            標(biāo)簽本身不包含任何數(shù)據(jù)。所有數(shù)據(jù),不管什么類型,程序的非程序的數(shù)據(jù)都是保存在屬性中。屬性是綁定在標(biāo)簽上,且屬性可以是任意類型的數(shù)據(jù)。OCAF提供許多直接可以使用的屬性如:整數(shù)、實(shí)數(shù)、軸、平面。也有用于拓樸、功能、可視化的屬性。每種類型的屬性由GUID來標(biāo)識。這樣做的好處就是所有類型的屬性都以相同的方式處理。可以創(chuàng)建新的實(shí)例,訪問、綁定到標(biāo)簽和從標(biāo)簽上刪除等。

            1.訪問標(biāo)簽的屬性

            使用函數(shù)TDF_Label::FindAttribute來訪問標(biāo)簽的屬性。如下例所示,

            2.使用GUID來標(biāo)識屬性 Identifying an attribute using a GUID

            可以創(chuàng)建一個(gè)屬性對象并得到其GUID。如下例所示,創(chuàng)建了一個(gè)整數(shù)屬性,通過方法ID來得到GUID

            3. 將屬性綁定到標(biāo)簽 Attaching an attribute to a label

            使用函數(shù)TDF_Label::Add來將屬性綁定到標(biāo)簽。重復(fù)綁定相同GUID的屬性到一個(gè)標(biāo)簽會出現(xiàn)錯(cuò)誤。TDF_Attribute::Label可以得到綁定屬性的標(biāo)簽。如下所示:

            4. 測試標(biāo)簽綁定狀態(tài) Testing the attachment to a label

            可以使用函數(shù)TDF_Attribute::IsA來檢驗(yàn)屬性是否已經(jīng)綁定到標(biāo)簽上,函數(shù)的參數(shù)是屬性的GUID。在下例所示,是檢測當(dāng)前標(biāo)簽是否有整數(shù)屬性,然后得出這個(gè)標(biāo)簽屬性的數(shù)量。函數(shù)TDF_Tool::HasAttribute用來檢測標(biāo)簽是否綁定的有屬性,函數(shù)TDF_Tool::NbAttributes返回標(biāo)簽綁定屬性的數(shù)量。

            5. 刪除標(biāo)簽的屬性 Removing an attribute from a label

            若要將屬性從標(biāo)簽中刪除,可以使用TDF_Label::Forget,函數(shù)參數(shù)為屬性的GUID。若要?jiǎng)h除標(biāo)簽所有屬性,使用函數(shù)TDF_Label::ForgetAll

            6. 特定屬性的創(chuàng)建 Specific attribute creation

            見《Application Framework User's Guide》。

             

            五、示例程序 Sample Code

              1: //------------------------------------------------------------------------------
            
              2: //	Copyright (c) 2012 eryar All Rights Reserved.
            
              3: //
            
              4: //		File    : Main.cpp
            
              5: //		Author  : eryar@163.com
            
              6: //		Date    : 2012-11-4 21:25
            
              7: //		Version : 0.1v
            
              8: //
            
              9: //	Description : OpenCASCADE Application Framework sample code.
            
             10: //
            
             11: //==============================================================================
            
             12: 
            
             13: #include <iostream>
            
             14: using namespace std;
            
             15: 
            
             16: #include <TDF_Tool.hxx>
            
             17: #include <TDF_ChildIterator.hxx>
            
             18: #include <TDataStd_Integer.hxx>
            
             19: #include <TDocStd_Document.hxx>
            
             20: 
            
             21: // Use Toolkit: TKLCAF
            
             22: #pragma comment(lib, "TKernel.lib")
            
             23: #pragma comment(lib, "TKLCAF.lib")
            
             24: 
            
             25: int main(int argc, char* argv[])
            
             26: {
            
             27:     TCollection_AsciiString entry;
            
             28: 
            
             29:     Handle_TDocStd_Document myDF    = new TDocStd_Document("myDocument");
            
             30: 
            
             31:     // Main label and root label of the data framework.
            
             32:     TDF_Label   mainLabel   = myDF->Main();
            
             33:     TDF_Label   root        = mainLabel.Root();
            
             34: 
            
             35:     cout<<"Main label :";
            
             36:     mainLabel.EntryDump(cout);
            
             37: 
            
             38:     cout<<endl<<"Root label :";
            
             39:     root.EntryDump(cout);
            
             40: 
            
             41:     // Create a label with tag 10 at Root.
            
             42:     TDF_Label   myLabel    = root.FindChild(10);
            
             43: 
            
             44:     cout<<endl<<"Entry of the new label :";
            
             45:     myLabel.EntryDump(cout);
            
             46: 
            
             47:     // Retrieving child labels.
            
             48:     cout<<endl<<"Retrieving child labels: "<<endl;
            
             49:     for (TDF_ChildIterator it(root); it.More(); it.Next())
            
             50:     {
            
             51:         it.Value().EntryDump(cout);
            
             52:         cout<<endl;
            
             53:     }
            
             54: 
            
             55:     // Attaching an attribute to a label.
            
             56:     Handle_TDataStd_Integer INT = new TDataStd_Integer;
            
             57:     myLabel.AddAttribute(INT);
            
             58: 
            
             59:     // Testing of attribute attachment.
            
             60:     if (myLabel.IsAttribute(INT->GetID()))
            
             61:     {
            
             62:         cout<<"The attribute is attached to the label."<<endl;
            
             63:     }
            
             64:     else
            
             65:     {
            
             66:         cout<<"The attribute is not attached to the label."<<endl;
            
             67:     }
            
             68: 
            
             69:     // Removing an attribute from a label.
            
             70:     myLabel.ForgetAttribute(INT->GetID());
            
             71: 
            
             72:     // Testing of attribute attachment.
            
             73:     if (myLabel.IsAttribute(INT->GetID()))
            
             74:     {
            
             75:         cout<<"The attribute is attached to the label."<<endl;
            
             76:     }
            
             77:     else
            
             78:     {
            
             79:         cout<<"The attribute is not attached to the label."<<endl;
            
             80:     }
            
             81: 
            
             82:     return 0;
            
             83: }

            輸出結(jié)果如下所示:

              1: Main label :0:1
            
              2: Root label :0:
            
              3: Entry of the new label :0:10
            
              4: Retrieving child labels:
            
              5: 0:1
            
              6: 0:10
            
              7: The attribute is attached to the label.
            
              8: The attribute is not attached to the label.
            
              9: Press any key to continue . . .

             

             

            eryar@163.com

            2012-11-06

            Feedback

            # re: OpenCASCADE Application Framework Data Framework Services  回復(fù)  更多評論   

            2012-11-07 09:33 by 力為
            最好不用這個(gè)組件

            # re: OpenCASCADE Application Framework Data Framework Services  回復(fù)  更多評論   

            2012-11-07 12:27 by occ
            @力為
            為什么不能使用這個(gè)組件?說說原因吧

            # re: OpenCASCADE Application Framework Data Framework Services  回復(fù)  更多評論   

            2012-11-07 17:23 by eryar
            @力為
            我想如果對樹形結(jié)構(gòu)的數(shù)據(jù)的操作進(jìn)行撤消與重做的話,這種框架還是值得參考的吧?

            # re: OpenCASCADE Application Framework Data Framework Services  回復(fù)  更多評論   

            2012-11-19 23:05 by aslan
            如果說沒有仔細(xì)研究該部分,或者沒有自己認(rèn)為更加好的解決方法,還是建議采用OCAF,不需要人云亦云。

            # re: OpenCASCADE Application Framework Data Framework Services  回復(fù)  更多評論   

            2012-11-20 18:15 by eryar
            @aslan
            是啊。
            OCAF也是別人的勞動(dòng)成果啊!

            # re: OpenCASCADE Application Framework Data Framework Services  回復(fù)  更多評論   

            2013-10-22 09:19 by 力為
            @eryar
            1. 繁瑣
            最最開始的時(shí)候用OCAF,簡單的描述沒什么問題。需要保存的數(shù)據(jù)多的時(shí)候,有很多體力活。每次都遍歷樹,使用不方便。
            2. 臃腫
            用GUID標(biāo)識,Undo/Redo保存的數(shù)據(jù)太多,耗費(fèi)內(nèi)存。

            簡單的應(yīng)用用不上,復(fù)雜的應(yīng)用使用起來不方便。我們都是按照自己的需求自己實(shí)現(xiàn)的。

            # re: OpenCASCADE Application Framework Data Framework Services  回復(fù)  更多評論   

            2013-10-22 19:48 by eryar
            @力為
            贊同,
            不過我正在寫的一個(gè)小程序正好用上了,
            :-)
            成人资源影音先锋久久资源网| 亚洲人成电影网站久久| 国产精品天天影视久久综合网| 国产精品久久自在自线观看| 久久久久国色AV免费观看| 免费一级做a爰片久久毛片潮| 婷婷伊人久久大香线蕉AV| 伊人久久免费视频| 香蕉久久夜色精品升级完成| 999久久久免费国产精品播放| 色播久久人人爽人人爽人人片AV| 久久精品黄AA片一区二区三区| 狠狠色伊人久久精品综合网| 亚洲精品午夜国产VA久久成人 | 97精品国产97久久久久久免费 | 久久精品国产99国产精品| 日产精品久久久久久久| 亚洲国产精久久久久久久| 99精品国产综合久久久久五月天| 国产2021久久精品| 久久免费的精品国产V∧| 亚洲国产成人久久综合碰| 亚洲午夜久久久精品影院| 久久亚洲精精品中文字幕| 久久久亚洲AV波多野结衣| 伊人久久大香线蕉精品| 国产精品久久久久久搜索| 久久久久99精品成人片直播| 久久精品无码一区二区WWW| 久久亚洲色一区二区三区| 久久国产影院| 精品久久久久久99人妻| 久久久91精品国产一区二区三区| 久久99精品久久久久久动态图| 一本久久免费视频| 国产香蕉久久精品综合网| 伊人久久大香线蕉综合5g| 午夜视频久久久久一区 | 国内精品久久久久久中文字幕| 久久99国产精品久久99果冻传媒| 9久久9久久精品|