0028599: Replacement of old Boolean operations with new ones in BRepProj_Projection...
[occt.git] / samples / tcl / dimensions.tcl
CommitLineData
7a733b19 1# Dimensions demo
2#
3# It shows capability of OCC to create different kinds
4# of dimensions (linear and angular) with 2D or 3D text.
0499eb06 5
5bffb882 6#Category: Visualization
7#Title: Dimensions in 3d viewer
8
0499eb06 9set aTopLoc [locate_data_file occ/Top.brep]
10set aBotLoc [locate_data_file occ/Bottom.brep]
11set aHatch [locate_data_file images/hatch_1.png]
12
0499eb06 13pload MODELING VISUALIZATION
7a733b19 14
15puts "Importing shapes..."
0499eb06 16restore $aTopLoc a
17restore $aBotLoc b
7a733b19 18
0499eb06 19vinit View1 w=768 h=768
20vclear
21vsetdispmode 0
22vsetcolorbg 255 255 255
23vbottom
24
7a733b19 25puts "Getting cut projection..."
0499eb06 26box bb -150 -250 0 150 250 100
27bsection bs b bb
28bsection as a bb
29vdisplay bs as
30vfit
31
32set anAEdges [explode as E]
33set aBEbges [explode bs E]
34
0499eb06 35set anArrAngle [expr 3.14 * 12.0 / 180.0]
36
7a733b19 37# Form dimension names list to set parameters with vdimparam command
38set aList {rd_1 rd_2 ad_1 ad_2 ad_3}
39for {set i 1} {$i <= 10} {incr i} {
40lappend aList ld_$i
41}
0499eb06 42
7a733b19 43puts "Creating dimensions..."
44vdimension ld_1 -length -shapes bs_27 -plane xoy -color black -flyout -15
45vdimension ld_2 -length -shapes bs_14 -plane xoy -color black -flyout 15
46vdimension ld_3 -length -shapes bs_28 -plane xoy -color black -label right -flyout -27
47vdimension ld_4 -length -shapes as_7 -plane xoy -color black -flyout -20
48vdimension ld_5 -length -shapes as_28 -plane xoy -color black -flyout -15
49vdimension ld_6 -length -shapes as_18 -plane xoy -color black -flyout 30
50vdimension ld_7 -length -shapes bs_20 -plane xoy -color black -flyout -20
51vdimension ld_8 -length -shapes as_43 -plane xoy -color black -flyout 55 -label right
52vdimension ld_9 -length -shapes as_12 -plane xoy -color black -flyout 35 -label right
53vdimension ld_10 -length -shapes as_40 -plane xoy -color black -flyout 15
54
55vdimension rd_1 -radius -shapes bs_45 -color black -label right
56vdimension rd_2 -radius -shapes bs_63 -color black
57
58vdimension ad_1 -angle -shapes as_38 as_49 -color black
59vdimension ad_2 -angle -shapes bs_24 bs_25 -color black
60vdimension ad_3 -angle -shapes as_48 as_43 -color black
61
1136702b 62puts "Changing text and arrow parameters of dimensions..."
0499eb06 63foreach i $aList {
7a733b19 64 vdimparam $i -text 3d sh 6 -arrowlength 4 -arrowangle $anArrAngle
0499eb06 65}
66
0499eb06 67vfit
68
7a733b19 69puts "Displaying exported shapes..."
0499eb06 70vdisplay a b
71vsetdispmode a 1
72vsetdispmode b 1
73vaspects a -setmaterial steel
74vaspects b -setmaterial bronze
75
7a733b19 76puts "Clipping shapes for better view..."
0499eb06 77vclipplane create pa
78vclipplane change pa equation 0 0 1 0
79vclipplane change pa capping on
80vclipplane change pa capping color 0.9 0.9 0.9
0499eb06 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
0499eb06 87vclipplane set pb object b
88
0499eb06 89vclipplane change pa capping texname $aHatch
90vclipplane change pa capping texscale 0.05 -0.05
91vclipplane change pb capping texname $aHatch
92vclipplane change pb capping texscale 0.05 0.05
93
0499eb06 94vbottom
95vrotate -0.3 -0.3 0
96vfit
97vzoom 1.2
63fad07e 98vrenderparams -msaa 8
7a733b19 99
100puts "Done."