0025236: Sample DRAW script to demonstrate XDE features
[occt.git] / samples / tcl / VisualizationDemo.tcl
1 # Copyright (c) 1999-2014 OPEN CASCADE SAS
2 #
3 # This file is part of Open CASCADE Technology software library.
4 #
5 # This library is free software; you can redistribute it and / or modify it
6 # under the terms of the GNU Lesser General Public version 2.1 as published
7 # by the Free Software Foundation, with special exception defined in the file
8 # OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 # distribution for complete text of the license and disclaimer of any warranty.
10 #
11 # Alternatively, this file may be used under the terms of Open CASCADE
12 # commercial license or contractual agreement.
13
14 # Command to log a message to both command-line and dialog window
15 proc sage { a} {
16     if { ![winfo exists .h ] } {
17         toplevel .h -bg azure3
18         wm title .h "INFO TEST HARNESS"
19         wm geometry .h +320+20
20     } 
21     if { [winfo exists .h.m ] } {
22         set astring [.h.m cget  -text]
23         set newstring "${astring} \n $a"
24         .h.m configure -text $newstring 
25         puts $a
26     } else {
27         message .h.m -justify left -bg azure2 -width 13c -relief ridge -bd 4 -text $a
28         puts $a
29     } 
30     pack .h.m
31     update
32 }
33
34 if { [winfo exists .h ] } {
35     destroy .h
36 }
37
38 pload MODELING VISUALIZATION
39
40 sage " Creating the V3D Viewer"
41 sage "    vinit"
42 sage " " 
43 vinit
44 vclear
45 clear
46
47 sage " Creating the Topological Viewer"
48 sage "    smallview"
49 sage " " 
50 smallview
51 sage " Creating a box"
52 sage "    box  b -10 -10 -10 20 20 20"
53 sage " "
54 box b -10 -10 -10 20 20 20
55 fit
56 sage " Display the box in the V3D Viewer"
57 sage "    vdisplay b"
58 sage " "
59 vdisplay b
60 vfit
61 nexplode b f
62 erase b
63 sage " Draft of two lateral faces "
64 sage "    nexplode b f"
65 sage "    depouille r b  0 0  -1 b_6 -15 10 -10 10  0 0 -1 "
66 sage "    nexplode r f"
67 sage "    depouille rr r  0 0 -1   r_1 -15 -10 -10 10  0 0 -1 "
68 sage " "
69 depouille r b  0 0  -1 b_6 -15 10 -10 10  0 0 -1 
70 clear
71 nexplode r f
72 depouille rr r  0 0 -1   r_1 -15 -10 -10 10  0 0 -1 
73 clear
74 nexplode rr e
75 verase b
76 vdisplay rr
77 vfit
78 sage " Fillet on four lateral edges, then on the top and bottom edges  "
79 sage "    nexplode rr e"
80 sage "    blend result rr 3 rr_2 3 rr_3 3 rr_10 3 rr_11"
81 sage "    nexplode result e"
82 sage "    blend result result 2 result_11 3 result_12"
83 sage " "
84 blend result rr 3 rr_2 3 rr_3 3 rr_10 3 rr_11
85 erase rr
86 erase result
87 nexplode result e
88 blend result result 2 result_11 3 result_12 
89 clear
90 nexplode result f
91 verase rr
92 vdisplay result
93 vfit
94 sage " Creating a profile on the top face "
95 sage "    nexplode result f"
96 sage "    profile p  S result_16 F 10 4 D 1 0 C 2 90. Y 8 C 2 90. X -2 C 2 90. Y -8 C 2 90. X 2
97 "
98 sage " "
99 profile p  S result_16 F 10 4 D 1 0 C 2 90. Y 8 C 2 90. X -2 C 2 90. Y -8 C 2 90. X 2
100 sage " Creating a prism"
101 sage "    prism rr p 0 0 20"
102 sage " "
103 prism rr p 0 0 20
104 sage " Change some attributs : MATERIAL , TRANSPARENCY"
105 sage "    vsetmaterial rr PLASTIC"
106 sage "    vsetcolor rr RED"
107 sage "    vsettransparency result 0.5"
108 sage "    vsetdispmode 1"
109 sage " "
110 vdisplay rr
111 vsetmaterial rr PLASTIC
112 vsettransparency rr 0.5
113 vsetcolor rr RED
114 vsettransparency result 0.5
115 vsetdispmode 1
116 vfit
117 fit
118 sage " Fusion of this prism with the original part "
119 sage "    fuse result rr result"
120 sage " "
121 fuse result rr result
122 donl result
123 vdisplay result
124 vdonly result
125 vfit
126 nexplode result f
127 erase result
128 fit
129
130 sage " Opening the top face"
131 sage "    offsetshape r result -1 0.0001 result_17"
132 sage " "
133 nexplode result f
134
135 offsetshape r result -1 0.0001 result_17
136 vdisplay r
137 vdonly r
138 vfit
139 vsetcolor r MATRABLUE
140 vsettransparency r 0
141
142 sage " Creating a cylinder and positionning it"
143 sage "    pcylinder cyl 2 300"
144 sage "    trotate cyl cyl 0 0 0  1 0 0 45"
145 sage "    ttranslate cyl cyl 0 7.5 0"
146 sage " "
147 pcylinder cyl 2 30
148 vdisplay cyl 
149 vsetcolor cyl RED
150 vfit
151 trotate cyl cyl 0 0 0  1 0 0 45
152 ttranslate cyl cyl 0 7.5 0
153 vdisplay cyl 
154 vsetcolor cyl RED
155 vfit
156 vdisplay cyl 
157 vsetcolor cyl RED
158 vfit
159 sage "Demo completed"