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