OpenCascade Draw Test Harness
Abstract . Draw is a command interpreter based on Tcl/Tk and a graphical system used to test and demonstrate OpenCascade modeling libraries. It provides a flexible and easy to use means of testing and demonstrating the OCCT modeling libraries. By a given command of Tcl, you can find the implentation code for that command by OpenCascade, the code could be as a demo to use of OCC modeling libraries. So this is the most effectively way of use OpenCascade.?
Key words. OpenCascade, Tcl/Tk, Testing, Scripts
1. Introduction
Draw Test Harness提供了靈活和易于使用的方式來測試、演示OpenCascade的建模算法。可用來交互的創建、顯示和修改曲線、曲面及拓樸形狀。你也可以自己寫Tcl腳本來自定義Draw或使用腳本來實現自動化測試。也可以為Draw添加新的自定義的命令。?
因為Draw是基于Tcl/Tk腳本的,所以可以根據OpenCascade自定義的命令名稱來找到相關的實現,這個實現應該是使用OpenCascade最有效的方式,也是官方使用OpenCascade的方式,具有很好的參考價值。?
還可在Draw 中使用Tcl腳本來實現概念建模,如果結果和預期一致,可再把Tcl命令相對應的C++代碼寫到程序中,提高編程效率。?
本文主要介紹如何根據OpenCascade中實現的命令找到相關的實現代碼,作為編程時的參考,避免了用C++代碼來實現一些功能時自己來摸索,從而浪費不必要的時間。?
2. Using Tcl/Tk
先給出Draw中使用腳本出來的效果的例子,再介紹找出命令實現代碼的方法。如下圖所示為用腳本在Draw中產生的效果:?
Figure 2.1 A blend test in Draw Test Harness?
其實現的腳本如下所示:
pload ALL vinit vgrid vsetgradientbg 0 0 180 255 255 255 2 vzbufftrihedron # run a test source tests/blend/ begin source tests /blend/buildevol/ a2 vsetdispmode 1 vdisplay result vfit
Figure 2.2 Tcl script?
將上述腳本代碼保存到samples/tcl文件夾下,文件名為init.tcl,再啟動Draw,輸入命令:?
Figure 2.3 Use the Tcl file?
3. Find code from Draw Test
因為Draw是基于Tcl/Tk實現的解釋器,所以根據Tcl中自定義命令的方法,可以找出OpenCascade中這些命令的實現代碼。更方便的做法是直接輸入命令名稱,再在所有的源代碼中搜索相關文件即可。如上述腳本中的vgrid命令,是打開、關閉柵格,可以直接搜索vgrid,得到結果如下所示:?
Figure 3.1 Find command in Files?
Figure 3.2 Find Result of the Command?
得到相關的代碼使用方法如下圖所示:?
Figure 3.3 The Command function code?
依此類推,其他Draw中的命令都可以找到相關的實現代碼,這些代碼都可作為編程的依據,有助于OpenCascade的正確、高效使用。?
4. Conclusion
從上可知,如果需要OpenCascade的什么功能,可以先在Draw Test Harness中試試看,如果在Draw Test Harness中可以實現,再找出其實現那個命令的代碼,再參考代碼實現所需要功能即可。這樣編程使用OpenCascade應該是輕松和高效的,因為Tcl是解釋執行,不像C++那樣需要編譯時間。?
5. References
1. Tcl and the Tk Toolkit?
2. Practical Programming in Tcl and Tk?
3. Tcl/Tk A Developer’s Guide?
4. OpenCascade Test Harness User’s Guide??
5. http://sourceforge.net/projects/tcl/
PDF Version: OpenCascade Draw Test Harness
更多文章、技術交流、商務合作、聯系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
