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.

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/

目录
相关文章
|
2月前
GEE错误——Tile error: Arrays must have same lengths on all axes but the cat axis
GEE错误——Tile error: Arrays must have same lengths on all axes but the cat axis
21 1
|
6月前
135Echarts - 路径图(Use lines to draw 1 million ny streets.)
135Echarts - 路径图(Use lines to draw 1 million ny streets.)
16 0
|
计算机视觉 Python Windows
OpenCV——line、circle、rectangle、ellipse、polylines函数的使用和绘制文本putText函数以及绘制中文的方法。
学习OpenCV的过程中,画图是不可避免的,本篇文章旨在介绍OpenCV中与画图相关的基础函数。
217 0
OpenCV——line、circle、rectangle、ellipse、polylines函数的使用和绘制文本putText函数以及绘制中文的方法。
|
算法
Split Shape by Plane in OpenCASCADE
Split Shape by Plane in OpenCASCADE eryar@163.com Abstract. Sometimes you want to split a shape by plane or even split a shape by a B Spline surfac...
1651 0
|
算法
Convert BSpline Curve to Arc Spline in OpenCASCADE
Convert BSpline Curve to Arc Spline in OpenCASCADE eryar@163.com Abstract. The paper based on OpenCASCADE algorithms to approximate the NURBS curve to arc spline.
1477 0
|
人工智能 图形学
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.
1520 0
Make Helix Shape in occQt
Make Helix Shape in occQtPCurve is a powerful modeling method, to make helix shapes in occQt to help you understand pcurve better, then you can also can model some intereting shape based on pcurve.
950 0
A Simple OpenCASCADE Qt Demo-occQt
A Simple OpenCASCADE Qt Demo-occQt eryar@163.com Abstract. OpenCASCADE have provided the Qt samples in the samples directory, but they are a little complicated.
2410 0