0022785: Draw Harness - add possibility to remove a text drawn by the command vdrawtext
[occt.git] / tests / bugs / vis / bug23226
CommitLineData
3bea4c16 1puts "============"
2puts "OCC23226"
3puts "============"
4puts ""
5#######################################################################
6# Extend OpenGl_Context to store map of shared GPU resources
7#######################################################################
8
9set BugNumber OCC23226
10
11#
12# This test is modified test cdl/934/C2
13#
14
15# this test performs automatical test of primitives array objects by pixel checking
16# this test ALSO DUMPS two result images (the primitives on the images should have
17# same contours, WIREFRAME OBJECTS ARE IN YELLOW-RED COLORS, SHADED OBJECTS ARE
18# BLUE-GREEN COLORS)
19
20set BUGNUMBER OCC22583
21set status 0
22set ImageName1 "occ22583-image1.png"
23set ImageName2 "occ22583-image2.png"
24
25# set window width and height, this values should correspond to a
26# view window sizes to pass the test
27set view_width 405
28set view_height 405
29
30# colors used for tests
31# yellow
32set colorY_R 1
33set colorY_G 1
34set colorY_B 0
35
36# red
37set colorR_R 1
38set colorR_G 0
39set colorR_B 0
40
41# blue
42set colorB_R 0
43set colorB_G 1
44set colorB_B 1
45
46# green
47set colorG_R 0
48set colorG_G 1
49set colorG_B 0
50
51# limit of range where the pixels are tested (sets number of iterations)
52# 30 pixels in width and in height will be enough to test all primitives
53set limit_x 3
54set limit_y 3
55
56# this procedure is internal and will be removed at the end of the script
57# generate points for primitive
58proc generate_points {x y z r g b} {
59 # define top plane points
60 global pts01 pts02 pts03 pts04 pts05 pts06
61 set pts01 "v [expr "$x-5"] [expr "$y+5"] [expr "$z"] n 0 0 -1 c $r $g $b"
62 set pts02 "v [expr "$x "] [expr "$y+5"] [expr "$z"] n 0 0 -1 c $r $g $b"
63 set pts03 "v [expr "$x "] [expr "$y "] [expr "$z"] n 0 0 -1 c $r $g $b"
64 set pts04 "v [expr "$x+5"] [expr "$y "] [expr "$z"] n 0 0 -1 c $r $g $b"
65 set pts05 "v [expr "$x-5"] [expr "$y-5"] [expr "$z"] n 0 0 -1 c $r $g $b"
66 set pts06 "v [expr "$x "] [expr "$y-5"] [expr "$z"] n 0 0 -1 c $r $g $b"
67}
68
69# this procedure is internal and will be removed at the end of the script
70# check pixels of primitive
71proc check_primitive {name1 r g b args} {
72 global limit_x limit_y view_width view_height
73 # show only primitive that we interested in to test
74 vdonly $name1 $args
75 vtop
76 vfit
77
78 # move cursor not to select shape
79 vmoveto 0 0
80 vmoveto 0 0
81
82 # test pixels in a top left corner
83 set TestPassed 0
84 set HasPixel 0
85 for {set i 0} {$i < $limit_x} {incr i} {
86 for {set j 0} {$j < $limit_y} {incr j} {
ccadc126 87 if { "[vreadpixel $i $j rgb]" == "$r $g $b" } {
3bea4c16 88 set HasPixel 1
89 }
90 }
91 }
92 if { $HasPixel == 1 } {
93 set TestPassed [expr $TestPassed + 1]
94 } else {
95 set TestPassed 0
96 }
97
98 # test pixels in bottom left corner
99 set HasPixel 1
100 for {set i 0} {$i < $limit_x} {incr i} {
101 for {set j 0} {$j < $limit_y} {incr j} {
ccadc126 102 set coord_y [expr $view_height-$j]
103 if { "[vreadpixel $i $coord_y rgb]" == "$r $g $b" } {
3bea4c16 104 set HasPixel 1
105 }
106 }
107 }
108 if { $HasPixel == 1 } {
109 set TestPassed [expr $TestPassed + 1]
110 } else {
111 set TestPassed 0
112 }
113
114 # test pixels in center right corner
115 set HasPixel 1
116 for {set i 0} {$i < $limit_x} {incr i} {
117 for {set j 0} {$j < $limit_y} {incr j} {
ccadc126 118 set coord_x [expr ($view_width-$limit_y) + $i]
119 set coord_y [expr ($view_height-$limit_y)/2 + $j]
120 if { "[vreadpixel $coord_x $coord_y rgb]" == "$r $g $b" } {
3bea4c16 121 set HasPixel 1
122 }
123 }
124 }
125 if { $HasPixel == 1 } {
126 set TestPassed [expr $TestPassed + 1]
127 } else {
128 set TestPassed 0
129 }
130
131 # test pixels in center left corner (shouldn't be anything)
132 set HasPixel 0
133 for {set i 0} {$i < $limit_x} {incr i} {
134 for {set j 0} {$j < $limit_y} {incr j} {
ccadc126 135 set coord_x [expr $view_width/4 + $i]
136 set coord_y [expr ($view_height-$limit_y)/2 + $j]
137 if { "[vreadpixel $coord_x $coord_y rgb]" == "$r $g $b" } {
3bea4c16 138 set HasPixel 1
139 }
140 }
141 }
142 if { $HasPixel == 1 } {
143 set TestPassed 0
144 } else {
145 set TestPassed [expr $TestPassed + 1]
146 }
147
148 # show all primitives
149 vdisplayall
150 vtop
151 vfit
152
153 # return a result
154 if { ${TestPassed} == 4 } {
155 return 1
156 } else {
157 return 0
158 }
159}
160
161# ### THIS IS THE HEAD LOOP OF THE TEST ####################
162# During this test primitives are created and displayed
163# with commands vdrawparray, and verified for consistency
164# with check_primitive procedure. In spite of the fact that there
165# a lot of code below, it's similar and divided on the similar
166# blocks of code.
167# The iteration loop is intended to check primitives with
168# "vertex buffer objects" turned off (vbo_enable = 0) and
169# turned on (vbo_enable = 1)
170
171for {set vbo_enable 0} {$vbo_enable < 2} {incr vbo_enable} {
5d1833ef 172 vinit
3bea4c16 173 if { $vbo_enable == 0 } {
174 vvbo 0
175 puts "TEST WITH VBO is OFF"
176 }
177 if { $vbo_enable == 1 } {
178 vvbo 1
179 puts "TEST WITH VBO is ON"
180 }
181
5d1833ef 182## vinit
3bea4c16 183 veraseall
184 vclear
185
186 # this points are only to simplify visiual check of dumped image
187 vpoint point1 65 0 0
188 vpoint point2 -145 0 0
189
190 # ****************************** Graphic3d_ArrayOfPoints ****************************** #
3bea4c16 191 puts "Graphic3d_ArrayOfPoints: TEST"
192 #
193 # 1: verticies
194 #
195 generate_points 60 0 0 $colorY_R $colorY_G $colorY_B
196 eval vdrawparray pt01 points $vbo_enable $pts01 $pts02 $pts03 $pts04 $pts05 $pts06
3bea4c16 197
198 # ****************************** Graphic3d_ArrayOfSegments ****************************** #
3bea4c16 199 puts "Graphic3d_ArrayOfSegments: TEST"
200 #
201 # 1: verticies
202 #
203 generate_points 50 0 0 $colorY_R $colorY_G $colorY_B
204 eval vdrawparray seg01 segments $vbo_enable $pts02 $pts01 $pts01 $pts03 $pts03 $pts05 $pts05 $pts06 $pts06 $pts04 $pts04 $pts02
3bea4c16 205 #
206 # 2: edges
207 #
208 generate_points 40 0 0 $colorR_R $colorR_G $colorR_B
209 eval vdrawparray seg02 segments $vbo_enable $pts01 $pts02 $pts03 $pts04 $pts05 $pts06 e 1 e 2 e 2 e 4 e 4 e 6 e 6 e 5 e 5 e 3 e 3 e 1
3bea4c16 210
211 # ****************************** Graphic3d_ArrayOfPolylines ****************************** #
3bea4c16 212 puts "Graphic3d_ArrayOfPolylines: TEST"
213 #
214 # 1: verticies
215 #
216 generate_points 30 0 0 $colorY_R $colorY_G $colorY_B
217 eval vdrawparray pline01 polylines $vbo_enable $pts02 $pts01 $pts03 $pts05 $pts06 $pts04 $pts02
3bea4c16 218 #
219 # 2: edges
220 #
221 generate_points 20 0 0 $colorR_R $colorR_G $colorR_B
222 eval vdrawparray pline02 polylines $vbo_enable $pts01 $pts02 $pts03 $pts04 $pts05 $pts06 e 2 e 4 e 6 e 5 e 3 e 1 e 2
3bea4c16 223 #
224 # 3: bounds
225 #
226 generate_points 10 0 0 $colorY_R $colorY_G $colorY_B
227 eval vdrawparray pline03 polylines $vbo_enable ( b 3 ( $pts02 $pts01 $pts03 )), ( b 4 ( $pts03 $pts05 $pts06 $pts04 )), ( b 2 ( $pts04 $pts02 ))
3bea4c16 228 #
229 # 4: verticies, bounds and edges
230 #
231 generate_points 0 0 0 $colorR_R $colorR_G $colorR_B
232 eval vdrawparray pline04 polylines $vbo_enable $pts01 $pts02 $pts03 $pts04 $pts05 $pts06 ( b 4 ( e 2 e 1 e 3 e 5 )), ( b 4 ( e 5 e 6 e 4 e 2 ))
3bea4c16 233
234 # ****************************** Graphic3d_ArrayOfTriangles ****************************** #
3bea4c16 235 puts "Graphic3d_ArrayOfTriangles: TEST"
236 #
237 # 1: verticies
238 #
239 generate_points -10 0 0 $colorB_R $colorB_G $colorB_B
240 eval vdrawparray t01 triangles $vbo_enable ( $pts03 $pts02 $pts01 ) , ( $pts03 $pts04 $pts02 ) , ( $pts04 $pts03 $pts06 ) , ( $pts06 $pts03 $pts05 )
3bea4c16 241 #
242 # 2: by edges
243 #
244 generate_points -20 0 0 $colorG_R $colorG_G $colorG_B
245 eval vdrawparray t02 triangles $vbo_enable $pts01 $pts02 $pts03 $pts04 $pts05 $pts06 e 6 e 3 e 5 e 6 e 4 e 3 e 1 e 3 e 2 e 2 e 3 e 4
3bea4c16 246
247 # ****************************** Graphic3d_ArrayOfTriangleFans ****************************** #
3bea4c16 248 puts "Graphic3d_ArrayOfTriangleFans: TEST"
249 #
250 # 1: verticies
251 #
252 generate_points -30 0 0 $colorB_R $colorB_G $colorB_B
253 eval vdrawparray tfan01 trianglefans $vbo_enable ( $pts02 $pts01 $pts03 $pts04 )
254 eval vdrawparray tfan02 trianglefans $vbo_enable ( $pts03 $pts05 $pts06 $pts04 )
3bea4c16 255 #
256 # 2: bounds and verticies
257 #
258 generate_points -40 0 0 $colorG_R $colorG_G $colorG_B
259 eval vdrawparray tfan03 trianglefans $vbo_enable ( b 4 ( $pts02 $pts01 $pts03 $pts04 )), ( b 4 ( $pts03 $pts05 $pts06 $pts04 ))
3bea4c16 260
261 # ****************************** Graphic3d_ArrayOfTriangleStrips ****************************** #
3bea4c16 262 puts "Graphic3d_ArrayOfTriangleStrips: TEST"
263 #
264 # 1: verticies
265 #
266 generate_points -50 0 0 $colorB_R $colorB_G $colorB_B
267 eval vdrawparray tstrip01 trianglestrips $vbo_enable ( $pts06 $pts04 $pts03 $pts02 $pts01 )
268 eval vdrawparray tstrip02 trianglestrips $vbo_enable ( $pts03 $pts05 $pts06 )
3bea4c16 269 #
270 # 2: bounds and verticies
271 #
272 generate_points -60 0 0 $colorG_R $colorG_G $colorG_B
273 eval vdrawparray tstrip03 trianglestrips $vbo_enable ( b 5 ( $pts06 $pts04 $pts03 $pts02 $pts01 )) , ( b 3 ( $pts03 $pts05 $pts06 ))
3bea4c16 274
275 # ****************************** Graphic3d_ArrayOfQuadrangles ****************************** #
3bea4c16 276 puts "Graphic3d_ArrayOfQuadrangles: TEST"
277 #
278 # 1: verticies
279 #
280 generate_points -70 0 0 $colorB_R $colorB_G $colorB_B
281 eval vdrawparray q01 quads $vbo_enable ( $pts01 $pts03 $pts04 $pts02 )
282 eval vdrawparray q02 quads $vbo_enable ( $pts03 $pts05 $pts06 $pts04 )
3bea4c16 283 #
284 # 2: verticies and edges
285 #
286 generate_points -80 0 0 $colorG_R $colorG_G $colorG_B
287 eval vdrawparray q03 quads $vbo_enable $pts01 $pts02 $pts03 $pts04 $pts05 $pts06 e 1 e 3 e 4 e 2 e 3 e 5 e 6 e 4
3bea4c16 288
289 # ****************************** Graphic3d_ArrayOfQuadrangleStrips ****************************** #
3bea4c16 290 puts "Graphic3d_ArrayOfQuadrangleStrips: TEST"
291 #
292 # 1: verticies
293 #
294 generate_points -90 0 0 $colorB_R $colorB_G $colorB_B
295 eval vdrawparray qstrips01 quadstrips $vbo_enable ( $pts02 $pts01 $pts04 $pts03 $pts06 $pts05 )
3bea4c16 296 #
297 # 2: verticies and edges
298 #
299 generate_points -100 0 0 $colorG_R $colorG_G $colorG_B
300 eval vdrawparray qstrips02 quadstrips $vbo_enable ( b 4 ( $pts02 $pts01 $pts04 $pts03 )) , ( b 4 ( $pts04 $pts03 $pts06 $pts05 ))
3bea4c16 301
302 # ****************************** Graphic3d_ArrayOfPolygons ****************************** #
3bea4c16 303 puts "Graphic3d_ArrayOfPolygons: TEST"
304 #
305 # 1: verticies
306 #
307 generate_points -110 0 0 $colorB_R $colorB_G $colorB_B
308 eval vdrawparray poly01 polygons $vbo_enable ( $pts04 $pts02 $pts01 $pts03 $pts05 $pts06 )
3bea4c16 309 #
310 # 2: verticies and bounds
311 #
312 generate_points -120 0 0 $colorG_R $colorG_G $colorG_B
313 eval vdrawparray poly02 polygons $vbo_enable ( b 5 ( $pts04 $pts02 $pts01 $pts03 $pts06 )) , ( b 3 ( $pts06 $pts03 $pts05 ))
3bea4c16 314 #
315 # 3: verticies and edges
316 #
317 generate_points -130 0 0 $colorB_R $colorB_G $colorB_B
318 eval vdrawparray poly03 polygons $vbo_enable $pts01 $pts02 $pts03 $pts04 $pts05 $pts06 e 4 e 2 e 1 e 3 e 5 e 6
3bea4c16 319 #
320 # 4: vertices, bounds and edges
321 #
322 generate_points -140 0 0 $colorG_R $colorG_G $colorG_B
323 eval vdrawparray poly04 polygons $vbo_enable $pts01 $pts02 $pts03 $pts04 $pts05 $pts06 ( b 5 ( e 4 e 2 e 1 e 3 e 6 )), ( b 3 ( e 6 e 3 e 5 ))
3bea4c16 324
325 vtop
326 vfit
327
328 # dump resulted image
5879dab4 329 if { $vbo_enable == 0 } { vfeedback; vdump ${imagedir}/$ImageName1 }
330 if { $vbo_enable == 1 } { vfeedback; vdump ${imagedir}/$ImageName2 }
3bea4c16 331
332}
333
334# delete internal procedures
335rename generate_points ""
336rename check_primitive ""
337
5d1833ef 338checkcolor 200 200 $colorG_R $colorG_G $colorG_B
339checkcolor 220 200 $colorB_R $colorB_G $colorB_B
340if { $stat == 1 } {
341 puts "BUG OK ${BUGNUMBER}"
3bea4c16 342} else {
5d1833ef 343 puts "BUG FAULTY ${BUGNUMBER}"
3bea4c16 344}
345
346set only_screen 1
347
5d1833ef 348