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

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/

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

PDF Version: OpenCascade Draw Test Harness

时间: 2024-09-20 06:14:19

OpenCascade Draw Test Harness的相关文章

OpenCascade Chinese Text Rendering

OpenCascade Chinese Text Rendering eryar@163.com Abstract. OpenCascade uses advanced text rendering powered by FTGL library. The FreeType provides vector text rendering, as a result the text can be rotated and zoomed without quality loss. FreeType al

OpenCASCADE Outline

OpenCASCADE Outline eryar@163.com      有网友反映blog中关于OpenCASCADE的文章比较杂乱,不太好找,最好能提供一个大纲,这样方便查找.于是决定将这些学习时写的文章整理下,方便对OpenCASCADE的学习理解.其实在http://www.cnblogs.com/opencascade中,已经将文章按目录重新发表了一遍.可以按OpenCASCADE的模块的顺序来学习,也可以挑选自己感兴趣的部分来学习.      由于本人水平所限,文中的错误不妥之处

OpenNURBS to OpenCASCADE

OpenNURBS to OpenCASCADE eryar@163.com Abstract. The OpenNURBS initiative provides CAD/CAM/CAE and computer graphics software developers the tools to accurately transfer 3D geometry between applications. The OpenNURBS C++ source code is clean and fai

OpenCASCADE Ring Type Spring Modeling

OpenCASCADE Ring Type Spring Modeling eryar@163.com Abstract. The general method to directly create an edge is to give a 3D curve as the support(geometric domain) of the edge. The curve maybe defined as a 2D curve in the parametric space of a surface

OpenCASCADE PCurve of Topological Face

OpenCASCADE PCurve of Topological Face eryar@163.com Abstract. OpenCASCADE provides a class BRepBuilderAPI_MakeFace to build topological faces. A face maybe built from a surface, elementary surface from gp package, surface from Geom, from a wire and

OpenCASCADE DataExchange DWG

OpenCASCADE DataExchange DWG eryar@163.com Abstract. DWG is a file format created in the 70's for the emerging CAD applications. Currently it is the native file format of AutoCAD, a proprietary CAD program developed by Autodesk. Libredwg is a free C

OpenCASCADE Shape Location

OpenCASCADE Shape Location eryar@163.com Abstract. The TopLoc package of OpenCASCADE gives resources to handle 3D local coordinate systems called Locations. A Location is a composition of elementary coordinate systems, each one is called a Datum. The

OpenCASCADE General Transformation

OpenCASCADE General Transformation eryar@163.com Abstract. OpenCASCADE provides a general transformation class: gp_GTrsf. It can be a transformation from gp, an affinity, or you can define your own transformation giving the matrix of transformation.

Create New Commands in Tcl

Create New Commands in Tcl eryar@163.com 摘要Abstract:Tcl/Tk脚本可以很容易实现用户自定义的命令,方便的创建图形化的用户界面GUI,所以Tcl和Tk的应用领域几乎覆盖了图形和工程应用的全部范围,包括计算机辅助设计.软件开发.测试.仪器控制.科学可视化及多媒体方面.本文主要详解如何在C程序中使用Tcl来创建自定义的命令,并理解OpenCascade的Draw Test Harness的实现. 关键字Key Words:OpenCascade,