0029311: Implementation of the Oriented Bounding Boxes (OBB) functionality
[occt.git] / samples / tcl / snowflake.tcl
CommitLineData
92ac0eb7 1# Creation of 2d drawing
2
031224c9 3#Category: Modeling
4#Title: Snowflake - creation of 2d drawing
92ac0eb7 5
6pload MODELING AISV
7
031224c9 8puts "Generating sample drawing of snowflake..."
9
92ac0eb7 10# make circular elements
11circle c11 5 5 0 5
12circle c12 5 5 0 3
13circle c21 18 7 0 7
14circle c22 18 7 0 5
15circle c31 28.5 5 0 5
16circle c32 28.5 5 0 3
17trim c21 c21 pi/4 -pi/4
18trim c22 c22 pi/4 -pi/4
19trim c31 c31 pi/4 -pi/4
20trim c32 c32 pi/4 -pi/4
21line l21 18 7 0 1 1 0
22line l22 18 7 0 1 -1 0
23line l31 28.5 5 0 1 1 0
24line l32 28.5 5 0 1 -1 0
25trim l21 l21 5 7
26trim l22 l22 5 7
27trim l31 l31 3 5
28trim l32 l32 3 5
29line l1 -6 0 0 0.86602540378443864 0.5 0
30line l2 -6 1 0 1 0 0
31trim l1 l1 0 30
32trim l2 l2 0 45
33mkedge c11 c11
34mkedge c12 c12
35mkedge c21 c21
36mkedge c22 c22
37mkedge c31 c31
38mkedge c32 c32
39mkedge l21 l21
40mkedge l22 l22
41mkedge l31 l31
42mkedge l32 l32
43mkedge l1 l1
44mkedge l2 l2
45wire b11 c11
46wire b12 c12
47orientation b12 R
48
49# build one ray
50plane p -6 0 0 0 0 1
51mkface f1 p b11
52add b12 f1
53wire b2 c21 l21 c22 l22
54mkface f2 p b2
55wire b3 c31 l31 c32 l32
56mkface f3 p b3
57prism f5 l1 -5 8.6602540378443864 0
58prism f4 l2 0 -1 0
59compound f1 f2 f3 bc
60bfuse r bc f4
92ac0eb7 61bcut r r f5
977ad983 62tcopy r r1
63tmirror r1 -6 0 0 0 1 0
64bfuse w r r1
65unifysamedom w w
92ac0eb7 66donly w
67
68# construct complete snowflake
69tcopy w w1
70tcopy w w2
71tcopy w w3
72tcopy w w4
73tcopy w w5
74trotate w1 -6 0 0 0 0 1 60
75trotate w2 -6 0 0 0 0 1 120
76trotate w3 -6 0 0 0 0 1 180
77trotate w4 -6 0 0 0 0 1 240
78trotate w5 -6 0 0 0 0 1 300
79bfuse w w w1
80bfuse w w w2
81bfuse w w w3
82bfuse w w w4
83bfuse w w w5
fe1a6e4e 84shape wsh Sh
85foreach f [explode w f] {add $f wsh}
86renamevar wsh w
92ac0eb7 87unifysamedom r w
88
89# keep only wires in compound
90eval compound [explode r w] snowflake
91tscale snowflake -6 0 0 1.5
92
93# draw frame loosely following GOST 2.104-68
94polyline frame -100 -100 0 172 -100 0 172 100 0 -100 100 0 -100 -100 0
95polyline t1 52 -100 0 52 -45 0 172 -45 0
96polyline t2 52 -60 0 172 -60 0
97polyline t3 52 -85 0 172 -85 0
98polyline t4 122 -100 0 122 -60 0
99polyline t5 122 -80 0 172 -80 0
100polyline t6 122 -65 0 172 -65 0
101polyline t7 142 -80 0 142 -85 0
102polyline t8 137 -80 0 137 -60 0
103polyline t9 154 -80 0 154 -60 0
104compound frame t1 t2 t3 t4 t5 t6 t7 t8 t9 lines
105
106# add text
ac84fcf6 107text2brep sample "SAMPLE" -font Arial -height 10 -pos 90 -55 0 -aspect bolditalic
108text2brep occ "Open CASCADE" -font Times -height 6 -pos 125 -95 0
109text2brep name "Snowflake" -font Courier -height 7 -pos 65 -75 0 -aspect italic
110text2brep material "Ice" -font Courier -height 7 -pos 75 -95 0 -aspect italic
111text2brep sheets "Sheets 1" -font Courier -height 3.5 -pos 145 -83 0 -aspect italic
112text2brep scale "Scale\n\n1:100" -font Courier -height 3.5 -pos 157 -63 0 -aspect italic -valign topfirstline
113text2brep mass "Mass\n\n1 mg" -font Courier -height 3.5 -pos 140 -63 0 -aspect italic -valign topfirstline
92ac0eb7 114eval compound [explode sample w] sample
115eval compound [explode occ w] occ
116eval compound [explode name w] name
117eval compound [explode material w] material
118eval compound [explode sheets w] sheets
119eval compound [explode scale w] scale
120eval compound [explode mass w] mass
121compound sample occ name material sheets scale mass text
122
031224c9 123compound snowflake lines text drawing
92ac0eb7 124
125# display in 3d view
126vinit Driver1/Viewer1/View1 w=1024 h=768
127vdisplay snowflake lines text
63fad07e 128vrenderparams -msaa 8
031224c9 129vsetcolor snowflake 0 0 0
130vsetcolor lines 0 0 0
131vsetcolor text 0 0 0
132vsetcolorbg 255 255 255
92ac0eb7 133vtop
031224c9 134vfit
135
f16a6cc5 136# add dimension:
137# detect vertices extremal in X direction
1a0339b4 138bounding -s snowflake -save x1 y1 z1 x2 y2 z2
f16a6cc5 139plane f1 x1 0 0 1 0 0
140plane f2 x2 0 0 1 0 0
141mkface f1 f1
142mkface f2 f2
143bsection s1 snowflake f1
144bsection s2 snowflake f2
145# select only upper vertices (nearer to the upper bound)
146explode s1 v
147explode s2 v
148plane fup 0 y2 0 0 1 0
149mkface fup fup
150for {set i 1} {$i <= 2} {incr i} {
151 set dmin 1e10
152 for {set j 1} {$j <= 2} {incr j} {
153 distmini d s${i}_$j fup
154 set dist [dval d_val]
155 if {$dmin > $dist} {
156 set dmin $dist
157 eval set v$i s${i}_$j
158 }
159 }
160}
161vdimension length -length -shapes $v1 $v2 -plane xoy -value 0.001 -dispunits mm -showunits -flyout 70 -label above -color black -text 5 3d sh
031224c9 162
163if { [regexp HAVE_GL2PS [dversion]] } {
164 puts "You can use command vexport to generate PDF: vexport your_file_path.pdf"
165}