0026342: No materials are read from STEP
[occt.git] / tests / bugs / modalg_5 / bug24758_2
CommitLineData
07b5cb8f 1puts "==========="
2puts "OCC24758"
3puts "==========="
4puts ""
5##############################################################
6# Sample Draw scripts for demonstrating sweeping algorithm
7##############################################################
8
1cc4346c 9if { [regexp {Debug mode} [dversion]] } {
f49c3109 10 cpulimit 3000
1cc4346c 11}
12
07b5cb8f 13# drill parameters (some terms taken from http://www.drill-bits.cn/drill-bits-quality.asp)
14dset R 4. ;# outer radius
15dset D 2*R ;# diameter
16dset Rr 3.5 ;# chisel radius (outer radius minus body clearance)
17
18dset b 1. ;# web thickness (approximate)
19dset d b/2
20
21dset H 80. ;# height of the spiral part
22dset a 3.*pi ;# total angle of spiral rotation
23
24dset sigma 118 ;# point angle, in degrees
25
26# Create section profile by sequence of Boolean operations
27# on simple planar objects
28puts "Creating the drill section profile..."
29polyline rectangle1 d -R 0 R -R 0 -d R 0 -R R 0 d -R 0
30
31circle circle1 0 0 0 0 0 1 R
32mkedge circle1 circle1
33wire circle1 circle1
34
35circle circle2 0 0 0 0 0 1 Rr
36mkedge circle2 circle2
37wire circle2 circle2
38
39plane p0
40mkface rectangle1 p0 rectangle1
41mkface circle1 p0 circle1
42mkface circle2 p0 circle2
43
44bcommon sec rectangle1 circle1
45# note use of 'fuse' instead of 'bfuse' -- we need to get single face
46fuse sec sec circle2
47
48# Construct flute profile so as to have cutting lip straight after sharpening.
49# Here we need to take into account spiral shift of the flute edge
50# along the point length -- the way to do that is to make spiral
51# from the desired cutting lip edge and then intersect it by plane
52polyline lip d -d/2 0 d -R -R/tan(sigma/2*pi/180)
53
54polyline sp 0 0 0 0 0 H
55cylinder cc 0 0 0 0 0 1 0 -4 0 4
56line ll 0 0 a 80
57trim ll ll 0 sqrt(a*a+H*H)
58
59vertex v1 0 -R 0
60vertex v2 0 -R H
61trotate v2 0 0 0 0 0 1 180.*a/pi
62mkedge ee ll cc v1 v2
63wire gg ee
64
65mksweep sp
66setsweep -G gg 0 0
67addsweep lip
68buildsweep spiral -S
69
70mkface f0 p0 -R R -R R
71bsection sflute spiral f0
72
73# here we rely on that section curve is parameterized from 0 to 1
74# and directed as cutting lip edge;
75# note that this can change if intersection algorithm is modified
76explode sflute e
77mkcurve cflute sflute_1
78cvalue cflute 0. x0 y0 z0
79cvalue cflute 1. x1 y1 z1
80vertex vf0 x0 y0 z0
81vertex vf1 x1 y1 z1
82
83# -- variant: replace curve by arc with start at x0,y0,z0 and end at x1,y1,z1,
84# -- such that tanget at start point is along Y
85#dset Rflute ((x1-x0)*(x1-x0)+(y1-y0)*(y1-y0))/(2*(x1-x0))
86#circle aflute x0+Rflute y0 0 0 0 1 Rflute
87#mkedge sflute_1 aflute vf0 vf1
88
89# make rounding in the flute; use circle with radius Rr/2
90circle cround x0+Rr/2 y0 0 0 0 1 Rr/2
91vertex vf3 x0+Rr y0 0
92mkedge sflute_2 cround vf3 vf0
93vertex vf2 R -R 0
94edge sflute_3 vf3 vf2
95edge sflute_4 vf2 vf1
96wire w2 sflute_1 sflute_2 sflute_3 sflute_4
97mkface flute p0 w2
98
99# cut flute from profile
100bcut sec sec flute
101trotate flute 0 0 0 0 0 1 180.
102bcut sec sec flute
103donly sec
104
105# sweep profile to get a drill body
106puts "Sweeping the profile..."
107mksweep sp
108setsweep -G gg 0 0
109explode sec w
110addsweep sec_1
111buildsweep base -S
112
113# sharpen the drill (see http://tool-land.ru/zatochka-sverla.php)
114puts "Sharpening..."
115dset theta a*R/H*sin((90-sigma/2)*pi/180)
116plane ax1 d 1.9*D "H+1.9*D/tan(pi/180.*sigma/2.)" 0 -1 -1
117pcone sh1 ax1 0 100*sin((sigma-90)/2*pi/180.) 100
118trotate sh1 0 0 0 0 0 1 -theta*180/pi
119tcopy sh1 sh2
120trotate sh2 0 0 0 0 0 1 180
121box sh -D/2 -D/2 72 D D 20
122bcommon qq sh1 sh2
123bcut sharpener sh qq
124
125bcut body base sharpener
126
127# make a shank
128puts "Making a shank..."
129plane pl2 0 0 -40 0 0 1
130pcylinder shank pl2 4 40
131pcone transit R 0 R
132plane pl3 0 0 -40 0 0 -0.5
133pcone tail pl3 R 0 0.5
134bfuse shank shank tail
135bfuse shank shank transit
136bfuse drill body shank
137
138# check result
139checkshape drill
140
141# show result
142puts "Displaying result..."
143incmesh drill 0.01
144vinit
145vdisplay drill
146vsetdispmode drill 1
147vfit
148
149# show section and sweep path
150ttranslate sec_1 0 0 H; trotate sec_1 0 0 0 0 0 1 a*180/pi; incmesh gg 0.01; vdisplay gg sec_1
151
152# check square
153renamevar drill result
154set square 3277.87
155
156set only_screen 1