Correction of testing case for issue 24374
[occt.git] / samples / tcl / bottle.tcl
CommitLineData
40093367 1# Script reproducing creation of bottle model as described in OCCT Tutorial
2
3pload MODELING VISUALIZATION
4
821edd22 5puts "Constructing bottle body..."
40093367 6
7# set basic dimensions
8dset height 70
9dset width 50
10dset thickness 30
11
12# construct base profile (half)
13vertex v1 -width/2 0 0
14vertex v2 -width/2 -thickness/4 0
15edge e1 v1 v2
16
17point p2 -width/2 -thickness/4 0
18point p3 0 -thickness/2 0
19point p4 width/2 -thickness/4 0
20catch {gcarc arc cir p2 p3 p4}
21mkedge e2 arc
22
23vertex v4 width/2 -thickness/4 0
24vertex v5 width/2 0 0
25edge e3 v4 v5
26
27wire w1 e1 e2 e3
28
29# complete profile by mirror and make a prism
30copy w1 w2
31tmirror w2 0 0 0 0 1 0
32
33wire w3 w1 w2
34mkplane f w3
35
36prism p f 0 0 height
37
38# fillet all edges
39explode p e
40blend b p thickness/12 p_1 thickness/12 p_2 thickness/12 p_3 thickness/12 p_4 thickness/12 p_5 thickness/12 p_6 thickness/12 p_7 thickness/12 p_8 thickness/12 p_9 thickness/12 p_10 thickness/12 p_11 thickness/12 p_12 thickness/12 p_13 thickness/12 p_14 thickness/12 p_15 thickness/12 p_16 thickness/12 p_17 thickness/12 p_18
41
42# neck dimensions
43dset neckradius thickness/4
44dset neckheight height/10
45
46# add neck
47pcylinder c neckradius neckheight
48ttranslate c 0 0 height
49
50bfuse f b c
51
52# make body hollow
53explode c f
54offsetshape body f -thickness/50 1.e-3 c_2
55
821edd22 56puts "Constructing threading..."
40093367 57
58# make two cylinders
59cylinder c1 0 0 height 0 0 1 neckradius*0.99
60cylinder c2 0 0 height 0 0 1 neckradius*1.05
61
62# define threading dimensions in parametric space
63dset major 2*pi
64dset minor neckheight/10
65
66# make parametric curves for threading
67ellipse el1 2*pi neckheight/2 2*pi neckheight/4 major minor
68ellipse el2 2*pi neckheight/2 2*pi neckheight/4 major minor/4
69
70trim arc1 el1 0 pi
71trim arc2 el2 0 pi
72
732dcvalue el1 0 x1 y1
742dcvalue el1 pi x2 y2
75
76line l x1 y1 x2-x1 y2-y1
77parameters l x2 y2 1.e-9 U
78trim s l 0 U
79
80# construct 3d edges and wires
81mkedge E1OnS1 arc1 c1 0 pi
82mkedge E2OnS1 s c1 0 U
83mkedge E1OnS2 arc2 c2 0 pi
84mkedge E2OnS2 s c2 0 U
85
86wire tw1 E1OnS1 E2OnS1
87wire tw2 E1OnS2 E2OnS2
88mkedgecurve tw1 1.e-5
89mkedgecurve tw2 1.e-5
90
91# build threading as solid
92thrusections -N thread 1 0 tw1 tw2
93
821edd22 94puts "Putting together and writing \"Open CASCADE\"..."
95
40093367 96# add threading to the body
821edd22 97compound body thread bottle
b514beda 98
99# define text
100text2brep text2d OpenCASCADE Times-Roman 8 bold composite=0
101prism text text2d 0 0 2
102trotate text 0 0 0 0 1 0 90
103ttranslate text 24.75 -2 65
104
105# cut operation
821edd22 106bcut bodytext body text
107compound bodytext thread bottle
108
109puts "Showing result..."
40093367 110
111# display result
112vdisplay bottle
113vfit
114vsetdispmode 1
821edd22 115
116# set ray tracing
117if { [regexp {HAVE_OPENCL} [dversion]] } {
118 puts "Trying raytrace mode..."
119 if { ! [catch {vraytrace 1}] } {
120 vtextureenv on 1
121 vfit
122 }
123}