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 vzbufftrihedron # run a test
source tests/blend/begin
source tests/blend/buildevol/a2 vsetdispmode
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/

OpenCascade Draw Test Harness的更多相关文章

  1. OpenCASCADE Shape Location

    OpenCASCADE Shape Location eryar@163.com Abstract. The TopLoc package of OpenCASCADE gives resources ...

  2. OpenCASCADE Ring Type Spring Modeling

    OpenCASCADE Ring Type Spring Modeling eryar@163.com Abstract. The general method to directly create ...

  3. OpenCASCADE PCurve of Topological Face

    OpenCASCADE PCurve of Topological Face eryar@163.com Abstract. OpenCASCADE provides a class BRepBuil ...

  4. OpenCASCADE General Transformation

    OpenCASCADE General Transformation eryar@163.com Abstract. OpenCASCADE provides a general transforma ...

  5. OpenNURBS to OpenCASCADE

    OpenNURBS to OpenCASCADE eryar@163.com Abstract. The OpenNURBS initiative provides CAD/CAM/CAE and c ...

  6. OpenCASCADE DataExchange DWG

    OpenCASCADE DataExchange DWG eryar@163.com Abstract. DWG is a file format created in the 70’s for th ...

  7. OpenCascade Chinese Text Rendering

    OpenCascade Chinese Text Rendering eryar@163.com Abstract. OpenCascade uses advanced text rendering ...

  8. OpenCascade Ruled Surface

    OpenCascade Ruled Surface eryar@163.com Abstract. A ruled surface is formed by moving a line connect ...

  9. Create New Commands in Tcl

    Create New Commands in Tcl eryar@163.com 摘要Abstract:Tcl/Tk脚本可以很容易实现用户自定义的命令,方便的创建图形化的用户界面GUI,所以Tcl和T ...

随机推荐

  1. 弱省互测#0 t1

    题意 给一个\(N \times M\)的01网格,1不能走,从起点\((1, 1)\)走到\((N, M)\),每次只能向下或向右走一格,问两条不相交的路径的方案数.(n, m<=1000) ...

  2. Ejabberd导入到eclipse

    ejabberd 在eclipse(erlide)中的配置.调试.运行   最近在折腾ejabberd,将ejabberd项目配置到eclipse中进行编译.调试等,现在将过程记下来,希望能帮助到需要 ...

  3. Mac OS X 中快速访问系统根目录的四种方法

    1.通过终端打开Finder的根目录          open / 2.通过“前往文件夹”快捷键组合 用户只需点击左上角的“前往”菜单,然后选择“前往文件夹...”功能.使用快捷键+Shift+G也 ...

  4. 常用的107条Javascript

    1.         document.write( " "); 输出语句 2.JS中的注释为// 3.传统的HTML文档顺序是:document- >html- >( ...

  5. 解决IE6/IE7/IE8不支持before,after问题

    对从事web开发的朋友来讲,低版本的IE永远是一个痛点,不支持最新技术(如css3,html5). 在现在web开发中使用图标字体已经很广泛,如Font Awesome,Bootstrap等,字体图片 ...

  6. 向mysql中插入Date类型的数据

    先看数据库表的定义 date字段为sql.date类型.我要向其中插入指定的日期和当前日期. 一.插入当前日期 思路:先获取当前系统,在将当前系统时间转换成sql类型的时间,然后插入数据库.代码如下 ...

  7. Flume_常见的几个问题

    在HDFS的文件默认生成文件大小1K,如何设置文件大小和数量 拷贝一份flume-conf.properties.template改名为hive-mem-size.properties hive-me ...

  8. 1051. Pop Sequence

    原题连接:https://www.patest.cn/contests/pat-a-practise/1051 题目: Given a stack which can keep M numbers a ...

  9. .net网站常见问题及解决方案

    1.   解决方法: 三个文件放到项目Bin文件夹     2. 解决方法 : requestValidationMode="2.0" 加到 3. 你在浏览器输入网址报这样的错误 ...

  10. mysql 命令行还原备份数据库

    通常数据库还原备份可以通过navicat等数据库管理工具进行,只需要简单的导出导入就行了,但遇到有索引外键的数据库,数据库管理工具运行.sql文件会报错,这时候可以尝试命令行导入,亲测可以成功 MyS ...