7c8e15a79122627897eb6d3b66bbe536cbd15567
[occt.git] / samples / tcl / snowflake.tcl
1 # Creation of 2d drawing
2
3 #Category: Modeling 
4 #Title: Snowflake - creation of 2d geometry
5
6 pload MODELING AISV
7
8 # make circular elements
9 circle c11 5 5 0 5
10 circle c12 5 5 0 3
11 circle c21 18 7 0 7
12 circle c22 18 7 0 5
13 circle c31 28.5 5 0 5
14 circle c32 28.5 5 0 3
15 trim c21 c21 pi/4 -pi/4
16 trim c22 c22 pi/4 -pi/4
17 trim c31 c31 pi/4 -pi/4
18 trim c32 c32 pi/4 -pi/4
19 line l21 18 7 0 1 1 0
20 line l22 18 7 0 1 -1 0
21 line l31 28.5 5 0 1 1 0
22 line l32 28.5 5 0 1 -1 0
23 trim l21 l21 5 7
24 trim l22 l22 5 7
25 trim l31 l31 3 5
26 trim l32 l32 3 5
27 line l1 -6 0 0 0.86602540378443864 0.5 0
28 line l2 -6 1 0 1 0 0
29 trim l1 l1 0 30
30 trim l2 l2 0 45
31 mkedge c11 c11
32 mkedge c12 c12
33 mkedge c21 c21
34 mkedge c22 c22
35 mkedge c31 c31
36 mkedge c32 c32
37 mkedge l21 l21
38 mkedge l22 l22
39 mkedge l31 l31
40 mkedge l32 l32
41 mkedge l1 l1
42 mkedge l2 l2
43 wire b11 c11
44 wire b12 c12
45 orientation b12 R
46
47 # build one ray
48 plane p -6 0 0 0 0 1
49 mkface f1 p b11
50 add b12 f1
51 wire b2 c21 l21 c22 l22
52 mkface f2 p b2
53 wire b3 c31 l31 c32 l32
54 mkface f3 p b3
55 prism f5 l1 -5 8.6602540378443864 0
56 prism f4 l2 0 -1 0
57 compound f1 f2 f3 bc
58 bfuse r bc f4
59 explode r Sh
60 renamevar r_1 r
61 bcut r r f5
62 explode r Sh
63 renamevar r_1 r
64 explode r e
65 wire w r_4 r_1 r_7 r_8 r_9 r_10 r_11 r_12 r_13 r_14 r_22 r_23 r_24 r_25 r_19 r_20 r_21 r_26 r_35 r_31 r_32 r_33 r_34 r_36 r_37
66 tcopy w w1
67 tmirror w1 -6 0 0 0 1 0
68 wire w w w1
69 mkface w p w
70 donly w
71
72 # construct complete snowflake
73 tcopy w w1
74 tcopy w w2
75 tcopy w w3
76 tcopy w w4
77 tcopy w w5
78 trotate w1 -6 0 0 0 0 1 60
79 trotate w2 -6 0 0 0 0 1 120
80 trotate w3 -6 0 0 0 0 1 180
81 trotate w4 -6 0 0 0 0 1 240
82 trotate w5 -6 0 0 0 0 1 300
83 bfuse w w w1
84 bfuse w w w2
85 bfuse w w w3
86 bfuse w w w4
87 bfuse w w w5
88 unifysamedom r w
89
90 # keep only wires in compound
91 eval compound [explode r w] snowflake
92 tscale snowflake -6 0 0 1.5
93
94 # draw frame loosely following GOST 2.104-68
95 polyline frame -100 -100 0 172 -100 0 172 100 0 -100 100 0 -100 -100 0
96 polyline t1 52 -100 0 52 -45 0 172 -45 0
97 polyline t2 52 -60 0 172 -60 0
98 polyline t3 52 -85  0 172 -85 0
99 polyline t4 122 -100 0 122 -60 0
100 polyline t5 122 -80 0 172 -80 0
101 polyline t6 122 -65 0 172 -65 0
102 polyline t7 142 -80 0 142 -85 0
103 polyline t8 137 -80 0 137 -60 0
104 polyline t9 154 -80 0 154 -60 0
105 compound frame t1 t2 t3 t4 t5 t6 t7 t8 t9 lines
106
107 # add text
108 text2brep sample "SAMPLE" Arial 10 x=90 y=-55 bolditalic
109 text2brep occ "Open CASCADE" Times 6 x=125 y=-95 
110 text2brep name "Snowflake" Courier 7 x=65 y=-75 italic
111 text2brep material "Ice" Courier 7 x=75 y=-95 italic
112 text2brep sheets "Sheets 1" Courier 3.5 x=145 y=-83 italic
113 text2brep scale "Scale\n\n1:100" Courier 3.5 x=157 y=-63 italic
114 text2brep mass "Mass\n\n1 mg" Courier 3.5 x=140 y=-63 italic
115 eval compound [explode sample w] sample
116 eval compound [explode occ w] occ
117 eval compound [explode name w] name
118 eval compound [explode material w] material
119 eval compound [explode sheets w] sheets
120 eval compound [explode scale w] scale
121 eval compound [explode mass w] mass
122 compound sample occ name material sheets scale mass text
123
124 compound snowflake frame text drawing
125
126 # display in 3d view
127 vinit Driver1/Viewer1/View1 w=1024 h=768
128 vdisplay snowflake lines text
129 vtop
130 vfit