0027158: BRepMesh manage vertex tolerance in parametric space in improper way
[occt.git] / samples / tcl / cutter.tcl
1 # Sample: creation of milling cutter
2 #Category: Modeling
3 #Title: Milling cutter
4
5 pload MODELING VISUALIZATION
6
7 # parameters
8 dset R  10.    ;# outer radius
9 dset H  20.    ;# height of the spiral part
10 dset a  0.5*pi ;# total angle of spiral rotation
11
12 # make profile
13
14 circle outer 0 0 0 0 0 1 R
15 circle inner 0 0 0 0 0 1 R-2
16 circle round 3 6 0 0 0 1 5
17 polyline cut -2 0 0  -2 R+1 0  0.5 R+1 0  -1 0 0  -2 0 0
18
19 proc _curvetoface {name} {
20   uplevel #0 mkedge $name $name
21   uplevel #0 wire $name $name
22   uplevel #0 mkface $name p0 $name
23 }
24
25 plane p0
26 _curvetoface outer
27 _curvetoface inner
28 _curvetoface round
29 mkface cut p0 cut
30
31 bcommon teeth cut round
32 bcommon teeth teeth outer
33
34 tcopy inner profile
35 set nbteeths 25
36 for {set i 0} {$i < $nbteeths} {incr i} {
37   fuse profile profile teeth
38   trotate teeth 0 0 0 0 0 1 360./$nbteeths
39 }
40
41 # sweep profile along curved shape
42
43 polyline sp 0 0 0  0 0 H
44 cylinder ss 0 0 0  0 0 1  1 0 0  R
45 vertex v1 R 0 0
46 vertex v2 R 0 H
47 line ll 0 0 a H
48 trim ll ll 0 sqrt(a*a+H*H)
49
50 trotate v2 0 0 0 0 0 1 180.*a/pi
51 mkedge ee ll ss v1 v2
52 wire gg ee
53  
54 donly profile sp gg
55 explode profile w
56 tcopy profile_1 profile_2 
57 tcopy profile_1 profile_3
58 tscale profile_1  0 0 0  1./(R-2) 
59 ttranslate profile_2 0 0 H/2
60 tscale profile_2  0 0 H/2  4./(R-2) 
61 ttranslate profile_3 0 0 H
62 tscale profile_3  0 0 H  3./(R-2) 
63
64 mksweep sp
65 setsweep -G gg 0 0
66 addsweep profile_1
67 addsweep profile_2
68 addsweep profile_3
69 vclear
70
71 buildsweep base -S
72
73 # make a shank
74 plane p1 0 0 H 0 0 1
75 pcylinder shank p1 1.4 H
76 plane p2 0 0 H+1 0 0 1
77 pcylinder sh2 p2 1.5 H-1
78 bfuse shank shank sh2
79 bfuse cutter base shank
80
81 # check result
82 checkshape cutter
83
84 # show result
85 incmesh cutter 0.01
86 vdisplay cutter
87 vsetdispmode cutter 1
88 vrenderparams -msaa 8
89 incmesh profile_1 0.01; vdisplay profile_1
90 vfit