5 ##############################################################
6 # Sample Draw scripts for demonstrating sweeping algorithm
7 ##############################################################
9 if { [regexp {Debug mode} [dversion]] } {
13 # drill parameters (some terms taken from http://www.drill-bits.cn/drill-bits-quality.asp)
14 dset R 4. ;# outer radius
15 dset D 2*R ;# diameter
16 dset Rr 3.5 ;# chisel radius (outer radius minus body clearance)
18 dset b 1. ;# web thickness (approximate)
21 dset H 80. ;# height of the spiral part
22 dset a 3.*pi ;# total angle of spiral rotation
24 dset sigma 118 ;# point angle, in degrees
26 # Create section profile by sequence of Boolean operations
27 # on simple planar objects
28 puts "Creating the drill section profile..."
29 polyline rectangle1 d -R 0 R -R 0 -d R 0 -R R 0 d -R 0
31 circle circle1 0 0 0 0 0 1 R
32 mkedge circle1 circle1
35 circle circle2 0 0 0 0 0 1 Rr
36 mkedge circle2 circle2
40 mkface rectangle1 p0 rectangle1
41 mkface circle1 p0 circle1
42 mkface circle2 p0 circle2
44 bcommon sec rectangle1 circle1
45 # note use of 'fuse' instead of 'bfuse' -- we need to get single face
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
52 polyline lip d -d/2 0 d -R -R/tan(sigma/2*pi/180)
54 polyline sp 0 0 0 0 0 H
55 cylinder cc 0 0 0 0 0 1 0 -4 0 4
57 trim ll ll 0 sqrt(a*a+H*H)
61 trotate v2 0 0 0 0 0 1 180.*a/pi
70 mkface f0 p0 -R R -R R
71 bsection sflute spiral f0
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
77 mkcurve cflute sflute_1
78 cvalue cflute 0. x0 y0 z0
79 cvalue cflute 1. x1 y1 z1
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
89 # make rounding in the flute; use circle with radius Rr/2
90 circle cround x0+Rr/2 y0 0 0 0 1 Rr/2
92 mkedge sflute_2 cround vf3 vf0
96 wire w2 sflute_1 sflute_2 sflute_3 sflute_4
99 # cut flute from profile
101 trotate flute 0 0 0 0 0 1 180.
105 # sweep profile to get a drill body
106 puts "Sweeping the profile..."
113 # sharpen the drill (see http://tool-land.ru/zatochka-sverla.php)
115 dset theta a*R/H*sin((90-sigma/2)*pi/180)
116 plane ax1 d 1.9*D "H+1.9*D/tan(pi/180.*sigma/2.)" 0 -1 -1
117 pcone sh1 ax1 0 100*sin((sigma-90)/2*pi/180.) 100
118 trotate sh1 0 0 0 0 0 1 -theta*180/pi
120 trotate sh2 0 0 0 0 0 1 180
121 box sh -D/2 -D/2 72 D D 20
125 bcut body base sharpener
128 puts "Making a shank..."
129 plane pl2 0 0 -40 0 0 1
130 pcylinder shank pl2 4 40
132 plane pl3 0 0 -40 0 0 -0.5
133 pcone tail pl3 R 0 0.5
134 bfuse shank shank tail
135 bfuse shank shank transit
136 bfuse drill body shank
142 puts "Displaying result..."
149 # show section and sweep path
150 ttranslate 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
153 renamevar drill result
154 checkprops result -s 3277.87
157 checkview -screenshot -3d -path ${imagedir}/${test_image}.png