zoukankan      html  css  js  c++  java
  • OpenCascade Draw Test Harness

    OpenCascade Draw Test Harness

    eryar@163.com

    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中产生的效果: 

    wps_clip_image-14743

    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

    wps_clip_image-23795

    Figure 2.2 Tcl script 

    将上述脚本代码保存到samples/tcl文件夹下,文件名为init.tcl,再启动Draw,输入命令: 

    wps_clip_image-30471

    Figure 2.3 Use the Tcl file 

    3. Find code from Draw Test

    因为Draw是基于Tcl/Tk实现的解释器,所以根据Tcl中自定义命令的方法,可以找出OpenCascade中这些命令的实现代码。更方便的做法是直接输入命令名称,再在所有的源代码中搜索相关文件即可。如上述脚本中的vgrid命令,是打开、关闭栅格,可以直接搜索vgrid,得到结果如下所示: 

    wps_clip_image-22146

    Figure 3.1 Find command in Files 

    wps_clip_image-16479

    Figure 3.2 Find Result of the Command 

    得到相关的代码使用方法如下图所示: 

    wps_clip_image-30092

    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/

    5. http://www.tcl.tk/

  • 相关阅读:
    需求采集
    <转>jmeter(十七)目录结构
    《Google软件测试之道》测试开发工程师
    聊聊学习和读书这件事
    聊聊用户
    jmeter(十六)配置元件之计数器
    《探索性软件测试》
    一个完整的性能测试流程
    js外部样式和style属性的添加移除
    jquery获取第一层li
  • 原文地址:https://www.cnblogs.com/opencascade/p/3879015.html
Copyright © 2011-2022 走看看