0026605: Possible array out of bounds read in Extrema_GExtPC.gxx
[occt.git] / samples / tcl / cpu.tcl
CommitLineData
5bffb882 1# Sample model of Intel i7-4790 CPU
2# Dimensions are taken from specs and foto found in Internet
3
4#Category: XDE
5#Title: Intel i7-4790 CPU
6
7pload MODELING VISUALIZATION XDE
8
9puts "Making board..."
10
11# board is rectangle 37.5 x 37.5 mm with semi-round holes on two sides;
12# assumed board thickness is 1 mm
13dset L 37.5
14dset t 1.
15polyline pboard 0 0 0 L 0 0 L L 0 0 L 0 0 0 0
16mkplane fboard pboard
17circle cslot -0.2 32.2 0 1
18mkedge eslot cslot
19wire wslot eslot
20mkplane fslot wslot
21bcut fboard fboard fslot
22ttranslate fslot L+0.4 0 0
23bcut fboard fboard fslot
24prism board fboard 0 0 t
25
26# make faces representing dard-green parts of the board sides
27mkoffset dgbot fboard 1 -0.5
28mkplane dgbot dgbot_1
29tcopy dgbot dgtop
30ttranslate dgtop 0 0 0.5*t
31box aux 36.6 17.7 0 10 8.4 2*t
32bcut dgtop dgtop aux
33prism pbot dgbot 0 0 0.5*t
34prism ptop dgtop 0 0 0.5*t
35bfuse board board pbot
36bfuse board board ptop
37
38# add triangular faces indicating base corner of the plate
39polyline btri 0.5 0.5 0 1.5 0.5 0 0.5 1.5 0 0.5 0.5 0
40polyline ttri 0.5 0.5 t 2.5 0.5 t 0.5 2.5 t 0.5 0.5 t
41thrusections stri 1 1 btri ttri
42bfuse board board stri
43
44explode board so
45renamevar board_1 board
46
47puts "Making case..."
48
49# case is made of two filleted prisms, base and top
50polyline lbase 3.4 1.8 t L-3.4 1.8 t L-3.4 11.4 t L-1.8 11.4 t L-1.8 25.2 t \
51 L-3.4 25.2 t L-3.4 L-3 t 3.4 L-3 t 3.4 25.2 t \
52 1.8 25.2 t 1.8 11.4 t 3.4 11.4 t 3.4 1.8 t
53mkplane f lbase
54explode f e
55chfi2d fbase f f_1 f_2 F 1.3 f_2 f_3 F 0.7 f_3 f_4 F 0.7 f_4 f_5 F 0.7 \
56 f_5 f_6 F 0.7 f_6 f_7 F 1.3 f_7 f_8 F 1.3 f_8 f_9 F 0.7 \
57 f_9 f_10 F 0.7 f_10 f_11 F 0.7 f_11 f_12 F 0.7 f_12 f_1 F 1.3
58
59polyline ltop 4. 3.4 t L-4 3.4 t L-4 L-4.8 t 4 L-4.8 t 4. 3.4 t
60mkplane f ltop
61explode f e
62chfi2d ftop f f_1 f_2 F 1.6 f_2 f_3 F 1.6 f_3 f_4 F 1.6 f_4 f_1 F 1.6
63
64# make case, assume height of base 1 mm and top additional 2.5 mm
65prism pbase fbase 0 0 1
66prism ptop ftop 0 0 3.5
67bfuse case pbase ptop
68
69explode case so
70renamevar case_1 case
71
72# write text on top of the case
73# note that font is chosen by availability of Unicode symbols,
74# it is different from actual font found on processor
75set font "Arial Unicode MS"
76#set text "i\u24c2\u00a911\nINTEL\u00ae CORE\u2122 i7-4790\nSR1QF 3.60GHZ\nMALAY\nL411B540 \u24d4"
77#text2brep title $text "Arial Unicode MS" 1.7 x=10 y=24 z=4.51
78# alternative variant to work-around issue #25852
79set text "i\u20dd\u20dd11\nINTEL\u20dd CORE\u2122 i7-4790\nSR1QF 3.60GHZ\nMALAY\nL411B540 \u20dd"
ac84fcf6 80text2brep title0 $text -font $font -height 1.7 -pos 10 24 4.51 -valign topfirstline
81text2brep title1 " M C" -font $font -height 0.77 -pos 10 24.2 4.51
82text2brep title2 "R" -font $font -height 0.77 -pos 15.3 21.9 4.51
83text2brep title3 "e4" -font $font -height 0.7 -pos 18.6 15.1 4.51
5bffb882 84compound title0 title1 title2 title3 title
85
86puts "Adding contact pads..."
87
88# contact pads on top side (round); we need 42 with R=0.3 and 1 with R=0.6
89pcylinder rpad 0.27 0.1
90eval compound [lrepeat 42 rpad] cpad
91set lpad [explode cpad]
92for {set i 1} {$i <= 20} {incr i} {
93 ttranslate cpad_[expr 2*$i ] [expr 4.5 + $i * 0.7] L-0.7 t
94 ttranslate cpad_[expr 2*$i-1] [expr 4.85 + $i * 0.7] L-1.3 t
95}
96ttranslate cpad_41 L-0.7 L-0.7 t
97ttranslate cpad_42 L-0.7 0.7 t
98pcylinder Rpad 0.5 0.1
99ttranslate Rpad 0.9 L-0.9 t
100eval compound $lpad Rpad rpads
101
102# contact pads at the bottom
103box pad -0.45 -0.27 -0.1 0.9 0.54 0.1
104trotate pad 0 0 0 0 0 1 60
105ellipse c 0 0 -0.1 0.5 0.4
106mkedge e c
107wire w e
108mkplane f w
109prism b f 0 0 0.1
110bcommon bpad pad b
111explode bpad so
112renamevar bpad_1 bpad
113#donly bpad; boundings bpad
114
115# pattern of presence of bottom pads, on XY plane (top view)
116set pattern [join {
117..ooooooooooooooo...ooooooooooooooooo...
118.oooooooooooooooo...ooooooooooooooooooo.
119.oooooooooooooooooooooooooooooooooooooo.
120.oooooooooooooooooooooooooooooooooooooo.
121.oooooooooooooooooooooooooooooooooooooo.
122.oooooooooooooooooooooooooooooooooooooo.
123.oooooooooooooooooooooooooooooooooooooo.
124.oooooooooooooooooooooooooooooooooooooo.
125.ooooooooooo................ooooooooooo.
126.oooooooooo.................ooooooooooo.
127oooooooooooo................oooooooooooo
128oooooooooooo................oooooooooooo
129oooooooooooo................oooooooooooo
130oooooooooooo................oooooooooooo
131oooooooooooo................oooooooooooo
132oooooooooooo................oooooooooooo
133oooooooooooo................oooooooooooo
134oooooooooooo................oooooooooooo
135..oooooooooo................oooooooooo..
136..oooooooooo................oooooooooo..
137..oooooooooo................oooooooooo..
138..oooooooooo................oooooooooo..
139oooooooooooo................oooooooooooo
140oooooooooooo................oooooooooooo
141oooooooooooo................oooooooooooo
142oooooooooooo................oooooooooooo
143oooooooooooo................oooooooooooo
144oooooooooooo................oooooooooooo
145oooooooooooo................oooooooooooo
146oooooooooooo................oooooooooooo
147.ooooooooooo.................ooooooooooo
148.ooooooooooo................oooooooooooo
149.ooooooooooooooooooooooooooooooooooooooo
150oooooooooooooooooooooooooooooooooooooooo
151oooooooooooooooooooooooooooooooooooooooo
152oooooooooooooooooooooooooooooooooooooooo
153oooooooooooooooooooooooooooooooooooooooo
154.ooooooooooooooooooooooooooooooooooooooo
155..oooooooooooooooo...oooooooooooooooooo.
156...ooooooooooooooo...ooooooooooooooooo..
157} ""]
158
159set nbpads 0
160for {set i 0} {$i < 1600} {incr i} {
161 if { [string index $pattern $i] == "o" } { incr nbpads }
162}
163eval compound [lrepeat $nbpads bpad] cpad
164set lpad [explode cpad]
165for {set ipad 1; set iplace 0} {$ipad <= $nbpads && $iplace < 1600} {incr ipad; incr iplace} {
166 while { [string index $pattern $iplace] == "." } { incr iplace }
167 set icol [expr $iplace % 40]
168 set irow [expr $iplace / 40]
169 ttranslate cpad_$ipad [expr 1 + 0.91 * $icol] [expr [dval L] - 1 - 0.91 * $irow] 0
170}
171
172# round and square contact pads on top side
173# note re-use of rpad object used for bootom round pads
174eval compound [lrepeat 8 rpad] crpads
175set lrpad [explode crpads]
176ttranslate crpads_1 25.3 8.4 -0.1
177ttranslate crpads_2 12.2 29.2 -0.1
178ttranslate crpads_3 12.5 15. -0.1
179ttranslate crpads_4 12.5 18.75 -0.1
180ttranslate crpads_5 12.5 19.5 -0.1
181ttranslate crpads_6 12.5 20.25 -0.1
182ttranslate crpads_7 12.5 21. -0.1
183ttranslate crpads_8 12.5 22.5 -0.1
184box spad_1 12.21 13.75 -0.1 0.58 0.58 0.1
185box spad_2 12.21 23.2 -0.1 0.58 0.58 0.1
186
187# final compound for all bottom pads
188eval compound $lpad $lrpad spad_1 spad_2 bpads
189
190# resistor-like packages at the bottom
191box rpk1 -0.6 -0.25 -0.5 0.3 0.5 0.5
192box rpk2 -0.3 -0.25 -0.5 0.6 0.5 0.5
193box rpk3 0.3 -0.25 -0.5 0.3 0.5 0.5
194compound rpk1 rpk2 rpk3 rpk
195
196eval compound [lrepeat 47 rpk] crpk
197set lrpk [explode crpk]
198# rotate first 26 packages vertically
199for {set i 1} {$i <= 26} {incr i} {trotate crpk_$i 0 0 0 0 0 1 90}
200# first 9 are vertical column on the right side of the bottom view
201for {set i 1} {$i <= 9} {incr i} {
202 ttranslate crpk_$i 13.4 [expr 9.8 + 1.6 * $i] 0
203}
204# next 8 are 2x4 grid in top left corner
205for {set i 1} {$i <= 4} {incr i} {
206 ttranslate crpk_[expr 9 + $i] 23. [expr 21.5 + 1.6 * $i] 0
207 ttranslate crpk_[expr 13 + $i] 24. [expr 21.5 + 1.6 * $i] 0
208}
209# others are translated individually, vertical first, bottom to top
210ttranslate crpk_18 21.5 9.4 0
211ttranslate crpk_19 21.5 11.0 0
212ttranslate crpk_20 21.5 12.6 0
213ttranslate crpk_21 22.5 9.8 0
214ttranslate crpk_22 20.0 12.2 0
215ttranslate crpk_23 24.0 13.6 0
216ttranslate crpk_24 24.0 15.2 0
217ttranslate crpk_25 19.5 16.0 0
218ttranslate crpk_26 20.5 16.0 0
219# now horizontal, bottom to top
220ttranslate crpk_27 23.7 9.5 0
221ttranslate crpk_28 23.7 10.5 0
222ttranslate crpk_29 22.8 11.5 0
223ttranslate crpk_30 22.8 12.5 0
224ttranslate crpk_31 22.7 14.3 0
225ttranslate crpk_32 22.7 16.0 0
226ttranslate crpk_33 22.8 17.0 0
227ttranslate crpk_34 22.8 19.1 0
228ttranslate crpk_35 22.7 20.0 0
229ttranslate crpk_36 23.0 20.9 0
230ttranslate crpk_37 23.3 21.8 0
231
232ttranslate crpk_38 19.8 21.6 0
233ttranslate crpk_39 19.8 22.6 0
234ttranslate crpk_40 19.8 23.6 0
235ttranslate crpk_41 21.6 22.2 0
236ttranslate crpk_42 21.6 23.2 0
237ttranslate crpk_43 21.6 24.2 0
238
239ttranslate crpk_44 18.0 24.6 0
240ttranslate crpk_45 18.0 25.6 0
241ttranslate crpk_46 18.0 26.6 0
242ttranslate crpk_47 18.0 27.6 0
243
244eval compound $lrpk brpk
245
246# show result in plain 3d viewer
247if [info exists i7_show_3dview] {
248 vinit Driver1/Viewer1/View1
249 vclear
250 vsetdispmode 1
251
252 vlight clear
253 vlight add amb
254 vlight add directional direction 1 -1 -2 head 1
255
256 vdisplay case
257 vsetcolor case 0.7 0.7 0.7
258
259 vdisplay title
260 vsetcolor title 0.1 0.1 0.1
261
262 # board is mostly yellow (edges, triangle markers)
263 foreach f [explode board f] { vdisplay $f; vsetcolor $f 0.7 0.5 0.3 }
264 # top and bottom faces are light-green (outside) and dark-green (inside)
265 vsetcolor board_4 0 0.6 0.55
266 vsetcolor board_5 0 0.6 0.55
267 vsetcolor board_12 0 0.3 0.33
268 vsetcolor board_15 0 0.3 0.33
269
270 vdisplay rpads
271 vsetcolor rpads 0.7 0.6 0.4
272
273 vdisplay bpads
274 vsetcolor bpads 0.7 0.6 0.4
275
276 vdisplay brpk
277 vsetcolor brpk 0.5 0.4 0.3
278
279 donly board case rpads brpk; fit
280}
281
282# make XDE document
283catch {Close D}
284pload OCAF XDE
285
286NewDocument D MDTV-XCAF
287
288SetName D [XAddShape D board 0] "Board"
289foreach f [explode board f] { XSetColor D $f 0.7 0.5 0.3 }
290XSetColor D board_4 0 0.6 0.55
291XSetColor D board_5 0 0.6 0.55
292XSetColor D board_12 0 0.3 0.33
293XSetColor D board_15 0 0.3 0.33
294
295SetName D [XAddShape D case 0] "Case"
296XSetColor D case 0.7 0.7 0.7
297
298SetName D [XAddShape D title 0] "Case title"
299XSetColor D title 0.1 0.1 0.1
300
301SetName D [XAddShape D rpads 1] "Top side contact pads"
302SetName D [XAddShape D bpads 1] "Bottom contact pads"
303SetName D [XFindShape D bpad] "Contact pad"
304SetName D [XFindShape D rpad] "Round pad"
305SetName D [XFindShape D Rpad] "Big round pad"
306SetName D [XFindShape D spad_1] "Square pad 1"
307SetName D [XFindShape D spad_2] "Square pad 2"
308XSetColor D rpad 0.7 0.6 0.4
309XSetColor D Rpad 0.7 0.6 0.4
310XSetColor D bpad 0.7 0.6 0.4
311XSetColor D spad_1 0.7 0.6 0.4
312XSetColor D spad_2 0.7 0.6 0.4
313
314SetName D [XAddShape D brpk 1] "Bottom packages"
315SetName D [XFindShape D rpk] "Bottom package"
316XSetColor D rpk1 0.7 0.7 0.7
317XSetColor D rpk2 0.5 0.4 0.3
318XSetColor D rpk3 0.7 0.7 0.7
319
320XShow D
321vlight clear
322vlight add amb
323vlight add directional direction 1 -1 -2 head 1
324vsetdispmode 1
325vfit
326
327# save to STEP if variable i7_save_xde is defined (specifies file name)
328if [info exists i7_save_xde] {
329 param write.surfacecurve.mode 0
330 WriteStep D $i7_save_xde
331}