0025235: Draw Harness - improve commands vdimension and vdimparam
[occt.git] / samples / tcl / dimensions.tcl
CommitLineData
0499eb06 1# Demo script for dimensions
2puts "Dimensions demo: it shows capability of OCC to create different kinds "
3puts "of dimensions (linear and angular) with 2D or 3D text."
4
5set dispScriptFile [file normalize [info script]]
6set scriptFolder [file dirname $dispScriptFile]
7
8set aTopLoc [locate_data_file occ/Top.brep]
9set aBotLoc [locate_data_file occ/Bottom.brep]
10set aHatch [locate_data_file images/hatch_1.png]
11
12if { ![file exist "$aTopLoc"] || ![file exist "$aBotLoc"] } {
13 puts "No model file in current directory!"
14 puts "Please put Bottom.brep and Top.brep in current directory and try again"
15}
16
17pload MODELING VISUALIZATION
18restore $aTopLoc a
19restore $aBotLoc b
20vinit View1 w=768 h=768
21vclear
22vsetdispmode 0
23vsetcolorbg 255 255 255
24vbottom
25
26# Get cut projection
27box bb -150 -250 0 150 250 100
28bsection bs b bb
29bsection as a bb
30vdisplay bs as
31vfit
32
33set anAEdges [explode as E]
34set aBEbges [explode bs E]
35
36#foreach e [concat $anAEdges $aBEbges] { vdisplay $e }
37set anArrAngle [expr 3.14 * 12.0 / 180.0]
38
39set aList {das_7 dbs_27 dbs_6 dbs_19 das_25 das_26 dbs_22 das_43 das_12 das_41 dbs_39 dbs_59 das_3944 dbs_1826 das_4843}
40
41vdimension dbs_19 -length -shapes bs_19 -plane xoy -color black -flyout -15
42vdimension dbs_6 -length -shapes bs_6 -plane xoy -color black -flyout 15
43vdimension dbs_27 -length -shapes bs_27 -plane xoy -color black -label right -flyout -27
44vdimension das_7 -length -shapes as_7 -plane xoy -color black -flyout -20
45vdimension das_25 -length -shapes as_25 -plane xoy -color black -flyout -15
46vdimension das_26 -length -shapes as_26 -plane xoy -color black -flyout 30
47vdimension dbs_22 -length -shapes bs_22 -plane xoy -color black -flyout -20
48vdimension das_43 -length -shapes as_43 -plane xoy -color black -flyout 55 -label right
49vdimension das_12 -length -shapes as_12 -plane xoy -color black -flyout 35 -label right
50vdimension das_41 -length -shapes as_41 -plane xoy -color black -flyout 15
51
52vdimension dbs_39 -radius -shapes bs_39 -color black -label right
53vdimension dbs_59 -radius -shapes bs_59 -color black
54
55vdimension das_3944 -angle -shapes as_39 as_44 -color black
56vdimension dbs_1826 -angle -shapes bs_18 bs_26 -color black
57vdimension das_4843 -angle -shapes as_48 as_43 -color black
58
59foreach i $aList {
60 vdimparam $i text=3d textsize=6 textmode=s arlength=4 arangle=$anArrAngle
61}
62
63# Final fit
64foreach e [concat $anAEdges $aBEbges] {
65 vremove $e
66}
67vfit
68
69vdisplay a b
70vsetdispmode a 1
71vsetdispmode b 1
72vaspects a -setmaterial steel
73vaspects b -setmaterial bronze
74
75# set clipping plane
76vclipplane create pa
77vclipplane change pa equation 0 0 1 0
78vclipplane change pa capping on
79vclipplane change pa capping color 0.9 0.9 0.9
80#vclipplane change pa capping hatch on
81vclipplane set pa object a
82
83vclipplane create pb
84vclipplane change pb equation 0 0 1 0
85vclipplane change pb capping on
86vclipplane change pb capping color 1.0 0.8 0.0
87#vclipplane change pb capping hatch on
88vclipplane set pb object b
89
90vsettexturemode Driver1/Viewer1/View1 2
91vclipplane change pa capping texname $aHatch
92vclipplane change pa capping texscale 0.05 -0.05
93vclipplane change pb capping texname $aHatch
94vclipplane change pb capping texscale 0.05 0.05
95
96# nice view
97vbottom
98vrotate -0.3 -0.3 0
99vfit
100vzoom 1.2