f8e28d2b0161564881554ac049195cc4e2d0b232
[occt.git] / samples / tcl / ANC101.tcl
1 # The following example constructs ANC-101 object of CAM-I.
2 #
3 # This model was used as a test part for comparing modeling systems in 1979 and
4 # again in 1983. The tests were organized by Computer Aided Manufacturing
5 # International (CAM-I).
6 #
7 #Category: Modeling
8 #Title: ANC101 (classic test for CAD modeling from CAM-I)
9
10 pload MODELING
11
12 set my_pi 3.1415926535897931
13 set aModelHeight 178.25
14 set aPlatformLength 426.25
15 set aPlatformWidth 201.5
16 set aPlatformHeight 58.9
17 set aPrismLength 279
18 set aPrismWidth 155
19 set aPrismHeight [expr $aModelHeight - $aPlatformHeight]
20 set aPrismXOffset [expr $aPlatformLength - $aPrismLength - 69.75]
21 set aPrismYOffset [expr ($aPlatformWidth - $aPrismWidth)/2]
22
23 #================================================================================
24 # A base of the model
25 box _platform $aPlatformLength $aPlatformWidth $aPlatformHeight
26
27 # Make screw holes on the platform
28 set aScrewHoleRadius [expr 26.2/2]
29 set aScrewHoleOffset 31
30 pcylinder _screwhole $aScrewHoleRadius $aPlatformHeight
31 ttranslate _screwhole $aScrewHoleOffset $aScrewHoleOffset 0
32 bcut _platform _platform _screwhole
33 reset _screwhole
34 ttranslate _screwhole [expr $aPlatformLength - $aScrewHoleOffset] $aScrewHoleOffset 0
35 bcut _platform _platform _screwhole
36 reset _screwhole
37 ttranslate _screwhole [expr $aPlatformLength - $aScrewHoleOffset] [expr $aPlatformWidth - $aScrewHoleOffset] 0
38 bcut _platform _platform _screwhole
39 reset _screwhole
40 ttranslate _screwhole $aScrewHoleOffset [expr $aPlatformWidth - $aScrewHoleOffset] 0
41 bcut _platform _platform _screwhole
42 reset _screwhole
43
44 # Back side cave
45 set aCaveLength 81.38
46 set aCaveDepth 10
47 set aCaveWidth 19.38
48 set aBottomLevel [expr $aPlatformHeight/2 - $aCaveWidth/2]
49 set aTopLevel [expr $aPlatformHeight/2 + $aCaveWidth/2]
50 beziercurve t_bcurve 4  0 $aCaveLength $aBottomLevel  3  0 [expr $aCaveLength + $aCaveWidth/2] $aBottomLevel 6  0 [expr $aCaveLength + $aCaveWidth/2] $aTopLevel 6  0 $aCaveLength $aTopLevel 3
51 vertex t_v1 0 $aCaveLength $aBottomLevel
52 vertex t_v2 0 $aCaveLength $aTopLevel
53 mkedge t_e1 t_bcurve
54 edge t_e2 t_v1 t_v2
55 wire t_w t_e1 t_e2
56 mkplane t_f1 t_w
57 prism t_s1 t_f1 $aCaveDepth 0 0
58 box t_s2 0 0 $aBottomLevel $aCaveDepth $aCaveLength $aCaveWidth
59 bfuse _backcave t_s1 t_s2
60 bcut _platform _platform _backcave
61
62 # Right side cave
63 set aRCaveRadius 26.2
64 set aRCaveDistToSection 15.5
65 set aCurveParam [expr ($my_pi - acos($aRCaveDistToSection/$aRCaveRadius))]
66 set aRCaveCenterX [expr $aPlatformLength - 162.75]
67 set aRCaveCenterZ [expr $aPlatformHeight/2]
68 circle t_circle $aRCaveCenterX 0 $aRCaveCenterZ 0 1 0 1 0 0 $aRCaveRadius
69 trim t_curve t_circle -$aCurveParam $aCurveParam
70 mkedge t_e1 t_curve
71 cvalue t_curve -$aCurveParam t_x t_y t_z
72 vertex t_v1 t_x t_y t_z
73 cvalue t_curve $aCurveParam t_x t_y t_z
74 vertex t_v2 t_x t_y t_z
75 edge t_e2 t_v1 t_v2
76 wire t_w t_e1 t_e2
77 mkplane t_f t_w
78 prism t_s t_f 0 $aCaveDepth 0
79 bcut _platform _platform t_s
80
81 # Caves on front side
82 set aFCaveCirclesRadius 4.65
83 set aFCaveBottomWidth 37.8
84 set aFCaveHeight 38.75
85 set aFCaveTopWidth 27
86 set aFCaveSmallCircleRadius 9.3
87 circle t_circle1 [expr $aFCaveTopWidth/2] [expr $aFCaveHeight/2] $aFCaveCirclesRadius
88 circle t_circle2 [expr -$aFCaveTopWidth/2] [expr $aFCaveHeight/2] $aFCaveCirclesRadius
89 circle t_circle3 [expr -$aFCaveBottomWidth/2] [expr -$aFCaveHeight/2] $aFCaveCirclesRadius
90 circle t_circle4 [expr $aFCaveBottomWidth/2] [expr -$aFCaveHeight/2] $aFCaveCirclesRadius
91
92 lintan t_l t_circle1 t_circle2
93 trim t_side1 t_l_1 0 $aFCaveTopWidth
94
95 lintan t_l t_circle2 t_circle3
96 trim t_side2 t_l_1 0 39.058577803089555
97
98 lintan t_l t_circle3 t_circle4
99 trim t_side3 t_l_1 0 $aFCaveBottomWidth
100
101 lintan t_l t_circle4 t_circle1
102 trim t_side4 t_l_1 0 39.196587861700415
103
104 trim t_circle1 t_circle1 0.15109758878146562 1.5707963267948966 
105 trim t_circle2 t_circle2 1.5707963267948966 3.0158086349284448
106 trim t_circle3 t_circle3 3.0158086349284448 4.7123889803846897 
107 trim t_circle4 t_circle4 4.7123889803846897 0.15109758878146562 
108
109 plane t_plane 0 0 0 1 0 0 0 1 0
110
111 to3d t_circle1 t_circle1 t_plane
112 to3d t_circle2 t_circle2 t_plane
113 to3d t_circle3 t_circle3 t_plane
114 to3d t_circle4 t_circle4 t_plane
115 to3d t_side1 t_side1 t_plane
116 to3d t_side2 t_side2 t_plane
117 to3d t_side3 t_side3 t_plane
118 to3d t_side4 t_side4 t_plane
119
120 mkedge t_e1 t_circle1
121 mkedge t_e2 t_side1
122 mkedge t_e3 t_circle2
123 mkedge t_e4 t_side2
124 mkedge t_e5 t_circle3
125 mkedge t_e6 t_side3
126 mkedge t_e7 t_circle4
127 mkedge t_e8 t_side4
128
129 wire t_w t_e1 t_e2 t_e3 t_e4 t_e5 t_e6 t_e7 t_e8
130 mkplane t_f t_w
131 prism t_s1 t_f -$aCaveDepth 0 0
132
133 circle t_circle 0 [expr $aFCaveTopWidth/2 + $aFCaveBottomWidth/2] 0 1 0 0 $aFCaveSmallCircleRadius
134 mkedge t_e t_circle
135 wire t_w t_e
136 mkplane t_f t_w
137 prism t_s2 t_f [expr -$aCaveDepth/2] 0 0
138
139 box t_s3 0 0 -$aFCaveSmallCircleRadius  [expr -$aCaveDepth/2] [expr $aFCaveTopWidth/2 + $aFCaveBottomWidth/2] [expr $aFCaveSmallCircleRadius*2]
140
141 # Compile elements
142 bfuse t_s2 t_s2 t_s3
143 bfuse _frontcave t_s1 t_s2
144 unifysamedom _frontcave _frontcave
145
146 # Cut this cave from the platform
147 ttranslate _frontcave $aPlatformLength [expr $aPlatformWidth*2/3] [expr $aPlatformHeight/2]
148 bcut _platform _platform _frontcave
149
150 tmirror _frontcave $aPlatformLength [expr $aPlatformWidth/2] [expr $aPlatformHeight/2] 0 1 0
151 bcut _platform _platform _frontcave
152
153 #================================================================================
154 # A wedge on the platform
155 box t_box  $aPrismXOffset $aPrismYOffset $aPlatformHeight $aPrismLength $aPrismWidth $aPrismHeight
156
157 set aCutwedgeLength [expr $aPrismHeight/0.57735]
158 wedge _cutwedge $aPlatformLength [expr $aPrismYOffset + $aPrismWidth] $aModelHeight 0 -1 0 -1 0 0 $aCutwedgeLength $aPrismHeight $aPrismWidth 0
159
160 bcut _prism t_box _cutwedge
161
162 # Make 9 small holes on a top side
163 set aWedgeSmallHolesRadius 7.68
164 set aWedgeSmallHolesOrbit 67.81
165 set aWedgeHoleXPos [expr $aPrismXOffset + 77.5]
166 set aWedgeHoleYPos [expr $aPrismYOffset + 77.5]
167
168 plane t_plane $aWedgeHoleXPos $aWedgeHoleYPos [expr $aPlatformHeight + $aPrismHeight/2] 0 0 1 1 0 0
169 pcylinder t_cyl t_plane $aWedgeSmallHolesRadius [expr $aPrismHeight/2]
170
171 set i 2
172 while {$i <= 10} {ttranslate t_cyl [expr $aWedgeSmallHolesOrbit*cos($i*$my_pi/6)] [expr $aWedgeSmallHolesOrbit*sin($i*$my_pi/6)] 0; bcut _prism _prism t_cyl; reset t_cyl; incr i}
173
174 # Make a cylinder on a canted side
175 set aWedgeCylinderRadius 38.75
176 set aWedgeCylinderHeight 38.75
177 set aWedgeCantedHeight [expr tan($my_pi/6)*($aCutwedgeLength - 69.75)]
178 set aWedgeCylinderZPos [expr $aModelHeight - $aWedgeCantedHeight/2]
179 plane t_plane [expr $aPrismXOffset + $aPrismLength*3/4] [expr $aPrismYOffset + $aPrismWidth/2] $aWedgeCylinderZPos cos($my_pi/3) 0 sin($my_pi/3) 0 1 0
180 pcylinder t_cyl t_plane $aWedgeCylinderRadius $aWedgeCylinderHeight
181 explode t_cyl e
182 blend t_cyl t_cyl 3 t_cyl_1
183 bfuse _prism _prism t_cyl
184 unifysamedom _prism _prism
185
186 # Make a hole in the cylinder on the wedge
187 pcylinder t_cyl t_plane [expr $aWedgeCylinderRadius/2] 100
188 ttranslate t_cyl [expr -60*cos($my_pi/3)] 0 [expr -60*sin($my_pi/3)]
189 bcut _prism _prism t_cyl
190
191 # Make a hole on a right side of the wedge
192 plane t_plane [expr $aPlatformLength - 162.75] $aPrismYOffset [expr $aModelHeight - $aWedgeCantedHeight] 0 1 0 1 0 0
193 pcylinder t_cyl t_plane 13.1 [expr $aPrismWidth/2]
194 bcut _prism _prism t_cyl
195
196 # Fuse the platform and the prism
197 bfuse _model _platform _prism
198
199 # Make a pass-through hole
200 set aWedgeHoleInnerRadius 38.77
201 set aWedgeHoleOuterRadius 58.13
202 set aWedgeHoleBottomInnerRadius 50.38
203
204 # Cylinders from bottom to top
205 plane t_plane $aWedgeHoleXPos $aWedgeHoleYPos 0
206 pcylinder t_cyl1 t_plane $aWedgeHoleOuterRadius 10
207 pcylinder t_cyl2 t_plane $aWedgeHoleBottomInnerRadius 10
208 pcylinder t_cyl3 t_plane $aWedgeHoleInnerRadius [expr $aModelHeight - 30]
209 pcylinder t_cyl4 t_plane $aWedgeHoleOuterRadius 10
210
211 ttranslate t_cyl2 0 0 10
212 ttranslate t_cyl3 0 0 20
213 ttranslate t_cyl4 0 0 [expr $aModelHeight - 10]
214
215 bfuse _cutCylindricShape t_cyl1 t_cyl2
216 bfuse _cutCylindricShape _cutCylindricShape t_cyl3
217 bfuse _cutCylindricShape _cutCylindricShape t_cyl4
218
219 bcut _model _model _cutCylindricShape
220
221 # Add a block on left side
222 circle t_circle1 0 0 38.75
223 circle t_circle2 [expr 38.75 + 9.3] [expr -57.35 + 9.3] 9.3
224 circle t_circle3 [expr -38.75 - 9.3] [expr -57.35 + 9.3] 9.3
225
226 lintan t_l t_circle1 t_circle2
227 trim t_line12 t_l_2 0 48.05
228
229 lintan t_l t_circle2 t_circle3
230 trim t_line23 t_l_3 0 96.1
231
232 lintan t_l t_circle3 t_circle1
233 trim t_line31 t_l_4 0 48.05
234
235 trim t_circle1 t_circle1 0 $my_pi
236 trim t_circle2 t_circle2 $my_pi 4.7123889803846897
237 trim t_circle3 t_circle3 4.7123889803846897 6.2831853071795862
238
239 reverse t_circle1
240
241 plane t_plane [expr $aPrismXOffset + 77.5] [expr $aPrismYOffset + $aPrismWidth] [expr $aPlatformHeight + 57.35] 0 1 0 -1 0 0
242
243 to3d t_circle1 t_circle1 t_plane
244 to3d t_circle2 t_circle2 t_plane
245 to3d t_circle3 t_circle3 t_plane
246 to3d t_line12 t_line12 t_plane
247 to3d t_line23 t_line23 t_plane
248 to3d t_line31 t_line31 t_plane
249
250 mkedge t_e1 t_circle1
251 mkedge t_e2 t_line31
252 mkedge t_e3 t_circle3
253 mkedge t_e4 t_line23
254 mkedge t_e5 t_circle2
255 mkedge t_e6 t_line12
256
257 wire t_w t_e1 t_e2 t_e3 t_e4 t_e5 t_e6
258 mkplane t_f t_w
259 prism t_s t_f 0 $aCaveDepth 0
260
261 bfuse _model _model t_s
262
263 # Make fillets
264 explode _model e
265
266 # Make a weld at joint edges of platform and wedge 
267 blend _model _model 2 _model_28
268 blend _model _model 2 _model_29
269 blend _model _model 2 _model_30
270 blend _model _model 2 _model_31
271 blend _model _model 2 _model_33
272
273 # Cylinder on wedge
274 blend result _model 2 _model_161
275
276 # Show result
277 pload VISUALIZATION
278 vinit Driver1/Viewer1/View1
279 vsetcolorbg 200 200 255
280 vdisplay result
281 vfit
282 vsetdispmode 1
283 vshowfaceboundary result 1