Tuesday, September 15, 2009

Draw Test Harness quick tutorial

OpenCascade has a very useful tool named Draw Test Harness. This tutorial presents two use cases that show how this tool can be used to research if some algorithms are appropriate for some implementation or not.

Preparing the tool:
- Launch Draw Test Harness (in can be launched by clicking on Start->Programs->OpenCascade Technology 6.3.0->Test Harness,
- on the command line write: pload ALL,
- then write: axo.
This loads all the occ packages and opens an axonometric view.
The result is displayed on the screenshot:


Use case 1: let's assume we want to find a way to combine two concentric circles so that the smaller one removes material from the bigger one. With test harness we can try different operations on the circles as wires or as faces to see which one fits our purpose. We can test with forward and reversed shapes, wires and faces and any other situation that we need to test.

The code is the following:
circle c1 0 0 0 50
circle c2 0 0 0 25
fit
mkedge ec1 c1 0 2*pi
mkedge ec2 c2 0 2*pi
wire wc1 ec1
wire wc2 ec2
mkplane p1 wc1
mkplane p2 wc2
bcut result p1 p2
donly result

And the result:


Another advantage beside the quick case testing would be also that we can look at the command source code to see how they are implemented.

Use case2: we want to want to make some tests with FreeBounds from the ShapeAnalysis package to see if we can use this class to detect some closed wires. We write quickly some code to analyze the result:

clear
vertex v1 10 10 0
vertex v2 10 100 0
vertex v3 100 100 0
vertex v4 100 10 0
vertex v5 50 150 0

edge e1 v1 v2
edge e2 v2 v3
edge e3 v3 v4
edge e4 v4 v1
edge e5 v2 v5
edge e6 v5 v3

wire w1 e1 e2 e3 e4 e5 e6
mkplane p1 w1
freebounds p1 0
donly p1_o

We can modify the code to test what happens if we build two wires from these edges or any other case that we are interested in. Another cool thing is that we can always peek at the command implementation.

And the result:

No comments: